ASFHyP3 / hyp3-gamma

HyP3 plugin for generating SAR products with GAMMA
BSD 3-Clause "New" or "Revised" License
30 stars 7 forks source link

Use importlib.metadata instead of depreciated pkg_resources #408

Closed jhkennedy closed 1 year ago

jhkennedy commented 1 year ago

pkg_resources provided by setuptools has a depreciation warning in their docs stating:

:warning: Attention

Use of pkg_resources is discouraged in favor of importlib.resources, importlib.metadata, and their backports (importlib_resources, importlib_metadata). Please consider using those libraries instead of pkg_resources.

This updates the entry_point loading method to use importlib.metadata.entry_points(), which is part of the python standard library, for loading the entry_point functions.

asjohnston-asf commented 1 year ago

The new container build is working as expected:

$ docker run -it --rm ********.dkr.ecr.us-west-2.amazonaws.com/hyp3-gamma:5.7.1.dev3_g2faa736 ++process rtc --help
usage: rtc [-h] [--username USERNAME] [--password PASSWORD] [--bucket BUCKET] [--bucket-prefix BUCKET_PREFIX] [--resolution {10.0,30.0}] [--radiometry {gamma0,sigma0}]
           [--scale {power,decibel,amplitude}] [--speckle-filter SPECKLE_FILTER] [--dem-matching DEM_MATCHING] [--include-dem INCLUDE_DEM] [--include-inc-map INCLUDE_INC_MAP]
           [--include-scattering-area INCLUDE_SCATTERING_AREA] [--include-rgb INCLUDE_RGB] [--dem-name {copernicus,legacy}]
           granule

positional arguments:
  granule

options:
  -h, --help            show this help message and exit
  --username USERNAME
  --password PASSWORD
  --bucket BUCKET
  --bucket-prefix BUCKET_PREFIX
  --resolution {10.0,30.0}
  --radiometry {gamma0,sigma0}
  --scale {power,decibel,amplitude}
  --speckle-filter SPECKLE_FILTER
  --dem-matching DEM_MATCHING
  --include-dem INCLUDE_DEM
  --include-inc-map INCLUDE_INC_MAP
  --include-scattering-area INCLUDE_SCATTERING_AREA
  --include-rgb INCLUDE_RGB
  --dem-name {copernicus,legacy}

$ docker run -it --rm ********.dkr.ecr.us-west-2.amazonaws.com/hyp3-gamma:5.7.1.dev3_g2faa736 ++process insar --help
usage: insar [-h] [--username USERNAME] [--password PASSWORD] [--bucket BUCKET] [--bucket-prefix BUCKET_PREFIX] [--include-dem INCLUDE_DEM] [--include-look-vectors INCLUDE_LOOK_VECTORS]
             [--include-los-displacement INCLUDE_LOS_DISPLACEMENT] [--include-displacement-maps INCLUDE_DISPLACEMENT_MAPS] [--include-wrapped-phase INCLUDE_WRAPPED_PHASE]
             [--include-inc-map INCLUDE_INC_MAP] [--apply-water-mask APPLY_WATER_MASK] [--looks {20x4,10x2}]
             granules [granules ...]

positional arguments:
  granules

options:
  -h, --help            show this help message and exit
  --username USERNAME
  --password PASSWORD
  --bucket BUCKET
  --bucket-prefix BUCKET_PREFIX
  --include-dem INCLUDE_DEM
  --include-look-vectors INCLUDE_LOOK_VECTORS
  --include-los-displacement INCLUDE_LOS_DISPLACEMENT
  --include-displacement-maps INCLUDE_DISPLACEMENT_MAPS
  --include-wrapped-phase INCLUDE_WRAPPED_PHASE
  --include-inc-map INCLUDE_INC_MAP
  --apply-water-mask APPLY_WATER_MASK
  --looks {20x4,10x2}

$ docker run -it --rm ********.dkr.ecr.us-west-2.amazonaws.com/hyp3-gamma:5.7.1.dev3_g2faa736 ++process water_map --help
usage: water_map [-h] [--username USERNAME] [--password PASSWORD] [--bucket BUCKET] [--bucket-prefix BUCKET_PREFIX] [--resolution {10.0,30.0}] [--speckle-filter SPECKLE_FILTER]
                 [--max-vv-threshold MAX_VV_THRESHOLD] [--max-vh-threshold MAX_VH_THRESHOLD] [--hand-threshold HAND_THRESHOLD] [--hand-fraction HAND_FRACTION]
                 [--membership-threshold MEMBERSHIP_THRESHOLD] [--include-flood-depth INCLUDE_FLOOD_DEPTH] [--estimator {iterative,logstat,nmad,numpy}] [--water-level-sigma WATER_LEVEL_SIGMA]
                 [--known-water-threshold KNOWN_WATER_THRESHOLD] [--iterative-min ITERATIVE_MIN] [--iterative-max ITERATIVE_MAX]
                 granule

positional arguments:
  granule

options:
  -h, --help            show this help message and exit
  --username USERNAME
  --password PASSWORD
  --bucket BUCKET
  --bucket-prefix BUCKET_PREFIX
  --resolution {10.0,30.0}
  --speckle-filter SPECKLE_FILTER
  --max-vv-threshold MAX_VV_THRESHOLD
  --max-vh-threshold MAX_VH_THRESHOLD
  --hand-threshold HAND_THRESHOLD
  --hand-fraction HAND_FRACTION
  --membership-threshold MEMBERSHIP_THRESHOLD
  --include-flood-depth INCLUDE_FLOOD_DEPTH
  --estimator {iterative,logstat,nmad,numpy}
  --water-level-sigma WATER_LEVEL_SIGMA
  --known-water-threshold KNOWN_WATER_THRESHOLD
  --iterative-min ITERATIVE_MIN
  --iterative-max ITERATIVE_MAX