Skip to content

absolute module import in stackSentinel/StripMap.py#505

Merged
hfattahi merged 1 commit intoisce-framework:mainfrom
yunjunz:stack
Sep 28, 2022
Merged

absolute module import in stackSentinel/StripMap.py#505
hfattahi merged 1 commit intoisce-framework:mainfrom
yunjunz:stack

Conversation

@yunjunz
Copy link
Contributor

@yunjunz yunjunz commented Jun 17, 2022

This PR replaces the from Stack import * line in stackSentinel.py and stackStripMap.py with the absolute module import below, to allow for pythonic calls to their main().

from topsStack.Stack import *
from stripmapStack.Stack import *

This change requires adding $ISCE_STACK to $PYTHONPATH, thus, would break the previous default setup for stack processors. But it enables a more programmable workflow/recipe for the downstream developers. So I think it's a good change at a small cost: updating the stack processor path setup, which is updated in the README file.

The PR also includes a small change on alosStack: use $ISCE_STACK/alosStack to replace $PATH_ALOSSTACK for style consistency

+ use absolute module import in stackSentinel.py and stackStripMap.py to allow for pythonic calls
   - e.g. stackSentinel.main() and stackStripMap.main()

+ contrib/stack/README.md: update installation note to add $ISCE_STACK to $PYTHONPATH

+ alosStack: use $ISCE_STACK/alosStack to replace $PATH_ALOSSTACK for style consistency
Copy link
Collaborator

@hfattahi hfattahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EJFielding
Copy link
Contributor

Looks helpful to make the alosStack setup more similar to the topsStack and stripmapStack setup.

@rtburns-jpl
Copy link
Member

This change requires adding $ISCE_STACK to $PYTHONPATH

What if we also install topsStack, stripmapStack, etc along with the other python modules? Then we can simply import isce.components.contrib.topsStack instead of having to modify environment variables.

@EJFielding
Copy link
Contributor

@rtburns-jpl I think the problem is that topsStack and stripmapStack have command-line programs with the same name but slightly different functions. That is why @hfattahi kept them separate and we have to add one or the other to the $PYTHONPATH and $PATH to do the processing workflow.

@rtburns-jpl
Copy link
Member

Yeah, we wouldn't be able to install the applications in a flat namespace, so if you wanted to simply run geocodeGdal.py you'd need to add the appropriate directory to your PATH. But we could still install them to the python module directory, so we could also call them unambiguously via e.g. python3 -m isce.components.contrib.topsStack.geocodeGdal

@yunjunz
Copy link
Contributor Author

yunjunz commented Jul 5, 2022

If installed via conda, all the stack processors are currently included in the envs/*/share/isce2 folder, whose path is saved as $ISCE_STACK. I don't know why they are not installed to /envs/insar/lib/python3.8/site-packages/isce directory, whose path is saved as $ISCE_HOME, which is accessible via import isce.*.

Since topsStack is more frequently used in its development version (for me at least), is there an easy way to point isce.components.contrib.topsStack to a non-interpreter directory?

@yunjunz
Copy link
Contributor Author

yunjunz commented Aug 10, 2022

Although the current way of adding $ISCE_STACK to $PYTHON_PATH from this PR is not ideal (as described in @rtburns-jpl comments above), it's consistent with the current setup style of adding $ISCE_STACK to the $PATH. I would suggest that we merge this PR before the new release.

@EJFielding
Copy link
Contributor

We should decide today or tomorrow whether to merge this before we freeze version for the UNAVCO 2022 short course. I don't understand enough about how Python works to advise on the details.

@rtburns-jpl
Copy link
Member

This change requires adding $ISCE_STACK to $PYTHONPATH, thus, would break the previous default setup for stack processors.

If I understand that correctly, we definitely shouldn't merge something breaking for a bugfix release. I think we can come up with something that will not break existing setups, and will make the stack more programmable without involving more env variable trickery.

@yunjunz
Copy link
Contributor Author

yunjunz commented Aug 10, 2022

If I understand that correctly, we definitely shouldn't merge something breaking for a bugfix release.

Yeah, I agree with this.

@yunjunz
Copy link
Contributor Author

yunjunz commented Aug 11, 2022

I think we can come up with something that will not break existing setups, and will make the stack more programmable without involving more env variable trickery.

I would argue that:

  1. the existing setups are manual already, this PR would bring one more line of manual setup, plus a few setup note simplifications to improve the style consistency, thus, it's clear and simple to adjust on the user side, in terms of breaking change;
  2. in the logic of "functionality is more important than elegant implementation", the programmable workflow (which is vital in my own processing) is still worth merging before we find out a better way, which would require other changes that may deserve its own PR.

Thus, I would think it is good to be merged, probably after the currently planned next bugfix release.

Adding @hfattahi and @piyushrpt to see if they have opinions on this.

@hfattahi
Copy link
Collaborator

@rtburns-jpl I think this is useful functionality and would be nice to merge. You can increment the minor release and make it clear in README of the release what users need to change to be able to keep running the stack processor. @yunjunz can help with that clarification.

@rtburns-jpl
Copy link
Member

Ok sounds good, thanks. I'll include this in the next feature release.

@yunjunz
Copy link
Contributor Author

yunjunz commented Aug 11, 2022

Thanks, @hfattahi and @rtburns-jpl. Here is a note for clarification in the release:

NOTE: Since this release, users should add ${ISCE_STACK} to their ${PYTHON_PATH} to be able to keep running the stack processors. For bash users, e.g., it's: export PYTHONPATH=${PYTHONPATH}:${ISCE_STACK}. Check more detailed instruction in the README file.

@hfattahi hfattahi merged commit 9e02af5 into isce-framework:main Sep 28, 2022
@yunjunz yunjunz deleted the stack branch September 28, 2022 20:28
@EJFielding
Copy link
Contributor

@rtburns-jpl When you have some time, I think this is a substantial change to ISCE2 that would merit at least a minor version bump.

yuankailiu added a commit to yuankailiu/isce2 that referenced this pull request May 23, 2023
+ resolve the conflicts since stackSentinel.py has been updated (in isce-framework#505, isce-framework#702)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants