Skip to content
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

deprecate preserve_comments fix spec parsing for inline comments with closing parenthesis #107

Merged
merged 3 commits into from Sep 6, 2023

Conversation

braingram
Copy link
Collaborator

@braingram braingram commented Sep 5, 2023

Fixes #105

The preserve_comments argument ends up mapping to the _inspec argument for ConfigObj. Setting this appears to break parsing of spec lines that contain inline comments with a closing parenthesis. The preserve_comments argument also appears to have no effect on parsing comments (aside from introducing the bug above).

This PR deprecates preserve_comments and removes internal usage of the _inspec argument. This should fix parsing inline comments for closing parenthesis (this is tested in the included test) and have no effect on comment parsing (also included in the test).

Doing a quick search through romancal and jwst I see no usage of the preserve_comments argument so I don't expect either of those packages to require updates. Hopefully regression tests (to be run below) will reveal if there are any issues with these changes.

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Patch coverage is 93.75% of modified lines.

Files Changed Coverage
src/stpipe/step.py 66.66%
src/stpipe/cmdline.py 100.00%
src/stpipe/config_parser.py 100.00%
src/stpipe/pipeline.py 100.00%
src/stpipe/utilities.py 100.00%

📢 Thoughts on this report? Let us know!.

@braingram braingram changed the title remove _inspec ConfigObj argument usage deprecate preserve_comments fix spec parsing for inline comments with closing parenthesis Sep 6, 2023
@braingram
Copy link
Collaborator Author

docs failure should be fixed with: #109

@braingram braingram marked this pull request as ready for review September 6, 2023 14:07
@braingram braingram requested a review from a team as a code owner September 6, 2023 14:07
@braingram
Copy link
Collaborator Author

braingram commented Sep 6, 2023

Adding @hbushouse for a JWST review
JWST regression tests: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/904/
JWST tests passed with no errors

Adding @WilliamJamieson for a Roman review
Roman regression tests: https://plwishmaster.stsci.edu:8081/job/RT/job/Roman-Developers-Pull-Requests/339/
Roman tests show 1 unrelated error (the one that pops up randomly when the tests are run with xdist):

FAILED romancal/regtest/test_linearity.py::test_linearity_step - ValueError: Block '1' not found.

this argument appears to have no effect other
than breaking specs with comments that contain
a closing parenthesis
Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

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

Looks OK to me. I'm just wondering if removing preserve_comments will have any effect on what you get when just listing the params for a given step or pipeline. For example, right now executing strun -h jump gives you the big list of outputs:

  --min_sat_area        minimum required area for the central saturation of snowballs
  --min_jump_area       minimum area to trigger large events processing
  --expand_factor       The expansion factor for the enclosing circles or ellipses
  --use_ellipses        deprecated
  --sat_required_snowball 
                        Require the center of snowballs to be saturated
  --min_sat_radius_extend 
                        The min radius of the sat core to trigger the extension of the core
  --sat_expand          Number of pixels to add to the radius of the saturated core of snowballs
  --edge_size           Size of region on the edges of NIR detectors where a sat core is not required
  --find_showers        Turn on shower flagging for MIRI
  --extend_snr_threshold 
                        The SNR minimum for detection of extended showers in MIRI
  --extend_min_area     Min area of emission after convolution for the detection of showers
  --extend_inner_radius 
                        Inner radius of the ring_2D_kernel used for convolution
  --extend_outer_radius 
                        Outer radius of the ring_2D_Kernel used for convolution

where the comments on each param are clearly displayed. Will those go away with this change?

@braingram
Copy link
Collaborator Author

strun -h jump

Thanks for taking a look and the questions.

The argument parsing and help output appears unchanged with this PR. Running strun -h jump using stpipe installed from this PR I see output that is identical to the output when run with stpipe main branch.

The spec is parsed using ConfigObj which stores inline comments in the inline_comments attribute. That attribute is used when constructing the argument parser (and help output) here:

comment = subspec.inline_comments.get(key) or ""

@hbushouse hbushouse merged commit 03e0a0f into spacetelescope:master Sep 6, 2023
19 checks passed
@braingram
Copy link
Collaborator Author

Thanks @WilliamJamieson and @hbushouse for the reviews.

@braingram braingram deleted the inline_comments branch September 6, 2023 17:56
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.

Step.spec parsing fails when comment contains a closing parthesis
3 participants