-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support selecting steps by package name for strun #202
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
==========================================
- Coverage 94.62% 94.57% -0.05%
==========================================
Files 37 37
Lines 3125 3172 +47
==========================================
+ Hits 2957 3000 +43
- Misses 168 172 +4 ☔ View full report in Codecov by Sentry. |
@@ -21,7 +21,7 @@ def main(): | |||
sys.exit(0) | |||
|
|||
try: | |||
Step.from_cmdline(sys.argv[1:]) | |||
cmdline.step_from_cmdline(sys.argv[1:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not required by this PR (I'm fine removing it) but during debugging it was confusing that this interface calls Step.from_cmdline
which then just calls cmdline.step_from_cmdline
.
Lines 170 to 191 in 799be65
@staticmethod | |
def from_cmdline(args): | |
""" | |
Create a step from a configuration file. | |
Parameters | |
---------- | |
args : list of str | |
Commandline arguments | |
Returns | |
------- | |
step : Step instance | |
If the config file has a ``class`` parameter, the return | |
value will be as instance of that class. | |
Any parameters found in the config file will be set | |
as member variables on the returned `Step` instance. | |
""" | |
from . import cmdline | |
return cmdline.step_from_cmdline(args) |
@@ -1,7 +1,7 @@ | |||
import warnings | |||
from collections import namedtuple | |||
|
|||
from importlib_metadata import entry_points | |||
import importlib_metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to change this import to allow the monkeypatching of "entry_points" in the unit test to work.
the only concern I have is if some user's shell uses |
Good point. Is there a shell that uses that? I don't think bash does and I'm too lazy to try the fancy "new" ones xD |
the only shell I can think of that uses colons is |
Question - isn't it already possible to disambiguate by specifying the package path for the step, e.g. 'strun jwst.resample.ResampleStep'? Is the idea just to add another convenient alias? |
I mean maybe we dip into unicode... |
I think the intent is to reduce unexpected behavior, if a user forgets they have both installed and just calls |
Yeah it's possible to either use the full step class or the class alias. For jwst these are defined here and for romancal here. Some "class aliases" (the second item in each tuple) are common which leads to issues when calling |
We could also add a warning or exception if multiple classes are matched. I think that's worth doing (maybe even part of this PR). To provide a bit more context. The "class alias" is also used for setting the "meta.cal_step" status when the step is skipped. Lines 484 to 486 in 799be65
Which is contributing to spacetelescope/roman_datamodels#343 where if a step is skipped in a pipeline for romancal it's cal_step status is not set to "SKIPPED". This is somewhat a separate issue but as romancal is going to define more class aliases to fix the skip issue it seems worth having a way to disambiguate the alias provided to strun since we will soon have more conflicting aliases (and both pipelines document that using an alias is possible). |
This seems like a good design to me, thanks! |
I see. I thought the original intent was that the class alias should be globally unique for stpipe packages, but it does seem silly to make romancal think of a synonym for "resample". |
Agreed that this seems like a reasonable approach - I think a warning or exception is a useful, if not necessary, addition. I am curious who the "typical" user would be who would encounter this issue, and in what environment this overlap would occur. I am not that familiar with what a typical Roman user is expected to do wrt. processing, locally vs. in the cloud, but I kind of expected processing for the two observatories to require different environments, if not AWS instances vs. local processing. Not that this should prevent a solution, just some speculation! |
I agree that especially as currently Roman isn't operational there aren't many people with both the Webb and Roman pipelines running. But it seemed bad form for the two packages using stpipe to step on one anothers' toes. I think we do want people to be able to have both pipelines running side-by-side in the same environment. |
Roman data will be processed locally as well. There's no reason to expect people won't be interested in both JWST and Roman data. |
Thanks! I'll update this PR with an error (and we'll see if we need to dial it back to a warning). I doubt this will come up for the specific combination of roman and jwst (although @nden objects to saying "you can't have jwst and romancal installed" and I agree). I think the issue is more likely to come up for things like Eureka (which extends the jwst pipeline with additional steps) and as more projects adopt stpipe (we've so far heard of one group working on 1 possibly 2 pipelines). |
I added an error in fd68d87 Testing with jwst and romancal installed if I run
With that environment I can run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a good solution to me, and scaleable to more packages in the future. I think it should remain an error, to enforce muscle habit of specifying the package name before shared aliases. To that end, should all aliases require the package name?
Thanks! I'll run regtests to make sure the error isn't a problem (although I doubt anything will fail given the test setups). I'm ok leaving aliases out when strun can unambiguously sort out the class name. If this goes in I'll work on PRs for jwst and romancal RTD to mention the need for a package name if >1 stpipe supporting package provides the same step names. |
Regtests: |
If a user installs both romancal and jwst and runs the following:
strun will always find the resample step in jwst (even though romancal provides a resample step with the class alias "resample").
This PR adds the ability to filter steps found by strun by providing the package name as a "scope. With this PR a user could call:
to run resample from romancal or
to run resample from jwst.
Documentation in both packages will need to be updated minimally with a description that providing a package name may be required if multiple strun supported packages are provided.
Tasks
docs/
pageno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)"git+https://github.com/<fork>/stpipe@<branch>"
)jwst
regression testromancal
regression testnews fragment change types...
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.misc.rst
: infrastructure or miscellaneous change