Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
83d1a59
#874 refactoring fre yamltools combine-yamls to use uw tools
Apr 27, 2026
75fb2ab
#874 add uw tools and refactor combine tool
Jul 17, 2026
cf205ee
#874 Merge branch 'main' of github.com:singhd789/fre-cli into 874.re…
Sep 4, 2026
b1e337a
#874 address pylint messages and add ability to pipe subtools
Sep 4, 2026
db6c29b
#874 update uwtools version
Sep 14, 2026
bbd6c15
#874 Merge branch 'main' of github.com:singhd789/fre-cli into 874.re…
Sep 14, 2026
d637e59
#874 remove am5 specifics
Sep 21, 2026
787547c
#874 update scripts and tests
Sep 21, 2026
8373574
#874 update tests
Sep 21, 2026
b5cd885
#874 address some pylint messages
Sep 21, 2026
01fa034
#874 more cleanup
Sep 21, 2026
428cd64
#874 slight cleanup for fre list yamls
Sep 22, 2026
a978de4
#874 update logging usage, comments, and documentation
Sep 22, 2026
80a54a0
#874 add uwtools dependency
Sep 23, 2026
c108b55
#874 update readme
Sep 23, 2026
43c4f9a
#874 update tests and address a comment
Sep 23, 2026
d9c3d93
#874 TEMPORARY - add back in so all tests don't fail
Sep 23, 2026
e15243e
#874 add test for piping subtools
Sep 23, 2026
200cdd2
Merge branch 'main' into 874.refactor-fre-yamltools
singhd789 Sep 23, 2026
53be9e3
#874 update
Sep 23, 2026
2e50fcd
#874 Merge branch '874.refactor-fre-yamltools' of github.com:singhd7…
Sep 23, 2026
fe7c433
#874 update
Sep 23, 2026
e061872
#874 undo these - changes in a different PR
Sep 29, 2026
590e233
#874 Merge branch 'main' of github.com:singhd789/fre-cli into 874.re…
Sep 30, 2026
4e47ba7
#874 update submodule
Oct 1, 2026
ccc5a72
#874 update yaml format for updated schema
Oct 1, 2026
18984e0
update fre pp configure-yaml and tests for uwtools integration
Oct 1, 2026
3bd89e4
clean up
Oct 1, 2026
5d81596
update fre list subtools to use tool with uwtools
Oct 1, 2026
b432561
fix tests and add test yamls
Oct 1, 2026
559ede1
update fre yamltools compile tests
Oct 2, 2026
d3546ea
whoops remove this
Oct 2, 2026
66b5f6b
only target fre package NOT uwtools logger
Oct 2, 2026
6a75cfc
do the same for other tests
Oct 2, 2026
f12f103
fix test for yaml additions
Oct 2, 2026
361eac9
Fix conda install command in build_conda.yml
singhd789 Oct 5, 2026
f0803f3
Add conda solver configuration to build workflow
singhd789 Oct 5, 2026
fc0c4fc
Actually set the solver as classic
singhd789 Oct 5, 2026
e9440fb
test version that worked before
Oct 5, 2026
6931715
install libmamba
Oct 5, 2026
76fb85a
remove version specification
Oct 5, 2026
79bfe51
hopefully fix build
Oct 6, 2026
5c387c4
Merge pull request #5 from singhd789/update-fre-list-tests
singhd789 Oct 7, 2026
a5de5f4
Merge pull request #4 from singhd789/update-fre-pp-yaml-tests
singhd789 Oct 7, 2026
98337b6
#874 clean up
Oct 7, 2026
6955bef
#874 add test
Oct 7, 2026
7b52b9a
#874 cover tests
Oct 7, 2026
119f8d3
#874 improve test coverage for failing test
Oct 7, 2026
fb49784
#874 attempt to fix failing code coverage
Oct 7, 2026
4e21ba6
#874 improve test coverage for failing test
Oct 7, 2026
293c384
Merge branch 'main' into 874.refactor-fre-yamltools
singhd789 Oct 9, 2026
e73d4a8
#874 try testing package this way
Oct 13, 2026
f437f53
#874 Merge branch '874.refactor-fre-yamltools' of github.com:singhd7…
Oct 13, 2026
0aad4cc
#874 try adding python
Oct 13, 2026
c558766
#874 pin libmamba version
Oct 14, 2026
58017b5
#874 revert changes
Oct 14, 2026
299ba12
Merge branch 'main' into 874.refactor-fre-yamltools
singhd789 Oct 15, 2026
fb03ea4
Merge branch 'main' into 874.refactor-fre-yamltools
singhd789 Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fre/gfdl_msd_schemas
9 changes: 7 additions & 2 deletions fre/list_/frelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ def platforms(yamlfile):
type=str,
help="Experiment to be post-processed",
required=True)
def pp_components(yamlfile, experiment):
@click.option("-a",
"--application",
type=str,
help="Post-processing application name.",
required=True)
def pp_components(yamlfile, experiment, application):
""" - List components to be post-processed for a defined experiment"""
list_pp_components_script.list_ppcomps_subtool(yamlfile, experiment)
list_pp_components_script.list_ppcomps_subtool(yamlfile, experiment, application)

@list_cli.command()
@click.option("-y",
Expand Down
51 changes: 12 additions & 39 deletions fre/list_/list_experiments_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
"""

import logging
import yaml

from fre.yamltools.info_parsers import pp_info_parser as ppip

## to-do: figure out validation
# Imports associated with commented block
# from pathlib import Path
# from fre.yamltools import helpers
# from fre.yamltools import combine_yamls_script as cy
from fre.yamltools import combine_yamls_script_new as cy

fre_logger = logging.getLogger(__name__)

Expand All @@ -29,44 +21,25 @@ def list_experiments_subtool(yamlfile: str):
platform = None
target = None

# Combine model
# Create pp yaml instance
yamldict = ppip.InitPPYaml(yamlfile, exp, platform, target)
yaml_str = yamldict.combine_model()
yaml_dict = yaml.load(yaml_str, Loader = yaml.Loader)
yaml_dict = cy.yamltools_combine_subtool(yamls = yamlfile,
experiment = exp,
platform = platform,
target = target,
output = None,
no_clean = True)

## COULD HAVE been one way to validate but section we'd want to parse was
## cleaned in final/"combined" yaml information
## Currently not a way to validate model yaml information because we only
## have schemas for the final "combined" compile or pp information (both
## of which remove the "experiments" section I believe
# exp = yamlfile.split("/")[-1].split(".")[0]
# platform = "None"
# target = "None"
#
# # Combine model / experiment
# yml_dict = cy.consolidate_yamls(yamlfile = yamlfile,
# experiment = exp,
# platform = platform,
# target = target,
# use = "compile",
# output = None)
#
# # Validate combined yaml information
# frelist_dir = Path(__file__).resolve().parents[2]
# schema_path = f"{frelist_dir}/fre/gfdl_msd_schemas/FRE/fre_make.json"
# # from fre.yamltools
# helpers.validate_yaml(yml_dict, schema_path)
#### TO-DO: CURRENTLY NO YAML PIECE VALIDATION
### No way to validate just the model yaml

# set logger level to INFO
former_log_level = fre_logger.level
fre_logger.setLevel(logging.INFO)

# log the experiment names, which should show up on screen for sure
fre_logger.info("Experiments found:")
for i in yaml_dict.get("experiments"):
fre_logger.info(' - %s', i.get("name"))
fre_logger.info("\n")

for i in yaml_dict["experiments"].keys():
fre_logger.info(' - %s', i)

# set logger back to normal level
fre_logger.setLevel(former_log_level)
38 changes: 27 additions & 11 deletions fre/list_/list_platforms_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from pathlib import Path
import logging
from fre.yamltools import combine_yamls_script as cy
from fre.yamltools import combine_yamls_script_new as cy
from fre.list_ import list_yamls_script as ly
from fre.yamltools import helpers

fre_logger = logging.getLogger(__name__)
Expand All @@ -22,17 +23,33 @@ def list_platforms_subtool(yamlfile: str):
former_log_level = fre_logger.level
fre_logger.setLevel(logging.INFO)

exp = yamlfile.split("/")[-1].split(".")[0]
exp = None
platform = None
target = None

# Combine model / experiment
yml_dict = cy.consolidate_yamls(yamlfile = yamlfile,
experiment = exp,
platform = platform,
target = target,
use = "compile",
output = None)
# model_yf_path = Path(yamlfile).resolve().parent
# with open(yamlfile, 'r') as yf:
# yml = yaml.safe_load(yf)
#
# platform_yf_path = f"{model_yf_path}/{yml['build']['platformYaml']}"

yml_list = ly.list_yamls_subtool(yamlfile = yamlfile,
experiment = exp,
application = None)

# # Combine model / experiment
# yml_dict = cy.consolidate_yamls(yamlfile = yamlfile,
# experiment = exp,
# platform = platform,
# target = target,
# use = "compile",
# output = None)
yml_dict = cy.yamltools_combine_subtool(yamls = yml_list,
experiment = exp,
platform = platform,
target = target,
output = None,
no_clean = False)

# Validate the yaml
fre_pkg_dir = Path(__file__).resolve().parents[1]
Expand All @@ -41,8 +58,7 @@ def list_platforms_subtool(yamlfile: str):
helpers.validate_yaml(yml_dict, schema_path)

fre_logger.info("Platforms available:")
for i in yml_dict.get("platforms"):
for i in yml_dict["platforms"]:
fre_logger.info(' - %s', i.get("name"))
fre_logger.info("\n")

fre_logger.setLevel(former_log_level)
45 changes: 30 additions & 15 deletions fre/list_/list_pp_components_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@

from pathlib import Path
import logging
from fre.yamltools import combine_yamls_script as cy
from fre.yamltools import combine_yamls_script_new as cy
from fre.list_ import list_yamls_script as ly
from fre.yamltools import helpers

fre_logger = logging.getLogger(__name__)

def list_ppcomps_subtool(yamlfile: str, experiment: str):
def list_ppcomps_subtool(yamlfile: str, experiment: str, application: str):
"""
List_ppcomps_subtool lists the components to be post-processed.

:param yamlfile: is the path to the model.yaml configuration file
:type yamlfile: str
:param experiment: is the experiment name defined in the model.yaml
:type experiment: str
:param application:
:type applicatin: str
"""
# set logger level to INFO
former_log_level = fre_logger.level
Expand All @@ -40,30 +43,42 @@ def list_ppcomps_subtool(yamlfile: str, experiment: str):
exp = experiment
platform = None
target = None
app = application

yml_list = ly.list_yamls_subtool(yamlfile = yamlfile,
experiment = exp,
application = app)

# # Combine model / experiment
# yml_dict = cy.consolidate_yamls(yamlfile = yamlfile,
# experiment = exp,
# platform = platform,
# target = target,
# use = "pp",
# output = None)
yml_dict = cy.yamltools_combine_subtool(yamls = yml_list,
experiment = exp,
platform = platform,
target = target,
output = None,
no_clean = False)

# Combine model / experiment
yml_dict = cy.consolidate_yamls(yamlfile = yamlfile,
experiment = exp,
platform = platform,
target = target,
use = "pp",
output = None)

# Validate combined yaml information
frelist_dir = Path(__file__).resolve().parents[2]
schema_path = f"{frelist_dir}/fre/gfdl_msd_schemas/FRE/fre_pp.json"
# from fre.yamltools
helpers.validate_yaml(yml_dict, schema_path)

comp_info = yml_dict["postprocess"]["components"]
# log the experiment names, which should show up on screen for sure
fre_logger.info("Components to be post-processed:")
for i in yml_dict["postprocess"]["components"]:
if "postprocess_on" in i:
if i.get("postprocess_on") is True:
fre_logger.info(' - %s', i.get("type"))
for i in comp_info.keys():
if "postprocess_on" in comp_info[i]:
if comp_info[i].get("postprocess_on") is True:
fre_logger.info(' - %s', i)
else:
fre_logger.info(' - %s', i.get("type"))
fre_logger.info("\n")
fre_logger.info(' - %s', i)

# set logger back to normal level
fre_logger.setLevel(former_log_level)
28 changes: 18 additions & 10 deletions fre/list_/list_yamls_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"""
import logging
from pathlib import Path
import sys
import yaml
import click

fre_logger = logging.getLogger(__name__)

Expand All @@ -25,6 +27,8 @@ def list_yamls_subtool(yamlfile: str, experiment: str, application:str):
:type experiment: str
:param application: is the application name
:type application: str
:return: is a comma separated string of yaml files (absolute paths)
:rtype: str

:raise ValueError: if the experiment, application passed does not exist and
if yaml files do not exist
Expand All @@ -40,8 +44,8 @@ def list_yamls_subtool(yamlfile: str, experiment: str, application:str):
with open(yamlfile, 'r', encoding="utf-8") as yf:
yaml_dict = yaml.load(yf, Loader = yaml.Loader)

compile_data = yaml_dict["build"].get("compileYaml")
platform_data = yaml_dict["build"].get("platformYaml")
compile_data = yaml_dict["build"].get("compileYaml")
exp_data = yaml_dict["experiments"].get(experiment)

yamls = [model_yaml]
Expand All @@ -68,15 +72,15 @@ def list_yamls_subtool(yamlfile: str, experiment: str, application:str):
else:
yamls.append(exp_data[a])
else:
yamls.extend([compile_data, platform_data])
yamls.extend([platform_data, compile_data])
for value in exp_data.values():
if isinstance(value, list):
yamls.extend(value)
else:
yamls.append(value)
else:
fre_logger.info("No experiment name passed. Will only provide YAMLs related to compilation.")
yamls.extend([compile_data, platform_data])
yamls.extend([platform_data, compile_data])

yamls_full_path = ""
# Add full path for yaml configurations
Expand All @@ -94,13 +98,13 @@ def list_yamls_subtool(yamlfile: str, experiment: str, application:str):
fre_logger.info(" - %s", y)

### Might add this in when fre yamltools combine-yamls is refactored
# fre_logger.info("")
# fre_logger.info('If combining these yamls, there are 2 options:')
# fre_logger.info(' 1. Pipe this tool to "fre yamltools combine"')
# fre_logger.info(' 2. Copy and paste this string (including quotes)
# as the -y option in "fre yamltools combine -y <yamls>:')
# fre_logger.info(' "%s"', yamls_full_path)
# fre_logger.info("")
fre_logger.info("")
fre_logger.info('If combining these yamls, there are 2 options:')
fre_logger.info(' 1. Pipe this tool to "fre yamltools combine"')
fre_logger.info(' 2. Copy and paste this string (including quotes) '
'as the -y option in "fre yamltools combine -y <yamls>:')
fre_logger.info(' "%s"', yamls_full_path)
fre_logger.info("")
fre_logger.setLevel(former_log_level)

# Check if the paths exist; give warning
Expand All @@ -113,4 +117,8 @@ def list_yamls_subtool(yamlfile: str, experiment: str, application:str):
if "True" in fail:
raise ValueError(" *** PROVIDE THE MISSING YAML CONFIGURATIONS ***")

# if not piped to fre yamltools combine, no need to show all the yamls
if not sys.stdout.isatty():
click.echo(yamls_full_path)

return yamls_full_path
24 changes: 10 additions & 14 deletions fre/list_/tests/test_list_experiments_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,36 @@
from pathlib import Path

import pytest
import yaml

from fre.list_ import list_experiments_script
from fre.yamltools import helpers


# SET-UP
TEST_DIR = Path("fre/make/tests")
NM_EXAMPLE = Path("null_example")
YAMLFILE = "null_model.yaml"
TEST_DIR = Path("fre/list_/tests/yamls")
YAMLFILE = "model.yaml"
EXP_NAME = "None"

# yaml file checks
def test_modelyaml_exists():
''' Test that model yaml exists '''
assert Path(f"{TEST_DIR}/{NM_EXAMPLE}/{YAMLFILE}").exists()
assert Path(f"{TEST_DIR}/{YAMLFILE}").exists()

# Test whole tool
def test_exp_list(caplog):
''' Test fre list exps subtool '''
list_experiments_script.list_experiments_subtool(f"{TEST_DIR}/{NM_EXAMPLE}/{YAMLFILE}")
list_experiments_script.list_experiments_subtool(f"{TEST_DIR}/{YAMLFILE}")

# check the logging output
check_out = [ 'Experiments found:',
' - null_model_full',
' - null_model_0',
' - null_model_1',
' - null_model_2' ]
' - experiment1',
' - experiment2' ]
for i in check_out:
assert i in caplog.text

# make sure the level is INFO
for record in caplog.records:
assert record.levelname == "INFO"
if record.name.startswith("fre"):
assert record.levelname == "INFO"

# Test validation
@pytest.mark.skip(
Expand All @@ -48,10 +44,10 @@ def test_exp_list(caplog):
)
def test_yamlvalidate():
''' Test yaml is being validated '''
yamlfilepath = Path(f"{TEST_DIR}/{NM_EXAMPLE}/{YAMLFILE}")
yamlfilepath = Path(f"{TEST_DIR}/{YAMLFILE}")

# Combine model / experiment
yml_dict = list_experiments_script.list_experiments_subtool(f"{TEST_DIR}/{NM_EXAMPLE}/{YAMLFILE}")
yml_dict = list_experiments_script.list_experiments_subtool(f"{TEST_DIR}/{YAMLFILE}")

# Validate and capture output
assert helpers.validate_yaml(yml_dict, VAL_SCHEMA)
Loading
Loading