Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jdavies-st
Copy link
Collaborator

@jdavies-st jdavies-st commented Nov 29, 2022

This PR addresses a bug in associations/registry.py seen in python 3.11 testing and discussed here

#7333 (comment)

The failure was in unit test jwst/associations/tests/test_asn_from_list.py::test_level2_from_cmdline.

It's not clear to me this is the desired fix. It does fix it, but given that the generated rules produced in the test produce the following rules (produced by adding print(rule_name, obj) at line 322 in registry.py):

Association <class 'jwst.associations.association.Association'>
RegistryMarker <class 'jwst.associations.registry.RegistryMarker'>
AsnMixin_Lv2Image <class 'jwst.associations.lib.rules_level2_base.AsnMixin_Lv2Image'>
AsnMixin_Lv2Nod <class 'jwst.associations.lib.rules_level2_base.AsnMixin_Lv2Nod'>
AsnMixin_Lv2Special <class 'jwst.associations.lib.rules_level2_base.AsnMixin_Lv2Special'>
AsnMixin_Lv2Spectral <class 'jwst.associations.lib.rules_level2_base.AsnMixin_Lv2Spectral'>
AsnMixin_Lv2WFSS <class 'jwst.associations.lib.rules_level2_base.AsnMixin_Lv2WFSS'>
Asn_Lv2FGS <class 'jwst.associations.lib.rules_level2b.Asn_Lv2FGS'>
Asn_Lv2Image <class 'jwst.associations.lib.rules_level2b.Asn_Lv2Image'>
Asn_Lv2ImageNonScience <class 'jwst.associations.lib.rules_level2b.Asn_Lv2ImageNonScience'>
Asn_Lv2ImageSpecial <class 'jwst.associations.lib.rules_level2b.Asn_Lv2ImageSpecial'>
Asn_Lv2ImageTSO <class 'jwst.associations.lib.rules_level2b.Asn_Lv2ImageTSO'>
Asn_Lv2MIRLRSFixedSlitNod <class 'jwst.associations.lib.rules_level2b.Asn_Lv2MIRLRSFixedSlitNod'>
Asn_Lv2NRSFSS <class 'jwst.associations.lib.rules_level2b.Asn_Lv2NRSFSS'>
Asn_Lv2NRSIFUNod <class 'jwst.associations.lib.rules_level2b.Asn_Lv2NRSIFUNod'>
Asn_Lv2NRSLAMPImage <class 'jwst.associations.lib.rules_level2b.Asn_Lv2NRSLAMPImage'>
Asn_Lv2NRSLAMPSpectral <class 'jwst.associations.lib.rules_level2b.Asn_Lv2NRSLAMPSpectral'>
Asn_Lv2NRSMSA <class 'jwst.associations.lib.rules_level2b.Asn_Lv2NRSMSA'>
Asn_Lv2Spec <class 'jwst.associations.lib.rules_level2b.Asn_Lv2Spec'>
Asn_Lv2SpecSpecial <class 'jwst.associations.lib.rules_level2b.Asn_Lv2SpecSpecial'>
Asn_Lv2SpecTSO <class 'jwst.associations.lib.rules_level2b.Asn_Lv2SpecTSO'>
Asn_Lv2WFSC <class 'jwst.associations.lib.rules_level2b.Asn_Lv2WFSC'>
Asn_Lv2WFSSNIS <class 'jwst.associations.lib.rules_level2b.Asn_Lv2WFSSNIS'>
Asn_Lv2WFSSNRC <class 'jwst.associations.lib.rules_level2b.Asn_Lv2WFSSNRC'>
AssociationNotValidError <class 'jwst.associations.exceptions.AssociationNotValidError'>
Constraint <class 'jwst.associations.lib.constraint.Constraint'>
Constraint_Base <class 'jwst.associations.lib.rules_level2_base.Constraint_Base'>
Constraint_ExtCal <class 'jwst.associations.lib.rules_level2_base.Constraint_ExtCal'>
Constraint_Image_Nonscience <class 'jwst.associations.lib.rules_level2_base.Constraint_Image_Nonscience'>
Constraint_Image_Science <class 'jwst.associations.lib.rules_level2_base.Constraint_Image_Science'>
Constraint_Mode <class 'jwst.associations.lib.rules_level2_base.Constraint_Mode'>
Constraint_Single_Science <class 'jwst.associations.lib.rules_level2_base.Constraint_Single_Science'>
Constraint_Special <class 'jwst.associations.lib.rules_level2_base.Constraint_Special'>
Constraint_Spectral_Science <class 'jwst.associations.lib.rules_level2_base.Constraint_Spectral_Science'>
Constraint_TSO <class 'jwst.associations.lib.dms_base.Constraint_TSO'>
Constraint_Target <class 'jwst.associations.lib.rules_level2_base.Constraint_Target'>
Constraint_WFSC <class 'jwst.associations.lib.dms_base.Constraint_WFSC'>
DMSAttrConstraint <class 'jwst.associations.lib.dms_base.DMSAttrConstraint'>
DMSLevel2bBase <class 'jwst.associations.lib.rules_level2_base.DMSLevel2bBase'>
DMS_Level3_Base <class 'jwst.associations.lib.rules_level3_base.DMS_Level3_Base'>
ListCategory <enum 'ListCategory'>
Member <class 'jwst.associations.lib.member.Member'>
RegistryMarker <class 'jwst.associations.registry.RegistryMarker'>
SimpleConstraint <class 'jwst.associations.lib.constraint.SimpleConstraint'>
Utility <class 'jwst.associations.lib.rules_level2_base.Utility'>
deque <class 'collections.deque'>
AsnMixin_AuxData <class 'jwst.associations.lib.rules_level3_base.AsnMixin_AuxData'>
AsnMixin_Science <class 'jwst.associations.lib.rules_level3_base.AsnMixin_Science'>
AsnMixin_Spectrum <class 'jwst.associations.lib.rules_level3_base.AsnMixin_Spectrum'>
Asn_Lv3ACQ_Reprocess <class 'jwst.associations.lib.rules_level3.Asn_Lv3ACQ_Reprocess'>
Asn_Lv3AMI <class 'jwst.associations.lib.rules_level3.Asn_Lv3AMI'>
Asn_Lv3Coron <class 'jwst.associations.lib.rules_level3.Asn_Lv3Coron'>
Asn_Lv3Image <class 'jwst.associations.lib.rules_level3.Asn_Lv3Image'>
Asn_Lv3ImageBackground <class 'jwst.associations.lib.rules_level3.Asn_Lv3ImageBackground'>
Asn_Lv3MIRMRS <class 'jwst.associations.lib.rules_level3.Asn_Lv3MIRMRS'>
Asn_Lv3MIRMRSBackground <class 'jwst.associations.lib.rules_level3.Asn_Lv3MIRMRSBackground'>
Asn_Lv3NRSFSS <class 'jwst.associations.lib.rules_level3.Asn_Lv3NRSFSS'>
Asn_Lv3NRSIFU <class 'jwst.associations.lib.rules_level3.Asn_Lv3NRSIFU'>
Asn_Lv3NRSIFUBackground <class 'jwst.associations.lib.rules_level3.Asn_Lv3NRSIFUBackground'>
Asn_Lv3SlitlessSpectral <class 'jwst.associations.lib.rules_level3.Asn_Lv3SlitlessSpectral'>
Asn_Lv3SpecAux <class 'jwst.associations.lib.rules_level3.Asn_Lv3SpecAux'>
Asn_Lv3SpectralSource <class 'jwst.associations.lib.rules_level3.Asn_Lv3SpectralSource'>
Asn_Lv3SpectralTarget <class 'jwst.associations.lib.rules_level3.Asn_Lv3SpectralTarget'>
Asn_Lv3TSO <class 'jwst.associations.lib.rules_level3.Asn_Lv3TSO'>
Asn_Lv3WFSCMB <class 'jwst.associations.lib.rules_level3.Asn_Lv3WFSCMB'>
Asn_Lv3WFSSNIS <class 'jwst.associations.lib.rules_level3.Asn_Lv3WFSSNIS'>
Constraint <class 'jwst.associations.lib.constraint.Constraint'>
Constraint_Base <class 'jwst.associations.lib.rules_level3_base.Constraint_Base'>
Constraint_IFU <class 'jwst.associations.lib.rules_level3_base.Constraint_IFU'>
Constraint_Image <class 'jwst.associations.lib.rules_level3_base.Constraint_Image'>
Constraint_MSA <class 'jwst.associations.lib.rules_level3_base.Constraint_MSA'>
Constraint_Obsnum <class 'jwst.associations.lib.rules_level3_base.Constraint_Obsnum'>
Constraint_Optical_Path <class 'jwst.associations.lib.rules_level3_base.Constraint_Optical_Path'>
Constraint_Spectral <class 'jwst.associations.lib.rules_level3_base.Constraint_Spectral'>
Constraint_TSO <class 'jwst.associations.lib.dms_base.Constraint_TSO'>
Constraint_Target <class 'jwst.associations.lib.rules_level3_base.Constraint_Target'>
Constraint_TargetAcq <class 'jwst.associations.lib.dms_base.Constraint_TargetAcq'>
DMSAttrConstraint <class 'jwst.associations.lib.dms_base.DMSAttrConstraint'>
DMS_Level3_Base <class 'jwst.associations.lib.rules_level3_base.DMS_Level3_Base'>
ListCategory <enum 'ListCategory'>
RegistryMarker <class 'jwst.associations.registry.RegistryMarker'>
SimpleConstraint <class 'jwst.associations.lib.constraint.SimpleConstraint'>
Utility <class 'jwst.associations.lib.rules_level3_base.Utility'>
202211291522:WARNING:jwst.associations.association.validate:Cannot validate: <class 'abc.Association'> has no schema. Presuming OK.

It might be picking up "rules" that are not actually rules? Are Utility and ListCategory actually rules? I don't follow the way rules are picked up, as I can't follow the importlib usage in these modules.

This PR also fixes a test that litters the repo with jw01439-o002_wfs-image2_*_asn.jsonassociation files by using a tmp_path fixture.

Checklist for maintainers

  • added entry in CHANGES.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant milestone
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR
  • Make sure the JIRA ticket is resolved properly

@jdavies-st jdavies-st changed the title Fix associations bug Fix associations ListCategory enum bug Nov 29, 2022
@codecov
Copy link

codecov bot commented Nov 29, 2022

Codecov Report

Base: 80.02% // Head: 76.98% // Decreases project coverage by -3.03% ⚠️

Coverage data is based on head (1220db4) compared to base (e4c8cb7).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7370      +/-   ##
==========================================
- Coverage   80.02%   76.98%   -3.04%     
==========================================
  Files         413      413              
  Lines       37911    39433    +1522     
==========================================
+ Hits        30339    30359      +20     
- Misses       7572     9074    +1502     
Flag Coverage Δ *Carryforward flag
nightly 79.65% <100.00%> (-0.36%) ⬇️ Carriedforward from c9d8e58
unit 51.88% <100.00%> (+0.04%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
jwst/associations/lib/process_list.py 84.55% <100.00%> (+0.25%) ⬆️
jwst/associations/registry.py 100.00% <100.00%> (+0.60%) ⬆️
jwst/extract_1d/soss_extract/soss_extract.py 38.78% <0.00%> (-51.24%) ⬇️
jwst/extract_1d/soss_extract/soss_solver.py 50.92% <0.00%> (-34.79%) ⬇️
jwst/extract_1d/extract_1d_step.py 45.08% <0.00%> (-31.43%) ⬇️
jwst/wfss_contam/disperse.py 56.71% <0.00%> (-30.79%) ⬇️
jwst/extract_1d/soss_extract/atoca.py 48.08% <0.00%> (-30.33%) ⬇️
jwst/extract_1d/soss_extract/atoca_utils.py 40.42% <0.00%> (-29.48%) ⬇️
jwst/wfss_contam/wfss_contam.py 67.21% <0.00%> (-21.80%) ⬇️
jwst/extract_1d/soss_extract/soss_boxextract.py 68.29% <0.00%> (-21.26%) ⬇️
... and 27 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@stscieisenhamer stscieisenhamer left a comment

Choose a reason for hiding this comment

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

In response to your concerns in the description of the PR: The code, as provided, is OK, in as much what is being seen is OK.

However, hoping your generosity of providing support continues, I have suggested a refactor in the in-line comments.

@jdavies-st jdavies-st force-pushed the fix-associations-bug branch from b72dfec to c58ddff Compare December 8, 2022 10:44
@github-actions github-actions bot removed the testing label Dec 8, 2022
@hbushouse hbushouse added this to the Build 9.1 milestone Dec 8, 2022
@hbushouse
Copy link
Collaborator

Started a regtest run against this PR branch at https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/484/

@hbushouse
Copy link
Collaborator

Regtest run is "clean" in the sense that the only failures are unrelated and are waiting on another open PR to get fixed.

@stscieisenhamer stscieisenhamer self-requested a review December 8, 2022 20:50
@hbushouse
Copy link
Collaborator

Regtests and CI tests are all "clean". @stscieisenhamer are you in approval of this?

Copy link
Collaborator

@stscieisenhamer stscieisenhamer left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks James!

@hbushouse hbushouse merged commit 9fe4938 into spacetelescope:master Dec 9, 2022
@jdavies-st jdavies-st deleted the fix-associations-bug branch December 12, 2022 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants