Skip to content
6 changes: 3 additions & 3 deletions esmvaltool/recipes/examples/recipe_decadal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ diagnostics:
first_example:
additional_datasets:
- &dcpp {dataset: EC-Earth3, project: CMIP6, exp: dcppA-hindcast, ensemble: r1i1p1f1,
sub_experiment: 's(1980:2018)', timerange: '*'}
sub_experiment: 's(1980:2018)', timerange: '198011/201812'}
- &obs {dataset: ERA-Interim, project: OBS6, type: reanaly, version: 1, tier: 3,
timerange: '198011/201812'}
variables:
Expand All @@ -36,7 +36,7 @@ diagnostics:
second_example:
additional_datasets:
- {<<: *dcpp, sub_experiment: 's(1980:2007)'}
- {<<: *dcpp, sub_experiment: 's(2008:2018)', timerange: '*/201812'}
- {<<: *dcpp, sub_experiment: 's(2008:2018)', timerange: '198011/201812'}
- {<<: *obs}
variables:
tas:
Expand All @@ -48,7 +48,7 @@ diagnostics:
script: examples/decadal_example.py
third_example:
additional_datasets:
- {<<: *dcpp, timerange: '*/P1Y'}
- {<<: *dcpp, timerange: '1980/P1Y'}
- {<<: *obs, timerange: '1980/2018'}
variables:
tas:
Expand Down
52 changes: 3 additions & 49 deletions tests/integration/test_diagnostic_run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test diagnostic script runs."""

import contextlib
import os
import shutil
import sys
from pathlib import Path
Expand All @@ -14,6 +15,8 @@


def write_config_file(dirname):
if not os.path.exists(dirname):
os.makedirs(dirname)
config_file = dirname / "config-user.yml"
cfg = {
"output_dir": str(dirname / "output_dir"),
Expand Down Expand Up @@ -70,57 +73,8 @@ def check(result_file):
reason="ESMValTool R not supported on OSX",
),
),
]


@pytest.mark.skipif(
version.parse(esmvalcore.__version__) >= version.parse("2.14.0"),
reason="ESMValCore >= v2.14.0",
)
@pytest.mark.installation
@pytest.mark.parametrize("script_file", SCRIPTS)
def test_diagnostic_run_config_file(tmp_path, script_file):
local_script_file = Path(__file__).parent / script_file

recipe_file = tmp_path / "recipe_test.yml"
script_file = tmp_path / script_file
result_file = tmp_path / "result.yml"

shutil.copy(local_script_file, script_file)

# Create recipe
recipe = dedent(f"""
documentation:
title: Test recipe
description: Recipe with no data.
authors: [andela_bouwe]

diagnostics:
diagnostic_name:
scripts:
script_name:
script: {script_file}
setting_name: {result_file}
""")
recipe_file.write_text(str(recipe))

config_file = write_config_file(tmp_path)
with arguments(
"esmvaltool",
"run",
"--config_file",
config_file,
str(recipe_file),
):
run()

check(result_file)


@pytest.mark.skipif(
version.parse(esmvalcore.__version__) < version.parse("2.12.0"),
reason="ESMValCore < v2.12.0",
)
@pytest.mark.installation
@pytest.mark.parametrize("script_file", SCRIPTS)
def test_diagnostic_run(tmp_path, script_file):
Expand Down