From b46bd9ca654f5e2dbeeb31f4eb6acaf80a7fde0a Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:56:50 +0545 Subject: [PATCH] top-level plot collections: fail on empty dict (#10233) * top-level plot collections: skip empty dict * tighten schema for plots; require key name --- dvc/repo/plots/__init__.py | 1 + dvc/schema.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index 62e559c8fe..22b0898f98 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -487,6 +487,7 @@ def _collect_pipeline_files(repo, targets: List[str], props, onerror=None): if isinstance(elem, str): dvcfile_defs_dict[elem] = None else: + assert elem k, v = next(iter(elem.items())) dvcfile_defs_dict[k] = v diff --git a/dvc/schema.py b/dvc/schema.py index 073a28b96f..b2d70de2ec 100644 --- a/dvc/schema.py +++ b/dvc/schema.py @@ -112,7 +112,7 @@ def validator(data): Output.PARAM_PLOT_TITLE: str, Output.PARAM_PLOT_TEMPLATE: str, } -SINGLE_PLOT_SCHEMA = {str: vol.Any(PLOT_DEFINITION, None)} +SINGLE_PLOT_SCHEMA = {vol.Required(str): vol.Any(PLOT_DEFINITION, None)} ARTIFACTS = "artifacts" SINGLE_ARTIFACT_SCHEMA = vol.Schema({str: ARTIFACT_SCHEMA}) FOREACH_IN = {