Skip to content

Commit 2cb0787

Browse files
authored
Avoid too wide supplementary file search (#2771)
1 parent 23885b9 commit 2cb0787

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
- repo: https://github.com/astral-sh/ruff-pre-commit
3636
rev: "v0.12.2"
3737
hooks:
38-
- id: ruff
38+
- id: ruff-check
3939
args: [--fix]
4040
- id: ruff-format
4141
- repo: https://github.com/pre-commit/mirrors-mypy

esmvalcore/_recipe/to_datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import TYPE_CHECKING, Any
1010

1111
from esmvalcore.cmor.table import _CMOR_KEYS, _update_cmor_facets
12-
from esmvalcore.dataset import Dataset, _isglob
12+
from esmvalcore.dataset import INHERITED_FACETS, Dataset, _isglob
1313
from esmvalcore.esgf.facets import FACETS
1414
from esmvalcore.exceptions import RecipeError
1515
from esmvalcore.local import LocalFile, _replace_years_with_timerange
@@ -249,7 +249,7 @@ def _append_missing_supplementaries(
249249
supplementary_facets: Facets = {
250250
facet: "*"
251251
for facet in FACETS.get(project, ["mip"])
252-
if facet not in _CMOR_KEYS
252+
if facet not in _CMOR_KEYS + tuple(INHERITED_FACETS)
253253
}
254254
if "version" in facets:
255255
supplementary_facets["version"] = "*"

tests/unit/recipe/test_to_datasets.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def test_merge_supplementaries_combine_dataset_with_variable(session):
253253
assert len(datasets) == 1
254254
assert len(datasets[0].supplementaries) == 2
255255
assert datasets[0].supplementaries[0].facets["short_name"] == "areacella"
256+
assert datasets[0].supplementaries[0].facets["dataset"] == "AWI-ESM-1-1-LR"
256257
assert datasets[0].supplementaries[1].facets["short_name"] == "sftlf"
257258

258259

@@ -404,9 +405,12 @@ def test_append_missing_supplementaries():
404405
facets,
405406
settings,
406407
)
407-
408408
short_names = {f["short_name"] for f in supplementaries}
409409
assert short_names == {"areacella", "sftlf"}
410+
sftlf = supplementaries[1]
411+
assert (
412+
"dataset" not in sftlf
413+
) # dataset will be inherited from the main variable
410414

411415

412416
def test_report_unexpanded_globs(mocker):

0 commit comments

Comments
 (0)