Refactor Omega's buildnml into a validated, testable omega_buildnml package - #494
Refactor Omega's buildnml into a validated, testable omega_buildnml package#494andrewdnolan wants to merge 19 commits into
buildnml into a validated, testable omega_buildnml package#494Conversation
03a951b to
8353ebe
Compare
buildnmlbuildnml into a validated, testable omega_buildnml package
There was a problem hiding this comment.
Pull request overview
Refactors Omega’s CIME buildnml into a standalone omega_buildnml Python package that cleanly separates config reading/merging from validation, adds user_nl_omega support, and introduces CI + documentation to keep packaged configuration and Default.yml consistent over time.
Changes:
- Extract
buildnmllogic intocomponents/omega/cime_config/omega_buildnml/with explicit validation and YAML duplicate-key rejection. - Add
validate_config.py, packaged YAML data files for meshes/overrides, and pytest unit coverage for the new package. - Update user/developer docs and add a dedicated GitHub Actions workflow for validation + unit tests.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| components/omega/doc/userGuide/Config.md | Documents user_nl_omega layering/precedence and blocked override options. |
| components/omega/doc/index.md | Adds the new BuildNml dev guide page to the docs index. |
| components/omega/doc/devGuide/BuildNml.md | New developer documentation for buildnml, validation, CI, and mesh support. |
| components/omega/dev-conda.txt | Adds pytest/PyYAML to the Omega dev conda environment. |
| components/omega/cime_config/validate_config.py | New CLI validator to check all packaged meshes/overrides + KNOWN_STREAMS. |
| components/omega/cime_config/user_nl_omega | Converts template guidance to YAML-based overrides and documents blocked settings. |
| components/omega/cime_config/omega_buildnml/validate.py | Implements validation rules for packaged configs and user overrides. |
| components/omega/cime_config/omega_buildnml/tests/test_validate_overrides.py | Unit tests for overrides validation + blocked options + known-streams drift. |
| components/omega/cime_config/omega_buildnml/tests/test_validate_input_files.py | Unit tests for mesh input-file validation rules. |
| components/omega/cime_config/omega_buildnml/tests/test_read_write.py | Unit tests for duplicate-key YAML parsing and user_nl_omega parsing. |
| components/omega/cime_config/omega_buildnml/tests/test_config.py | Unit tests for merge precedence and blocked-options invariants. |
| components/omega/cime_config/omega_buildnml/tests/init.py | Marks tests as a package. |
| components/omega/cime_config/omega_buildnml/README.md | Documents package purpose, dependency constraints, and local dev/test steps. |
| components/omega/cime_config/omega_buildnml/read_write.py | Adds YAML read/write helpers, packaged-data reading, and unique-key YAML loader. |
| components/omega/cime_config/omega_buildnml/data/README.md | Documents packaged YAML data purpose and validation. |
| components/omega/cime_config/omega_buildnml/data/input_files.yaml | Defines mesh→input-file mappings for required IOStreams. |
| components/omega/cime_config/omega_buildnml/data/config_overrides.yaml | Defines coupled and mesh-specific override layers. |
| components/omega/cime_config/omega_buildnml/config.py | Implements layer merging plus runtime overrides and stream file resolution. |
| components/omega/cime_config/omega_buildnml/_types.py | Adds shared typing aliases. |
| components/omega/cime_config/omega_buildnml/init.py | Exposes the package public API (__all__). |
| components/omega/cime_config/buildnml | Switches CIME entrypoint to use omega_buildnml package + user_nl_omega. |
| .pre-commit-config.yaml | Adds types-PyYAML for mypy; adjusts flake8 hook deps. |
| .github/workflows/omega-buildnml-workflow.yml | Adds CI workflow to validate configs and run pytest across Python versions. |
Suppressed comments (1)
components/omega/cime_config/omega_buildnml/read_write.py:28
- The example path in this docstring points to
components/omega/config/Defaults.yml, but the repo usescomponents/omega/configs/Default.yml. Keeping the example accurate helps prevent copy/paste mistakes.
Path to default config file (i.e. components/omega/config/Defaults.yml)
xylar
left a comment
There was a problem hiding this comment.
@andrewdnolan, this looks great! I'm really happy with the direction it's taking.
Just one real topic to discuss, and then a few small comments or questions.
|
@xylar A follow-up to correct/clarify my earlier reply: I overstated the bug a bit.
The real, narrower bug: Separately, while looking at this I noticed Also added |
b5bdac1 to
0418b03
Compare
xylar
left a comment
There was a problem hiding this comment.
With the known streams things and the linting done after the rebase, I'm happy to approve!
0418b03 to
10e314d
Compare
xylar
left a comment
There was a problem hiding this comment.
Re-approving now that KNOWN_STREAMS is gone from the code for real.
cbegeman
left a comment
There was a problem hiding this comment.
Approving on the basis of code inspection. Let me know if any testing would be helpful. Thanks, @andrewdnolan !
Mesh overrides are optional; empty dict when not provided
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Accdidently was turning on tracer restroing which was causing crashes
Point to mesh with correct reconstruction variables names, which were changed as part of E3SM-Project#480
647770d to
11b8a8e
Compare
Summary
Extract
components/omega/cime_config/buildnml's logic into a newomega_buildnmlPython package, adding validation of all input configuration, support foruser_nl_omega, unit tests, a CI workflow, and developer/user documentation.Refactor
buildnmland intoomega_buildnml, split acrossread_write.py(reading/writing YAML),config.py(merging config layers, resolving mesh input files), andvalidate.py(validation).buildnmlinto packaged data files,data/input_files.yamlanddata/config_overrides.yamlValidation
config_overrides.yamlstructure and its options againstconfigs/Default.yml, so overrides can't silently set unknown options.validate.py'sKNOWN_STREAMShasn't drifted from theIOStreamsactually defined inDefault.yml.validate_config.py, a CLI entry point that validates every mesh and override entry in the packaged configuration files (rather than just the ones needed for a single case).user_nl_omegasupportuser_nl_omega, merging them in as the highest-precedence configuration layer.TimeIntegration.StartTime, restart/forcingIOStreams) cannot be overridden by users.Testing and CI
config.py,read_write.py, andvalidate.py.omega-buildnmlGitHub Actions workflow, runningvalidate_config.pyand the unit tests (across supported Python versions) on pull requests touchingcime_config/orDefault.yml.Documentation
omega_buildnml/andomega_buildnml/data/.buildnml, configuration validation, CI, and how to add a new supported mesh.user_nl_omega)" section to the userGuide'sConfig.md, describing the configuration layering and which options are blocked from user override.Checklist
Documentation:
Linting
Provide relevant details in a comment to the PR titled
Testingwith the following:e3sm_submodules/Omegabaseline-pfor both the baseline (Polarise3sm_submodules/Omega) and the PR build