Skip to content

874.refactor fre yamltools - #975

Draft
singhd789 wants to merge 58 commits into
NOAA-GFDL:mainfrom
singhd789:874.refactor-fre-yamltools
Draft

singhd789 wants to merge 58 commits into
NOAA-GFDL:mainfrom
singhd789:874.refactor-fre-yamltools

Conversation

@singhd789

@singhd789 singhd789 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

  • a lot of the test yamls changes were actually just from RENAMING so they're not AM5 specific

Issue ticket number and link (if applicable)

Fixes #XXX (replace XXX with the issue number and GitHub will autolink the PR to the issue)

Checklist before requesting a review

  • I ran my code
  • I tried to make my code readable
  • I tried to comment my code
  • I wrote a new test, if applicable
  • I wrote new instructions/documentation, if applicable
  • I ran pytest and inspected it's output
  • I ran pylint and attempted to implement some of it's feedback
  • No print statements; all user-facing info uses logging module

Note: If you are a code maintainer updating the tag or releasing a new fre-cli version, please use the release_procedure.md template. To quickly use this template, open a new pull request, choose your branch, and add ?template=release_procedure.md to the end of the url.

@singhd789

Copy link
Copy Markdown
Contributor Author

This PR would probably need to go along with these two:
- update schema for validation tests (NOAA-GFDL/gfdl_msd_schemas#60)
- update environment yaml to rebuild testing environment for uwtools (#976)

@singhd789

singhd789 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

NOTES:

  • keeping the first combine-yamls subtool so ALL the tests don't fail
    • tools that used this subtool include fre make, fre pp, and fre list
    • the yaml formats and scripts need to be adjusted/updated for the incoming changes (to-do in following prs so this one isn't even longer)
  • local tests for the new combine subtool seem to pass locally

Dana Singh added 3 commits September 21, 2026 17:06
- suppress output for when fre list yamls is not piped to fre yamltools combine
- switch combining order for platforms and compile (so users can define reusable variables in platforms)
Copilot AI lite review requested due to automatic review settings September 22, 2026 21:23

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Unresolved critical integration and packaging issues block safe approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 7 High severity · 4 Medium severity · 1 Low severity

Open (12)
What changed in this PR

Refactors YAML composition around uwtools, updates fixtures and CLI/listing workflows, and removes obsolete AM5 examples.

Changes:

  • Adds uwtools packaging dependencies.
  • Migrates YAML fixtures and tests to the new composition model.
  • Adds the refactored combiner and piped YAML support.
File Summary
meta.yaml Adds the uwtools dependency.
fre/​yamltools/​tests/​yamls/​settings.yaml Adds shared settings fixture.
fre/​yamltools/​tests/​yamls/​pp_yamls/​pp.c96_amip.yaml Migrates post-processing configuration.
fre/​yamltools/​tests/​yamls/​pp_yamls/​pp-TEST.c96_amip.yaml Updates test post-processing configuration.
fre/​yamltools/​tests/​yamls/​model.yaml Adds the renamed model fixture.
fre/​yamltools/​tests/​yamls/​grid_yamls/​TEST_grids.yaml Adds grid fixture data.
fre/​yamltools/​tests/​yamls/​compile_yamls/​platforms.yaml Migrates platform properties.
fre/​yamltools/​tests/​yamls/​compile_yamls/​compile.yaml Migrates compile properties.
fre/​yamltools/​tests/​yamls/​compile_yamls/​compile_fail/​wrong_platforms.yaml Updates failing platform fixture.
fre/​yamltools/​tests/​yamls/​compile_yamls/​compile_fail/​wrong_compile.yaml Updates failing compile fixture.
fre/​yamltools/​tests/​yamls/​compile_yamls/​compile_fail/​am5-wrong_datatype.yaml Adds datatype failure fixture.
fre/​yamltools/​tests/​yamls/​compile_yamls/​compile_fail/​am5-wrong_compilefile.yaml Adds missing compile-file fixture.
fre/​yamltools/​tests/​yamls/​COMPARE_TEST_OUTPUT_cmor.yaml Adds expected CMOR output.
fre/​yamltools/​tests/​yamls/​cmor_yamls/​cmor.yaml Migrates CMOR references.
fre/​yamltools/​tests/​yamls/​analysis_yamls/​land.yaml Migrates land analysis properties.
fre/​yamltools/​tests/​yamls/​analysis_yamls/​clouds.yaml Migrates cloud analysis properties.
fre/​yamltools/​tests/​test_combine_yamls_script.py Updates combiner tests.
fre/​yamltools/​tests/​AM5_example/​settings.yaml Removes obsolete settings fixture.
fre/​yamltools/​tests/​AM5_example/​pp_yamls/​pp.c96_amip.yaml Removes obsolete post-processing fixture.
fre/​yamltools/​tests/​AM5_example/​compile_yamls/​compile_fail/​am5-wrong_datatype.yaml Removes obsolete failure fixture.
fre/​yamltools/​tests/​AM5_example/​compile_yamls/​compile_fail/​am5-wrong_compilefile.yaml Removes obsolete failure fixture.
fre/​yamltools/​tests/​AM5_example/​am5.yaml Removes obsolete AM5 fixture.
fre/​yamltools/​helpers.py Updates YAML helper imports.
fre/​yamltools/​freyamltools.py Adds the new combine CLI workflow.
fre/​yamltools/​combine_yamls_script_new.py Implements uwtools-based composition.
fre/​yamltools/​__init__.py Removes legacy constructor registration.
fre/​list_/​list_yamls_script.py Adds piped YAML support.
environment.yml Adds the uwtools channel and dependency.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread fre/yamltools/combine_yamls_script_new.py Outdated
# we don't need all this output but maybe it can be wrapped up in fre_logger.debug if needed?
with open(os.devnull, 'w', encoding="utf-8") as f, contextlib.redirect_stdout(f):
print("This will not be displayed")
combined_yaml_dict = config.compose(configs=yaml_list, realize=True).as_dict()

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.

I think this call to uw config compose will fail if an empty settings yaml is used, as it will be trying to compose a directory.

Comment thread fre/yamltools/freyamltools.py
Comment thread fre/yamltools/helpers.py

# this boots yaml with !join- see __init__
import json
import yaml
Comment on lines +11 to +14
PP_AMIP_CHUNK96: "P1Y"
PP_AMIP_CHUNK384: "P1Y"
PP_XYINTERP96: "180,288"
PP_XYINTERP384: "720,1152"
# check_fre_version(combined)
init_obj = LetsGo(yamls, experiment, platform, target, output)

init_file = f"{Path.cwd()}/init.yaml"

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.

I was wondering if this init file is strictly necessary, and if so, it would be safer to use a defined temporary directory instead of a known filename in the current directory. (What if someone had a init.yaml there for some other project? This would remove it.)

Comment on lines +21 to +22
@click.option("--use", type=click.Choice(['compile','pp', 'cmor']),
help="Process user is combining yamls for. Can pass 'compile', 'pp', or 'cmor'", required=True)

@singhd789 singhd789 Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will be removed (old subtool) with other PRs

Comment thread fre/yamltools/freyamltools.py Outdated
try:
#out =
cy.consolidate_yamls(modelyaml, COMP_EXPERIMENT, COMP_PLATFORM, COMP_TARGET, use, output = None)
cy.yamltools_combine_subtool(yamls, COMP_EXPERIMENT, COMP_PLATFORM, COMP_TARGET, output = None)
Comment thread fre/yamltools/freyamltools.py Outdated
Dana Singh and others added 4 commits October 5, 2026 17:19
update fre list subtools and tests for uwtools integration
 update fre pp configure-yaml and tests for uwtools integration
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.96%. Comparing base (ea0634b) to head (fb03ea4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #975      +/-   ##
==========================================
- Coverage   83.46%   78.96%   -4.51%     
==========================================
  Files          68       69       +1     
  Lines        3811     3903      +92     
==========================================
- Hits         3181     3082      -99     
- Misses        630      821     +191     
Flag Coverage Δ
unittests 78.96% <100.00%> (-4.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
fre/list_/frelist.py 92.59% <100.00%> (+7.97%) ⬆️
fre/list_/list_experiments_script.py 100.00% <100.00%> (ø)
fre/list_/list_platforms_script.py 100.00% <100.00%> (ø)
fre/list_/list_pp_components_script.py 100.00% <100.00%> (+4.34%) ⬆️
fre/list_/list_yamls_script.py 89.85% <100.00%> (+3.41%) ⬆️
fre/pp/configure_script_yaml.py 90.00% <100.00%> (+0.16%) ⬆️
fre/yamltools/combine_yamls_script_new.py 100.00% <100.00%> (ø)
fre/yamltools/freyamltools.py 96.87% <100.00%> (+4.56%) ⬆️
fre/yamltools/helpers.py 66.66% <100.00%> (-26.84%) ⬇️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea0634b...fb03ea4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@singhd789

singhd789 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Note: this PR might help the codecov - #984

Let's try to get that one in first.


yamls = ly.list_yamls_subtool(yamlfile = yml,
experiment = e,
application= "postprocess")

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.

Could this target for the list yamls be general and not specific to postprocessing?

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.

application = ['postprocess', 'analysis']

?

But even then we're stuck with hard-coding postprocess and analysis here in configure_script_yaml.py

Ideally, we want to retrieve these application keys from the yaml, right?

self.y = yamls.split(",")
self.e = str(experiment)
self.p = str(platform)
self.t = str(target)

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.

Should experiment, platform, and target be required or optional?

If they are optional like this, None will be the result if the yaml refers to the experiment, platform, or target.

I suggest we should either make them required, or have a hard error if the yaml uses them and they are not defined.

:type no_clean: boolean
"""
# fre_logger.info('checking fre_cli_version compatibility...')
# check_fre_version(combined)

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 FRE version checking is on my mind, ha. I'm thinking about this Niki problem with using fre/test which is related to this.

Should this be uncommented?

fre_logger.error("List experiments via `fre list -y [model YAML]`")
raise ValueError("Experiment passed DNE")

settings_data = ""

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.

settings yaml is optional. If it's not used, I'm wondering if it should be None rather than an empty string.

if application not in exp_data.keys():
raise ValueError(" *** Application passed is not defined in the model YAML. *** ")

yamls.extend([platform_data, settings_data])

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.

Using settings_data here when the user doesn't have a settings yaml might be safe, but seems iffy if the settings_data is an empty string.

fail = []
fre_logger.info("")
for y in yamls_full_path.split(","):
if not Path(y).exists():

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.

If the settings yaml is not used, the empty string is still part of the yaml list, so this check passes because the base directory exists.

yaml_list.extend(self.y)

for y in yaml_list:
if not Path(y).exists():

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.

I think that an empty settings yaml would also pass here, due to the parent directory existing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update fre list subtools to account for incoming yaml changes and update documentation Refactor fre yamltools combine-yamls

3 participants