Fix tracking_id is minted per CMORiser, not per file - #690
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #690 +/- ##
=====================================
Coverage 78.6% 78.7%
=====================================
Files 41 41
Lines 9021 9028 +7
Branches 1687 1688 +1
=====================================
+ Hits 7094 7101 +7
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.
#Solve 689
Fix
Branch
fix_tracking_id_issue.base.py, +28 lines:_write_singletakes its global attributes from a new helper instead of readingself.ds.attrsdirectly.Three choices worth recording:
hdl:21.14100) and CMIP7 (hdl:21.14107) handles stay defined in their vocabularies. A dataset with no usable id is left alone.self.ds.attrswould leak into later files. The returned dict is only ever read downstream (membership check,generate_filename,_build_drs_path, and the write loop), so reference-to-copy changes nothing else.creation_dateis deliberately not refreshed. Files written in one run legitimately share a creation time, and nothing requires it to differ per file.Validation
Unit tests —
tests/unit/test_tracking_id_per_file.py, 8 tests. Seven cover the helper (distinct ids, prefix preserved, dataset not mutated, other attributes carried through, unusable id left alone);TestSplitWriteMintsIdPerFiledriveswrite()end to end and reads the ids back off disk.That last one matters: covering only the helper leaves the call site untested —
_write_singlecould revert toself.ds.attrsand the other seven would still pass. Mutation-checked in both directions:self.ds.attrsFull suite: 2108 passed.
Real data — years 101–103 with
split_years=1, so one CMORiser writes three files, which is the shape the defect needs: