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

Move dqflags from romancal to roman_datamodels and make them enums. #293

Merged

Conversation

WilliamJamieson
Copy link
Contributor

When working on jump detection for romancal I noticed that the dqflags were stored in romancal instead of roman_datamodels. The dqflags being directly part of the pipeline instead of the datamodels package proved to be an issue for JWST as some tools wished to not have a direct dependency on the JWST pipeline simply to open and interpret existing output files, see spacetelescope/stdatamodels#134.

This PR begins the process of moving the dqflags from romancal to roman_datamodels by "duplicating" them into roman_datamodels. Note that at this time, romancal will still be referencing its internally defined flags, an update to this effect can be made later to romancal which is seamless to the development process.

Additionally, this PR transitions the dqflags from using simple dictionaries to defining them using an Enum as I discussed briefly with @schlafly. This adds two useful things:

  1. It protects the defined values of the dqflags from accidentally being changed at run time. The current use of a dict is susceptible to the possibility of a module importing the dqflags updating a flag's value, which would change that value globally.
  2. Allows for . access to the flag values e.g. pixel.GOOD while still retaining the dictionary like access e.g. pixel["GOOD"]. The . access is nice because it enables static checkers to "flag" when something like a typo in a flag's name occurs and code completion engine's to suggest the list of possible flags.

Checklist

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bd88351) 97.48% compared to head (74d8aa8) 97.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #293      +/-   ##
==========================================
+ Coverage   97.48%   97.56%   +0.07%     
==========================================
  Files          28       30       +2     
  Lines        2704     2788      +84     
==========================================
+ Hits         2636     2720      +84     
  Misses         68       68              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@WilliamJamieson WilliamJamieson marked this pull request as ready for review February 9, 2024 20:16
@WilliamJamieson WilliamJamieson requested a review from a team as a code owner February 9, 2024 20:16
Copy link
Collaborator

@PaulHuwe PaulHuwe left a comment

Choose a reason for hiding this comment

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

LGTM. Be sure to get approval on the RCAL companion ticket before merging this.

@schlafly
Copy link
Collaborator

This looks good to me. It's good to have this in roman_datamodels rather than romancal so that people can use the flags without bringing in romancal as a dependency.

@WilliamJamieson WilliamJamieson merged commit 6833d01 into spacetelescope:main Feb 12, 2024
16 checks passed
@WilliamJamieson WilliamJamieson deleted the feature/move_dqflags branch February 12, 2024 18:42
WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request Feb 16, 2024
@WilliamJamieson WilliamJamieson mentioned this pull request Feb 16, 2024
4 tasks
WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request Feb 23, 2024
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.

3 participants