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

Add default constructor to datamodels and deprecate the maker_utils #436

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

WilliamJamieson
Copy link
Collaborator

This PR adds the type(datamodel).create_default(**kwargs) instance constructor to each of the datamodel types. This is equivalent to calling maker_utils.mk_datamodel(type(datamodel), **kwargs). This prevents users from accidentally working directly with un-wrapped node objects, external users should be working through the datamodel objects not the nodes. This also simplifies the method to generate a "default" model.

This is the first step in moving the handling of datamodel creation in romancal. The next step will be adding constructor methods construct datamodels from datamodels of a different type where this makes sense.

Tasks

  • Update or add relevant roman_datamodels tests.
  • Update relevant docstrings and / or docs/ page.
  • Does this PR change any API used downstream? (If not, label with no-changelog-entry-needed.)
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

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 96.26866% with 5 lines in your changes missing coverage. Please review.

Project coverage is 97.28%. Comparing base (087a60d) to head (890385e).
Report is 81 commits behind head on main.

Files with missing lines Patch % Lines
src/roman_datamodels/maker_utils.py 0.00% 4 Missing ⚠️
src/roman_datamodels/datamodels/_core.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #436      +/-   ##
==========================================
- Coverage   97.56%   97.28%   -0.29%     
==========================================
  Files          30       38       +8     
  Lines        2788     3420     +632     
==========================================
+ Hits         2720     3327     +607     
- Misses         68       93      +25     

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

Copy link
Collaborator

@mairanteodoro mairanteodoro left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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.

2 participants