Add fre_cli_version to model YAML and enforce version compatibility#768
Add fre_cli_version to model YAML and enforce version compatibility#768
Conversation
|
@copilot small bug with |
Fixed in 092d7e5. The |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
==========================================
+ Coverage 84.10% 84.15% +0.05%
==========================================
Files 70 70
Lines 4780 4796 +16
==========================================
+ Hits 4020 4036 +16
Misses 760 760
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
ready for actual review |
| @@ -1,3 +1,5 @@ | |||
| fre_version: "2025.04" | |||
There was a problem hiding this comment.
Just a note (forward looking) - I think if/when we adopt uw tools for yaml combining things, this might be better under fre_properties (I think they'll turn into more key:value pairs versus just being defined as yaml anchors used elsewhere)
There was a problem hiding this comment.
IMO fre_properties should be optional instead of first-class configuration. fre properties in Bronx are user-specified variables, and we mostly have that style in ours now.
| # Clean the yaml, the key exists, delete | ||
| keys_clean=["name", "platform", "target", # these are needed to create the final parsed dictionary fed to cmor | ||
| "fre_properties", "directories", "experiments", | ||
| "fre_properties", "fre_version", "directories", "experiments", |
There was a problem hiding this comment.
Hm, it might be beneficial for this to stay and not be cleaned (for more information when troubleshooting maybe?). In that case though, it'll probably have to be added to the gfdl_msd_schema.
Another forward looking thought previously discussed was not doing as much cleaning, so users/workflows have more information to find.
There was a problem hiding this comment.
Agree it would be better to keep it, but the compile/pp schemas (fre_make.json, fre_pp.json) have "additionalProperties": false at the top level, so fre_cli_version in the combined YAML would currently fail schema validation. Left it in keys_clean for now with fre_cli_version (renamed). Adding it to the schemas can be a follow-up.
fre/yamltools/helpers.py
Outdated
| return y | ||
|
|
||
|
|
||
| def check_fre_version(yamlfile): |
There was a problem hiding this comment.
type hints might need to be added to this file - just noticed this
There was a problem hiding this comment.
Added -> None return type hint to check_fre_version in a7f048b.
fre/yamltools/helpers.py
Outdated
| # Clean the yaml | ||
| # If keys exists, delete: | ||
| keys_clean=["fre_properties", "experiments"] | ||
| keys_clean=["fre_properties", "fre_version", "experiments"] |
There was a problem hiding this comment.
same clean note as above
092d7e5 to
31216f4
Compare
|
@copilot understand feedback, implement changes based on it |
Done in a7f048b. Changes implemented:
|
| ## fre -v cmor yaml -y fre/yamltools/tests/esm4_cmip6_ex/esm4_cmip6.yaml \ | ||
| ## -e ESM4_TOAR_2014climo_2050ozone_v2 -p gfdl.ncrc5-intel22 -t prod-openmp | ||
|
|
||
| fre_cli_version: "2025.04" |
There was a problem hiding this comment.
Are these fre_cli_version references in the test yamls used?
The new test test_helpers.py test the fre-cli version check functionality without this file.
There was a problem hiding this comment.
Yes, they're used. When consolidate_yamls() runs in tests, it calls check_fre_version() first, which reads fre_cli_version from these model YAMLs. Without the key, every test that calls consolidate_yamls() would log a warning about missing fre_cli_version. The key also now persists in the resolved YAML output (as of 8991fb0), so it's part of the combined output that tests validate.
ceblanton
left a comment
There was a problem hiding this comment.
I'd prefer to keep fre_cli_version in the resolved yaml.
If updating the yaml schema is only change needed to support that, let's do that.
fre/yamltools/helpers.py
Outdated
| # Clean the yaml | ||
| # If keys exists, delete: | ||
| keys_clean=["fre_properties", "experiments"] | ||
| keys_clean=["fre_properties", "fre_cli_version", "experiments"] |
There was a problem hiding this comment.
I'd prefer to keep fre_cli_version in the resolved yaml.
The only change needed to do this would be to add it to the yaml schema, correct?
There was a problem hiding this comment.
Done in 8991fb0. Removed fre_cli_version from keys_clean in both helpers.clean_yaml() and cmor_info_parser.clean_yaml(), so it now persists in all resolved YAMLs (compile, pp, and cmor).
For the schema: fre_pp.json already had "additionalProperties": true so no change needed there. Added fre_cli_version as an allowed string property in fre_make.json (which has "additionalProperties": false). Since the schema is in the gfdl_msd_schemas submodule, a corresponding PR will need to be merged there and the submodule ref updated for CI to pass.
|
Done in 8991fb0. Since the schema is in the
Done in 8991fb0. Changes per feedback:
All 31 tests pass locally. Note: since |
- Add check_fre_version() function to fre/yamltools/helpers.py - Call check_fre_version() in consolidate_yamls() before YAML combining - Update clean_yaml() in helpers.py and cmor_info_parser.py to remove fre_version - Add fre_version to all model YAML test files - Add tests for version checking logic - Update model_yaml.rst documentation Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
… test Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
…caplog assertions The test_exp_list test in test_list_pp_components_script.py asserts all captured log records are INFO level. The debug-level log emitted on successful version check was captured by caplog, causing the assertion 'DEBUG' == 'INFO' to fail. Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
… YAMLs Per reviewer consensus (@singhd789, @ceblanton): rename the YAML key from fre_version to fre_cli_version to distinguish it from fre-workflows version. Also adds type hint (-> None) to check_fre_version function. Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Per @ceblanton's feedback: - Remove fre_cli_version from keys_clean in helpers.clean_yaml() and cmor_info_parser.clean_yaml() so it persists in resolved YAMLs - Add fre_cli_version as allowed property in fre_make.json schema (fre_pp.json already has additionalProperties: true) - Update CMOR comparison test fixture to include fre_cli_version Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/0cd76d05-84ab-4f72-8691-f09098df07f5
8991fb0 to
5d1eca6
Compare
Describe your changes
Adds a
fre_cli_versiontop-level key to model YAMLs, checked against the installed fre-cli version before any YAML combining occurs. Mirrors Bronx'sFRE_VERSIONbehavior. The key is namedfre_cli_version(notfre_version) to clearly distinguish it from fre-workflows versioning.Core logic (
fre/yamltools/helpers.py):check_fre_version(yamlfile: str) -> None— loads model YAML, comparesfre_cli_versiontofre.versionValueErrorwith clear messageIntegration (
fre/yamltools/combine_yamls_script.py):check_fre_version()called at the top ofconsolidate_yamls(), before any use-specific logicResolved YAML persistence:
fre_cli_versionis not cleaned from resolved YAMLs — it persists in compile, pp, and cmor outputs for troubleshooting visibilityfre_cli_versionadded as an allowed property in thefre_make.jsonschema (fre_pp.jsonalready has"additionalProperties": true)fre_cli_versionDocumentation (
docs/usage/yaml_dev/model_yaml.rst):fre_cli_versionkey documentation and updated example YAML structureTest YAMLs: All model YAML test fixtures updated with
fre_cli_version: "2025.04"Bug fix: Removed a debug-level log from
check_fre_version()success path that was breakingfre listtests — specificallytest_list_pp_components_script.py::test_exp_list, which asserts all captured log records are INFO level.Note: The
fre_make.jsonschema change is in thegfdl_msd_schemassubmodule — a corresponding PR needs to be merged there and the submodule reference updated for CI to pass.Issue ticket number and link (if applicable)
Checklist before requesting a review
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.