Skip to content

Drop model-native variable attributes from CMORised output - #697

Merged
rhaegar325 merged 1 commit into
mainfrom
fix_raw_attrs_leak_to_cmorised_data
Sep 8, 2026
Merged

Drop model-native variable attributes from CMORised output#697
rhaegar325 merged 1 commit into
mainfrom
fix_raw_attrs_leak_to_cmorised_data

Conversation

@rhaegar325

Copy link
Copy Markdown
Collaborator

Closes #696

What this does

Adds _MODEL_NATIVE_VARIABLE_ATTRIBUTES (8 attributes, from a 30,373-file
scan) and _drop_model_native_attributes() to base.py, called once at the
end of update_attributes() in the atmosphere, ocean and sea-ice CMORisers.
The redundant pop("um_stash_source") in atmosphere.py is removed.

Two decisions worth reviewing

It sweeps every variable, not just self.cmor_name. That is the actual
bug: the old pop never reached auxiliary variables, which is why clw and
orog still shipped um_stash_source in released files.

It is a denylist, not an allowlist. An allowlist would silently drop
coordinates, units_metadata and formula_terms — required CF metadata that
varies by variable and grid. grid_mapping is deliberately kept; it is
legitimate on projected grids.

The helper must run after _check_calendar(), which reads calendar_type to
infer the MOM calendar before it is removed. Both constraints are in the
docstring.

Validation

Five variables covering all four attribute sources, CMORised before and after
from real archives:

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.8%. Comparing base (9ab0ceb) to head (24c7593).

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #697     +/-   ##
=======================================
+ Coverage   78.8%   78.8%   +0.1%     
=======================================
  Files         41      41             
  Lines       9070    9078      +8     
  Branches    1692    1694      +2     
=======================================
+ Hits        7143    7154     +11     
+ Misses      1592    1589      -3     
  Partials     335     335             
Flag Coverage Δ
unit 78.8% <100.0%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rhaegar325
rhaegar325 merged commit 273dbb1 into main Sep 8, 2026
4 checks passed
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.

Model-native attributes leak from raw output into CMORised files

1 participant