Skip to content

Commit 8999a2d

Browse files
Merge branch 'main' into oras5
2 parents c33838b + b03c23d commit 8999a2d

9 files changed

Lines changed: 65 additions & 6 deletions

File tree

.github/workflows/build-and-deploy-on-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2222
with:
2323
fetch-depth: 0
2424
persist-credentials: false

.github/workflows/citation_file_validator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
if: github.repository == 'ESMValGroup/ESMValCore' # avoid GAs in forks
2020
steps:
2121
- name: Check out a copy of the repository
22-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2323
with:
2424
persist-credentials: false
2525
- name: Check whether the citation metadata from CITATION.cff is valid

.github/workflows/run-tests-monitor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- test-py314
3232
name: ${{ matrix.os }} ${{ matrix.environment }}
3333
steps:
34-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3535
with:
3636
fetch-depth: 0
3737
persist-credentials: false

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- test-r
3333
name: ${{ matrix.os }} ${{ matrix.environment }}
3434
steps:
35-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3636
with:
3737
fetch-depth: 0
3838
persist-credentials: false

.github/workflows/update-lockfiles.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
pixi-update:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
1818
with:
1919
fetch-depth: 0
2020
persist-credentials: false

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@
224224
"affiliation": "SMHI, Sweden",
225225
"name": "Lenhardt, Julien",
226226
"orcid": "https://orcid.org/0000-0002-9949-3989"
227+
},
228+
{
229+
"affiliation": "Climate Resource, Australia",
230+
"name": "Lewis, Jared",
231+
"orcid": "https://orcid.org/0000-0002-8155-8924"
227232
}
228233
],
229234
"description": "ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.",

CITATION.cff

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ authors:
228228
family-names: Lenhardt
229229
given-names: Julien
230230
orcid: "https://orcid.org/0000-0002-9949-3989"
231+
-
232+
affiliation: "Climate Resource, Australia"
233+
family-names: Lewis
234+
given-names: Jared
235+
orcid: "https://orcid.org/0000-0002-8155-8924"
231236

232237
cff-version: 1.2.0
233238
date-released: 2026-03-10

esmvalcore/_main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def version(self):
607607
for project, version in self._extra_packages.items():
608608
print(f"{project}: {version}") # noqa: T201
609609

610-
def run(self, recipe, **kwargs):
610+
def run(self, recipe, session_name=None, **kwargs):
611611
"""Execute an ESMValTool recipe.
612612
613613
`esmvaltool run` executes the given recipe. To see a list of available
@@ -617,6 +617,15 @@ def run(self, recipe, **kwargs):
617617
A list of possible flags is given here:
618618
https://docs.esmvaltool.org/projects/ESMValCore/en/latest/quickstart/configure.html#configuration-options
619619
620+
Parameters
621+
----------
622+
recipe:
623+
Path to the recipe to run.
624+
session_name:
625+
Name of the session output subdirectory (relative to the configured ``output_dir``).
626+
When given, this value is used instead of the default ``<recipe.stem>_<timestamp>``.
627+
628+
If the given name already exists, a suffix is added to the session name to avoid overwriting existing data.
620629
"""
621630
from .config import CFG
622631
from .exceptions import InvalidConfigParameter
@@ -651,6 +660,8 @@ def run(self, recipe, **kwargs):
651660

652661
CFG["resume_from"] = parse_resume(CFG["resume_from"], recipe)
653662
session = CFG.start_session(recipe.stem)
663+
if session_name is not None:
664+
session.session_name = str(session_name)
654665

655666
self._run(recipe, session, cli_config_dir)
656667

tests/unit/main/test_esmvaltool.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,44 @@ def test_run_command_line_config(mocker, cfg, argument, value, tmp_path):
9696
assert session[argument] == value
9797

9898

99+
def test_run_session_name(mocker, cfg, tmp_path):
100+
"""Check that `session_name` overrides the auto-generated name."""
101+
mocker.patch.object(esmvalcore.config, "CFG", cfg)
102+
session = cfg.start_session.return_value
103+
104+
program = ESMValTool()
105+
recipe_file = "/path/to/recipe_test.yml"
106+
config_dir = tmp_path / "config"
107+
config_dir.mkdir(parents=True, exist_ok=True)
108+
109+
mocker.patch.object(program, "_get_recipe", return_value=Path(recipe_file))
110+
mocker.patch.object(program, "_run")
111+
112+
program.run(recipe_file, session_name="result", config_dir=config_dir)
113+
114+
assert session.session_name == "result"
115+
# Check that the session name is not passed to the cfg
116+
for call in cfg.nested_update.call_args_list:
117+
assert "session_name" not in call.args[0]
118+
119+
120+
def test_run_no_session_name(mocker, cfg, tmp_path):
121+
"""Check that the session name is left untouched by default."""
122+
mocker.patch.object(esmvalcore.config, "CFG", cfg)
123+
124+
program = ESMValTool()
125+
recipe_file = "/path/to/recipe_test.yml"
126+
config_dir = tmp_path / "config"
127+
config_dir.mkdir(parents=True, exist_ok=True)
128+
129+
mocker.patch.object(program, "_get_recipe", return_value=Path(recipe_file))
130+
mocker.patch.object(program, "_run")
131+
132+
program.run(recipe_file, config_dir=config_dir)
133+
134+
assert "session_name" not in cfg.start_session.return_value.__dict__
135+
136+
99137
@pytest.mark.parametrize("search_data", ["quick", "complete"])
100138
def test_run(mocker, session, search_data):
101139
session["search_data"] = search_data

0 commit comments

Comments
 (0)