-
Notifications
You must be signed in to change notification settings - Fork 21
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
RCAL-965 Provide conversion from TVAC/FPS models to ScienceRawModel #455
base: main
Are you sure you want to change the base?
RCAL-965 Provide conversion from TVAC/FPS models to ScienceRawModel #455
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #455 +/- ##
==========================================
- Coverage 97.56% 97.19% -0.37%
==========================================
Files 30 37 +7
Lines 2788 3354 +566
==========================================
+ Hits 2720 3260 +540
- Misses 68 94 +26 ☔ View full report in Codecov by Sentry. |
Just trying to figure out how this works... if I do strun roman_elp tvac.asdf, when or where does from_tvac_raw get called? Re schema differences, I think we should try to hit the things that romancal looks for but we don't need to copy everything over just because. The guide window xstart is an interesting case. romancal looks for it, but TVAC doesn't actually use guide windows and so if the code runs I would be fine with it without messing with guide window things. |
@schlafly This is all invoked in the dq_init_step. See romancal PR#1596 |
fc00d0e
to
c89df59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little surprised more changes aren't needed. I notice that there are regression test failures - are these expected?
# Define how to recursively copy all attributes. | ||
def node_update(raw, other): | ||
"""Implement update to directly access each value""" | ||
for key in other.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rather similar to:
https://github.com/spacetelescope/roman_datamodels/blob/main/src/roman_datamodels/datamodels/_datamodels.py#L177
and I seem to recall other spots in the code doing similar recursive updating. Maybe it is best to make a utility function that these methods can call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. There is a subtle difference now, but will look for a way to handle more generically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And methinks have accomplished it.
Thanks, I think this looks reasonable. Can you add some documentation of what exactly we're trying to accomplish here, though? Probably as a docstring in from_tvac_raw, but potentially also in the RTD if there's a reasonable place. i.e., something like: I think the biggest practical issue is that a lot of the guide window stuff changed name and we'll now have those bogus fields twice, which is ugly but practical. That said, since guide windows aren't actually being used for TVAC---I think? @tddesjardins ? --- it's hard for me to justify writing code to do the conversion of all of the unused fields. Have you reviewed the schema to see if that's the biggest area where things got renamed? I went through Tyler's L2 schema doc to try to make sure, and I think that's the case, but it would be good to have another set of eyes on it. |
for more information, see https://pre-commit.ci
c89df59
to
1f4a703
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
@schlafly I've updated the docstrings in both the roman_datamodel's api and the romancal high-level description of the dq_init step. |
For all reviewers: I believe all the comments have been addressed. Ready for full review |
@@ -23,6 +24,78 @@ class FilenameMismatchWarning(UserWarning): | |||
""" | |||
|
|||
|
|||
def _node_update(to_node, from_node, extras=None, extras_key=None, ignore=None): | |||
"""Copy node contents from an existing node to an existing node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Copy node contents from an existing node to an existing node | |
"""Copy node contents from an existing node to another existing node |
|
||
How the copy occurs depends on existence of keys in `to_node` | ||
|
||
If key exists in `to_node`, contents is converted from `from_node` stnode type to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If key exists in `to_node`, contents is converted from `from_node` stnode type to | |
If key exists in `to_node`, contents are converted from `from_node` stnode type to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM outside of the one question I posed
continue | ||
if key in to_node: | ||
if isinstance(to_node[key], Mapping): | ||
_node_update(getattr(to_node, key), getattr(from_node, key), extras=extras, extras_key=extras_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this potentially cause a value to accidentally move things to extras
if, say, a sub-keyword happens to have the same name as a root level keyword that is in extras? Since the extra block isn't examining the hierarchy feeding it?
Resolves RCAL-965
This PR addresses the issue that TVAC/FPS data cannot be run through the pipeline, mostly due to the fact that the TVAC-related datamodels are frozen. A new method,
ScienceRawModel.from_tvac_raw
is introduced to do the conversion.Tasks
roman_datamodels
tests.docs/
page.no-changelog-entry-needed
.)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types).romancal
regression test (https://github.com/spacetelescope/RegressionTests/actions/workflows/romancal.yml) with this branch installed ("git+https://github.com/<fork>/rad@<branch>"
).News fragment change types:
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.misc.rst
: infrastructure or miscellaneous change