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

JP-3721: Simplify ModelContainer #330

Merged
merged 3 commits into from
Oct 8, 2024
Merged

Conversation

emolter
Copy link
Contributor

@emolter emolter commented Sep 26, 2024

Helps to resolve JP-3721

Helps to close spacetelescope/jwst:8738

This PR enables the JWST ModelContainer to no longer inherit from DataModel as part of an effort to make ModelContainer's usage narrower and easier to understand.

Tasks

  • update or add relevant tests
  • update relevant docstrings and / or docs/ page
  • Does this PR change any API used downstream? (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)
    • run jwst regression tests with this branch installed ("git+https://github.com/<fork>/stdatamodels@<branch>")
news fragment change types...
  • changes/<PR#>.feature.rst: new feature
  • changes/<PR#>.bugfix.rst: fixes an issue
  • changes/<PR#>.doc.rst: documentation change
  • changes/<PR#>.removal.rst: deprecation or removal of public API
  • changes/<PR#>.misc.rst: infrastructure or miscellaneous change

@emolter emolter changed the title JP-3721 JP-3721: Simplify ModelContainer Sep 26, 2024
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.55%. Comparing base (fd6be8d) to head (9bcaae1).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #330   +/-   ##
=======================================
  Coverage   66.55%   66.55%           
=======================================
  Files         102      102           
  Lines        5456     5457    +1     
=======================================
+ Hits         3631     3632    +1     
  Misses       1825     1825           

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

@emolter
Copy link
Contributor Author

emolter commented Oct 8, 2024

@emolter emolter marked this pull request as ready for review October 8, 2024 18:30
@emolter emolter requested a review from a team as a code owner October 8, 2024 18:30
@braingram
Copy link
Collaborator

This PR enables the JWST ModelContainer to no longer inherit from DataModel and to no longer require its own save method, as part of an effort to make ModelContainer's usage narrower and easier to understand.

I follow the changes motivated by the inheritance change. Since ModelContainer is no longer a JwstDataModel subclass it won't enter:

elif isinstance(init, model_base.JwstDataModel):
# Copy the object so it knows not to close here
return init.__class__(init, **kwargs)

by switching list to Sequence here:
elif is_association(init) or isinstance(init, list):
try:
from jwst.datamodels import ModelContainer
except ImportError as err:
raise ValueError("Cannot open an association without the jwst package installed") from err
return ModelContainer(init, **kwargs)

dm.open(container) will do the same thing as before (call ModelContainer(container)).

I don't following the no longer require its own save bit. Is that just in reference to AbstractDataModel.save?

@emolter
Copy link
Contributor Author

emolter commented Oct 8, 2024

I don't following the no longer require its own save bit. Is that just in reference to AbstractDataModel.save?

Yes, and it hasn't got anything to do with stdatamodels specifically, as you correctly point out. I will remove it from the summary

Copy link
Collaborator

@braingram braingram left a comment

Choose a reason for hiding this comment

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

LGTM.

@emolter
Copy link
Contributor Author

emolter commented Oct 8, 2024

regression tests passed. @braingram I don't have permissions to request additional reviewers nor merge in this repository, feel free to do either at your convenience

@braingram braingram merged commit d602f7c into spacetelescope:main Oct 8, 2024
19 checks passed
@emolter emolter deleted the JP-3721 branch October 8, 2024 20:17
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.

Simplify ModelContainer
2 participants