Skip to content

feat(compare_namelists): add TOML support for compare_namelists and mizuRoute baseline comparison - #5024

Draft
johnpaulalex wants to merge 2 commits into
ESMCI:masterfrom
johnpaulalex:feature/mizuroute-toml-cime
Draft

feat(compare_namelists): add TOML support for compare_namelists and mizuRoute baseline comparison#5024
johnpaulalex wants to merge 2 commits into
ESMCI:masterfrom
johnpaulalex:feature/mizuroute-toml-cime

Conversation

@johnpaulalex

@johnpaulalex johnpaulalex commented Aug 8, 2026

Copy link
Copy Markdown

Description of changes

Adds native TOML configuration comparison support to CIME/compare_namelists.py (_compare_tomls) and generalizes _do_full_nl_comp in CIME/case/case_cmpgen_namelists.py to 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'"] in setup.py for Python versions below 3.11.

Expected transition order for mizuRoute going to TOML format:

    1. old baselines are all control
    1. new cases write both toml & control; when they compare with baseline, they continue to use control
    1. we transition baselines to toml; when cases run against those newer baselines, they use toml
    1. Eventually all baselines are toml

Specific notes

Contributors other than yourself, if any:

Linked issues addressed, if any:

  • None

Description of generative AI usage:

  • Google Antigravity was used to write the code and tests, followed by human-guided verification.

Answer Changes & Scientific Impact

  • Bit-for-Bit (B4B) with baseline master
  • Roundoff-level differences only
  • Expected Answer Changes (ECA)

User Interface & Namelist Changes

  • Namelist / Defaults modified? No
  • XML / Build script changes? No

Testing planned or performed, if any:

  • Executed unit tests in CIME/tests/test_unit_compare_namelists.py and CIME/tests/test_unit_cmpgen_namelists_mizuroute.py (6/6 passing).

PR branch hash-tag: bc8143e5066e409dbebcda08dcf2f520ea85c2b0

@johnpaulalex
johnpaulalex force-pushed the feature/mizuroute-toml-cime branch 9 times, most recently from 4e3acaa to e8e404a Compare August 12, 2026 23:57
@ekluzek ekluzek added ty: enhancement Responsibility: CESM Responsibility to manage and accomplish this issue is through CESM tp: CIMElib Responsibility: CTSM Responsibility to manage and accomplish this issue is the CTSM Software group labels Aug 13, 2026

@ekluzek ekluzek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread CIME/case/case_cmpgen_namelists.py Outdated
Comment thread CIME/case/case_cmpgen_namelists.py
Comment thread CIME/compare_namelists.py
Compare contents of two TOML files
"""
try:
import tomllib

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread setup.py
include_package_data=True,
name="CIME",
packages=find_packages(),
install_requires=["tomli; python_version < '3.11'"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

CIME/core/config/bootstrap.py

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.

@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.66%. Comparing base (f8e59ff) to head (bc8143e).
⚠️ Report is 115 commits behind head on master.

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.
📢 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.

@ekluzek

ekluzek commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Responsibility: CESM Responsibility to manage and accomplish this issue is through CESM Responsibility: CTSM Responsibility to manage and accomplish this issue is the CTSM Software group tp: CIMElib ty: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants