feat(compare_namelists): add TOML support for compare_namelists and mizuRoute baseline comparison - #5024
Conversation
4e3acaa to
e8e404a
Compare
ekluzek
left a comment
There was a problem hiding this comment.
Adding support for toml files to store namelist file type content is a nice addition. And this can be done before it's done in mizuRoute, it's just adding additional capability.
Largely this is fine, but I'd like to see it a little more general so that mizuRoute doesn't have to be in the filenames.
| Compare contents of two TOML files | ||
| """ | ||
| try: | ||
| import tomllib |
There was a problem hiding this comment.
We talked about a limitation of the standard tomllib library used here is that it removes comments. Which isn't great, but n this context for a comparison it's probably fine.
| include_package_data=True, | ||
| name="CIME", | ||
| packages=find_packages(), | ||
| install_requires=["tomli; python_version < '3.11'"], |
There was a problem hiding this comment.
This should be fine, since python 3.9 is already at end of life. And 3.11 is only having security updates until 2028. So shouldn't be that contraversial to update to 3.11 from 3.9.
There's also a python version checker in
and that perhaps is where this should be set. But, there's a few different places this is done, so I'll defer to someone else who can suggest where this should be done.
…izuRoute baseline comparison
e8e404a to
bc8143e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5024 +/- ##
==========================================
+ Coverage 28.48% 37.66% +9.18%
==========================================
Files 262 134 -128
Lines 38490 19655 -18835
Branches 8146 4166 -3980
==========================================
- Hits 10964 7404 -3560
+ Misses 26268 11390 -14878
+ Partials 1258 861 -397 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@johnpaulalex I updated the header to outline the transition for mizuRoute. The conversion from control file format to TOML format is unique to mizuRoute. Although there is a desire to move all CESM code to use a standard text file format that's independent of compiler. So we do want to remove namelist handling, but that will be way down the road when each CESM/E3SM/NorESM subcomponents have all transitioned away from namelist. I expect that to be years down the road. Note that the control file format that mizuRoute uses is a specific home grown file format not used anywhere else. So moving away from it is a higher priority for mizuRoute than for other components. |
…e_namelists. Initially intended for mizuroute toml files, but the code is generic. Note there was never explicit support for comparing legacy mizuroute control files, they just use the generic text differ if namelist parsing fails; so when the legacy control files go away, there will be nothing to change here. Overrides some of previous commit: * _do_full_nl_comp doesn't look for both toml and control anymore, just toml (since it's just reading merged results). Reverted corresponding test_unit_cmpgen_namelists_mizuroute.py file. * Looks for _toml not .toml
Description of changes
Adds native TOML configuration comparison support to
CIME/compare_namelists.py(_compare_tomls) and generalizes_do_full_nl_compinCIME/case/case_cmpgen_namelists.pyto handle format transitions (e.g..control<->.toml) generically across all CIME components without component-specific string hardcoding.Adds dependency fallback
install_requires=["tomli; python_version < '3.11'"]insetup.pyfor Python versions below 3.11.Expected transition order for mizuRoute going to TOML format:
Specific notes
Contributors other than yourself, if any:
Linked issues addressed, if any:
Description of generative AI usage:
Answer Changes & Scientific Impact
User Interface & Namelist Changes
Testing planned or performed, if any:
CIME/tests/test_unit_compare_namelists.pyandCIME/tests/test_unit_cmpgen_namelists_mizuroute.py(6/6 passing).PR branch hash-tag:
bc8143e5066e409dbebcda08dcf2f520ea85c2b0