plots: fix handling of multiple plots from single revision (#4031)

This commit is contained in:
Paweł Redzyński
2020-06-12 16:08:08 +03:00
committed by GitHub
parent b94a18cfb9
commit 584c97a58d
2 changed files with 24 additions and 1 deletions
+3 -1
View File
@@ -43,7 +43,9 @@ class Plots:
plots = _collect_plots(self.repo, targets, rev)
for path_info, props in plots.items():
datafile = relpath(path_info, self.repo.root_dir)
data[rev] = {datafile: {"props": props}}
if rev not in data:
data[rev] = {}
data[rev].update({datafile: {"props": props}})
# Load data from git or dvc cache
try:
+21
View File
@@ -585,3 +585,24 @@ def test_plots_modify_not_existing_template(dvc):
dvc.plots.modify(
"metric.json", props={"template": "not-existing-template.json"}
)
def test_multiple_plots(tmp_dir, scm, dvc, run_copy_metrics):
metric1 = [
OrderedDict([("first_val", 100), ("second_val", 100), ("val", 2)]),
OrderedDict([("first_val", 200), ("second_val", 300), ("val", 3)]),
]
metric2 = [
OrderedDict([("first_val", 100), ("second_val", 100), ("val", 2)]),
OrderedDict([("first_val", 200), ("second_val", 300), ("val", 3)]),
]
_write_csv(metric1, "metric_t1.csv")
_write_json(tmp_dir, metric2, "metric_t2.json")
run_copy_metrics(
"metric_t1.csv", "metric1.csv", plots_no_cache=["metric1.csv"]
)
run_copy_metrics(
"metric_t2.json", "metric2.json", plots_no_cache=["metric2.json"]
)
assert len(dvc.plots.show().keys()) == 2