experiments: only show queued experiments for the current commit (#4462)

This commit is contained in:
Peter Rowlands (변기호)
2020-08-25 14:33:46 +03:00
committed by GitHub
parent 01a6580b3d
commit 714503a9e8
2 changed files with 48 additions and 5 deletions
+6 -5
View File
@@ -73,10 +73,11 @@ def show(
# collect queued (not yet reproduced) experiments
for stash_rev, (_, baseline_rev) in repo.experiments.stash_revs.items():
with repo.experiments.chdir():
experiment = _collect_experiment(
repo.experiments.exp_dvc, stash_rev, stash=True
)
res[baseline_rev][stash_rev] = experiment
if baseline_rev in revs:
with repo.experiments.chdir():
experiment = _collect_experiment(
repo.experiments.exp_dvc, stash_rev, stash=True
)
res[baseline_rev][stash_rev] = experiment
return res
+42
View File
@@ -60,3 +60,45 @@ def test_show_experiment(tmp_dir, scm, dvc):
else:
assert exp["metrics"]["metrics.yaml"] == expected_params
assert exp["params"]["params.yaml"] == expected_params
def test_show_queued(tmp_dir, scm, dvc):
tmp_dir.gen("copy.py", COPY_SCRIPT)
tmp_dir.gen("params.yaml", "foo: 1")
stage = dvc.run(
cmd="python copy.py params.yaml metrics.yaml",
metrics_no_cache=["metrics.yaml"],
params=["foo"],
name="foo",
)
scm.add(["copy.py", "params.yaml", "metrics.yaml", "dvc.yaml", "dvc.lock"])
scm.commit("baseline")
baseline_rev = scm.get_rev()
dvc.reproduce(
stage.addressing, experiment=True, params=["foo=2"], queue=True
)
exp_rev = dvc.experiments.scm.resolve_rev("stash@{0}")
results = dvc.experiments.show()[baseline_rev]
assert len(results) == 2
exp = results[exp_rev]
assert exp["queued"]
assert exp["params"]["params.yaml"] == {"foo": 2}
# test that only queued experiments for the current baseline are returned
tmp_dir.gen("foo", "foo")
scm.add(["foo"])
scm.commit("new commit")
new_rev = scm.get_rev()
dvc.reproduce(
stage.addressing, experiment=True, params=["foo=3"], queue=True
)
exp_rev = dvc.experiments.scm.resolve_rev("stash@{0}")
results = dvc.experiments.show()[new_rev]
assert len(results) == 2
exp = results[exp_rev]
assert exp["queued"]
assert exp["params"]["params.yaml"] == {"foo": 3}