remove redundant attrs leaked from raw data - #688
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #688 +/- ##
=====================================
Coverage 78.6% 78.6%
=====================================
Files 41 41
Lines 9018 9021 +3
Branches 1687 1687
=====================================
+ Hits 7091 7094 +3
Misses 1592 1592
Partials 335 335
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
Branch
fix_outname_issue.src/access_moppy/base.pyAn allow-list of the table fields that describe the variable, and a shared helper applying it:
Two decisions carry the safety of this change.
The filter reads the table entry, not the variable's final attributes. Its reach is therefore one assignment:
coordinates,units_metadataand anything inherited from the source file are set elsewhere and cannot be touched, so a name missing from the allow-list cannot silently delete them. A filter over the final attributes would have to enumerate them all, and a gap there deletes real metadata._FillValueandmissing_valuemust be in the list. They are not table fields at all —_get_variable_entryinjects them (defaulting to 1e20, since no CMIP6 or CMIP7 entry carries either), andbase.py:2388reads_FillValueback from the variable attributes to create the netCDF variable.wcrp_cmip7requires both at severity HIGH with a constant of 1e20. Dropping them would write files with no fill value and two weight-3 compliance failures — worse than the leak.The allow-list is a complete partition, not a guess: the CMIP6 and CMIP7 tables carry 16 distinct fields between them, plus the 2 injected ones; 13 are written and 5 are directives.
src/access_moppy/{atmosphere,ocean,sea_ice}.pyEach of the three
attrs.update(...)blocks becomesself._apply_cmor_variable_attributes(cmor_attrs)._drop_stale_range_attributesstill runs immediately afterwards and is unchanged.