Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify configure task in recipe test workflow #3394

Merged
merged 7 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import pprint

import yaml
from esmvalcore.config._config_object import Config

import esmvaltool


def main():
Expand All @@ -17,16 +14,11 @@ def main():
environment for the ``configure`` task and the result is written to
the file defined by ``USER_CONFIG_PATH`` in the ``flow.cylc`` file.
ehogan marked this conversation as resolved.
Show resolved Hide resolved
"""
# Get the default configuration values from the latest version of
# ESMValTool.
config_values = get_latest_default_conf_vals()

# Get the configuration values defined in the environment for the
# 'configure' task.
config_values_from_task_env = get_config_values_from_task_env()
config_values = get_config_values_from_task_env()

# Update the default configuration values.
config_values.update(config_values_from_task_env)
# Update the configuration from OS environment.
user_config_path = os.environ["USER_CONFIG_PATH"]
config_values["config_file"] = user_config_path

Expand All @@ -38,30 +30,6 @@ def main():
write_yaml(user_config_path, config_values)


def get_latest_default_conf_vals():
"""Return the default configuration values from the latest version of
ESMValTool."""
latest_esmvaltool_dir = os.environ["ESMVALTOOL_DIR"]
default_config_file = os.path.join(latest_esmvaltool_dir,
"config-user-example.yml")
# A dictionary is needed here to avoid the config object from
# converting paths to 'PosixPath' objects, which causes issues when
# writing the YAML file.
config_values = dict(Config._load_user_config(default_config_file))

# Update the type of the value of 'config_developer_file' from a
# 'PosixPath' object to a string, to avoid issues when writing the
# YAML file (all other paths will be overwritten).
config_developer_file = str(config_values["config_developer_file"])
config_values["config_developer_file"] = config_developer_file

print("Default configuration values from the latest version of ESMValTool "
f"{esmvaltool.__version__} (from '{default_config_file}'): ")
pprint.PrettyPrinter().pprint(config_values)

return config_values


def get_config_values_from_task_env():
"""Return the configuration values defined in the environment for the
``configure`` task."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
initial cycle point = 1
final cycle point = 10
[[graph]]
R1 = """install_env_file => clone_latest_esmval => configure
R1 = """install_env_file => configure
install_env_file => clone_latest_esmval
alistairsellar marked this conversation as resolved.
Show resolved Hide resolved
configure => process<fast> => compare<fast>
configure => process<medium> => compare<medium>"""
configure => process<medium> => compare<medium>
clone_latest_esmval => process<fast>
clone_latest_esmval => process<medium>"""
ehogan marked this conversation as resolved.
Show resolved Hide resolved

[runtime]
[[root]]
Expand Down
Loading