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

Split long regtests into reusable fixtures and smaller named tests #1426

Merged
merged 26 commits into from
Oct 7, 2024

Conversation

braingram
Copy link
Collaborator

@braingram braingram commented Sep 30, 2024

Closes #1325

This PR refactors some large regtests:

  • moving the pipeline run to a module scoped fixture (the result will be reused for any tests that use the fixture in the module)
  • splitting asserts into separate named tests that use the new fixture
  • removing the multiple passfail functions and their use (the test results provide information about if the test passed or failed)

There are a few items to resolve for this PR:

  • does the new dms_requirement_tests.json need parametrization values (and are they supported) for parameterized tests that correspond to dms requirements? (for example romancal.regtest.test_mos_pipeline.test_steps_ran now tests DMS400 but technically only using the skymatch parametrization) EDIT: @zacharyburnett confirmed the non-parametrized one is the one to use.
  • many log messages contained mentions of dms requirements that are not in dms_requirement_tests.json (and did not previously have a decorator). These log messages aren't in a format that the metrics collector understands. If these were added to verify a requirement those requirements are not being verified. I suspect we want to convert the log messages into entries into dms_requirement_tests.json and will add comments for those dms requirements.

Regression tests all pass: https://github.com/spacetelescope/RegressionTests/actions/runs/11071508240

Tasks

  • request a review from someone specific, to avoid making the maintainers review every PR
  • add a build milestone, i.e. 24Q4_B15 (use the latest build if not sure)
  • Does this PR change user-facing code / API? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
    • update or add relevant tests
    • update relevant docstrings and / or docs/ page
    • start a regression test and include a link to the running job (click here for instructions)
      • Do truth files need to be updated ("okified")?
        • after the reviewer has approved these changes, run okify_regtests to update the truth files
  • if a JIRA ticket exists, make sure it is resolved properly
news fragment change types...
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change
  • changes/<PR#>.docs.rst
  • changes/<PR#>.stpipe.rst
  • changes/<PR#>.associations.rst
  • changes/<PR#>.scripts.rst
  • changes/<PR#>.mosaic_pipeline.rst
  • changes/<PR#>.patch_match.rst

steps

  • changes/<PR#>.dq_init.rst
  • changes/<PR#>.saturation.rst
  • changes/<PR#>.refpix.rst
  • changes/<PR#>.linearity.rst
  • changes/<PR#>.dark_current.rst
  • changes/<PR#>.jump_detection.rst
  • changes/<PR#>.ramp_fitting.rst
  • changes/<PR#>.assign_wcs.rst
  • changes/<PR#>.flatfield.rst
  • changes/<PR#>.photom.rst
  • changes/<PR#>.flux.rst
  • changes/<PR#>.source_detection.rst
  • changes/<PR#>.tweakreg.rst
  • changes/<PR#>.skymatch.rst
  • changes/<PR#>.outlier_detection.rst
  • changes/<PR#>.resample.rst
  • changes/<PR#>.source_catalog.rst

@braingram braingram changed the title Refactor regtests Split long regtests into reusable fixtures and smaller named tests Sep 30, 2024
def test_output_is_image_model(output_model):
# DMS280 FIXME comment says 280
# DMS414 FIXME log message said 414
# FIXME was not an assert
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The current code:

# DMS280 result is an ImageModel
pipeline.log.info(
"DMS414 MSG: Testing that result is a Level 2 model......."
+ passfail(isinstance(model, rdm.datamodels.ImageModel))
)

Mentions DMS280 in the comment but DMS414 in the log message and contains no assert. What is the expected DMS requirement here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I updated the comments here: 457073d


@pytest.mark.soctests
def test_has_a_wcs(output_model):
# DMS129 TODO not listed
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DMS129 isn't listed in the requirements. Is it satisfied?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we should mark this as done. I can't figure out why it's not picked up by John's page, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added DMS129 in 4c0ad1d

)
def test_steps_ran(output_model, step_name):
# DMS86
# also DMS129 for assign_wcs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

DMS129 should be marked done (i.e., we should add it to the test_requirements_dms.json file)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added DMS129 in 4c0ad1d

@pytest.mark.soctests
@pytest.mark.parametrize("meta_attribute", ("detector", "optical_element"))
def test_instrument_meta(output_model, meta_attribute):
# DMS-136 PSF tests TODO not listed
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DMS136 isn't listed in the requirements. Is it satisfied?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we should go ahead and mark it. I don't understand why it's not tracked on John's "missing requirements" page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Added DMS136 in 229b164


@pytest.mark.soctests
def test_wcs_has_bounding_box(output_model):
# DMS89 WCS tests TODO not listed
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DMS89 is not listed in the requirements. Is it satisfied?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is likewise a requirement that should be added to the requirements.json list; we've delivered this requirement and this was the test that did that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added DMS89 in 03ce0ad

def test_resample_ran(output_model):
# DMS373 test output is resampled to a skycell
# FIXME this doesn't test if the output is a skyceell
assert output_model.meta.cal_step.resample == "COMPLETE"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous code:

pipeline.log.info(
"DMS373 MSG: Testing the creation of a Level 3 mosaic image resampled to a skycell"
+ passfail(model.meta.cal_step.resample == "COMPLETE")
)

mentions that the requirement is that the output is resampled to a skycell. The test doesn't appear to test that (and was not previously an assert).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that the comment is misleading. Let's leave this for now. Perhaps the test should be updated to look for https://github.com/spacetelescope/rad/blob/main/src/rad/resources/schemas/mosaic_basic-1.0.0.yaml#L133 , but I'm not sure that we actually populate that right now. I'll spin that into a separate issue.

@braingram
Copy link
Collaborator Author

I'm going to open this for review to try to get some help on the questions about the DMS requirements. There are a number of inconsistencies and missing requirements (ones mentioned in the code but not in the requirement file, for the ones I investigated they also did not previously have a decorator).

@braingram braingram marked this pull request as ready for review September 30, 2024 13:45
@braingram braingram enabled auto-merge October 7, 2024 21:23
@braingram braingram merged commit c806e09 into spacetelescope:main Oct 7, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants