From cfeb6bce20bb621750adfe3270b24aabe6cde2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Fri, 12 Jan 2024 08:43:13 +0545 Subject: [PATCH 1/2] top-level plot collections: skip empty dict --- dvc/repo/plots/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index 62e559c8fe..6865786f79 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -486,7 +486,7 @@ def _collect_pipeline_files(repo, targets: List[str], props, onerror=None): for elem in plots_def: if isinstance(elem, str): dvcfile_defs_dict[elem] = None - else: + elif elem: k, v = next(iter(elem.items())) dvcfile_defs_dict[k] = v From 3a82fba534b2e3ab05cc44d67dcd04f8a6d6dc0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Fri, 12 Jan 2024 09:05:41 +0545 Subject: [PATCH 2/2] tighten schema for plots; require key name --- dvc/repo/plots/__init__.py | 3 ++- dvc/schema.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index 6865786f79..22b0898f98 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -486,7 +486,8 @@ def _collect_pipeline_files(repo, targets: List[str], props, onerror=None): for elem in plots_def: if isinstance(elem, str): dvcfile_defs_dict[elem] = None - elif elem: + 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 = {