ASFHyP3 / hyp3-autorift

A HyP3 plugin for feature tracking processing with AutoRIFT-ISCE
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

__init__.py:main fails with ValueError: too many values to unpack #246

Closed asjohnston-asf closed 3 months ago

asjohnston-asf commented 5 months ago
$ python -m hyp3_autorift ++process hyp3_autorift S1A_IW_SLC__1SSH_20170118T091036_20170118T091104_014884_01846D_01C5 S1B_IW_SLC__1SSH_20170112T090955_20170112T091023_003813_0068DC_C750
Traceback (most recent call last):
  File "/home/asjohnston/mambaforge/envs/hyp3-autorift/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/asjohnston/mambaforge/envs/hyp3-autorift/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/asjohnston/src/hyp3-autorift/src/hyp3_autorift/__main__.py", line 47, in <module>
    main()
  File "/home/asjohnston/src/hyp3-autorift/src/hyp3_autorift/__main__.py", line 38, in main
    (process_entry_point,) = {process for process in eps if process.name == args.process}
ValueError: too many values to unpack (expected 1)

Reviewing importlib.metadata.entry_points, there are multiple entry points registered with the same hyp3_autorift name:

>>> from importlib.metadata import entry_points
>>> for ep in entry_points()['console_scripts']:
...     if ep.name == 'hyp3_autorift':
...         print(ep)
... 
EntryPoint(name='hyp3_autorift', value='hyp3_autorift.__main__:main', group='console_scripts')
EntryPoint(name='hyp3_autorift', value='hyp3_autorift.process:main', group='console_scripts')
EntryPoint(name='hyp3_autorift', value='hyp3_autorift.process:main', group='console_scripts')

This was possibly introduced when migrating from setup.py to pyproject.toml

asjohnston-asf commented 5 months ago

Invoking the hyp3_autorift console script without python -m works just fine:

$ hyp3_autorift S1A_IW_SLC__1SSH_20170118T091036_20170118T091104_014884_01846D_01C5 S1B_IW_SLC__1SSH_20170112T090955_20170112T091023_003813_0068DC_C750
This is the Open Source version of ISCE.
Some of the workflows depend on a separate licensed package.
To obtain the licensed package, please make a request for ISCE
through the website: https://download.jpl.nasa.gov/ops/request/index.cfm.
Alternatively, if you are a member, or can become a member of WinSAR
you may be able to obtain access to a version of the licensed sofware at
https://winsar.unavco.org/software/isce
2024-03-18 11:47:15,322 - matplotlib - DEBUG - matplotlib data path: /home/asjohnston/mambaforge/envs/hyp3-autorift/lib/python3.9/site-packages/matplotlib/mpl-data
2024-03-18 11:47:15,327 - matplotlib - DEBUG - CONFIGDIR=/home/asjohnston/.config/matplotlib
2024-03-18 11:47:15,329 - matplotlib - DEBUG - interactive is False
2024-03-18 11:47:15,329 - matplotlib - DEBUG - platform is linux
2024-03-18 11:47:15,382 - matplotlib - DEBUG - CACHEDIR=/home/asjohnston/.cache/matplotlib
2024-03-18 11:47:15,384 - matplotlib.font_manager - DEBUG - Using fontManager instance from /home/asjohnston/.cache/matplotlib/fontlist-v330.json
2024-03-18 11:47:16,361 - root - INFO - Downloading https://sentinel1.asf.alaska.edu/SLC/SB/S1B_IW_SLC__1SSH_20170112T090955_20170112T091023_003813_0068DC_C750.zip
...
jhkennedy commented 3 months ago

Currently, the only console script entry points are:

[project.scripts]
hyp3_autorift = "hyp3_autorift.process:main"
s1_correction = "hyp3_autorift.s1_correction:main"

and we dropped hyp3_autorift = hyp3_autorift.__main__:main in v0.11.0, https://github.com/ASFHyP3/hyp3-autorift/compare/v0.10.5...v0.11.0#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7L65-L66

before we cut over to pyproject.toml and a src layout in v0.13.0, so I don't think this is related to that change.

My guess is that pip didn't clean up the entry points appropriately when hyp3_autorift was updated sometime before v0.11.0 and now. I would expect a fresh environment and pip install to solve the issue.

asjohnston-asf commented 3 months ago

I've confirmed I can't reproduce my original issue using a fresh install of v0.15.0:

$ git clone git@github.com:ASFHyP3/hyp3-autorift.git
$ cd hyp3-autorift/
$ mamba env create -f environment.yml 
$ mamba activate hyp3-autorift
$ python -m pip install -e .

$ python -m hyp3_autorift ++process hyp3_autorift S1A_IW_SLC__1SSH_20170118T091036_20170118T091104_014884_01846D_01C5 S1B_IW_SLC__1SSH_20170112T090955_20170112T091023_003813_0068DC_C750
This is the Open Source version of ISCE.
Some of the workflows depend on a separate licensed package.
To obtain the licensed package, please make a request for ISCE
through the website: https://download.jpl.nasa.gov/ops/request/index.cfm.
Alternatively, if you are a member, or can become a member of WinSAR
you may be able to obtain access to a version of the licensed sofware at
https://winsar.unavco.org/software/isce
2024-05-07 14:06:27,736 - matplotlib - DEBUG - matplotlib data path: /home/asjohnston/mambaforge/envs/hyp3-autorift/lib/python3.9/site-packages/matplotlib/mpl-data
2024-05-07 14:06:27,740 - matplotlib - DEBUG - CONFIGDIR=/home/asjohnston/.config/matplotlib
2024-05-07 14:06:27,741 - matplotlib - DEBUG - interactive is False
2024-05-07 14:06:27,741 - matplotlib - DEBUG - platform is linux
2024-05-07 14:06:27,785 - matplotlib - DEBUG - CACHEDIR=/home/asjohnston/.cache/matplotlib
2024-05-07 14:06:27,787 - matplotlib.font_manager - DEBUG - Using fontManager instance from /home/asjohnston/.cache/matplotlib/fontlist-v330.json
2024-05-07 14:06:28,392 - root - INFO - Downloading https://sentinel1.asf.alaska.edu/SLC/SB/S1B_IW_SLC__1SSH_20170112T090955_20170112T091023_003813_0068DC_C750.zip