Files
dvc/tests/func/experiments/test_diff.py
T
Peter Rowlands (변기호) 176a23e291 experiments: store experiments in refs/exps instead of heads (#4910)
* experiments: commit to refs/exps/... instead of branch heads

* update exp show

* restore checkpoint_resume kwarg

* refactor new() to use experiments stash

* experiments: use refspecs to populate and collect executors

* experiments: use new stash and merge on exp checkout

* experiments: fix executor chdir

* experiments: update run and show

* skip checkout after reproduce

* checkpoints: use experiments refspecs

* check if workspace was stashed before applying

* exp show: unify checkpoint/standalone experiment collection

* git: move iter_refs to backend

* update for scm changes

* experiments: replace exp checkout in favor of exp apply

* git: handle rev_parse errors in resolve_commit

* update refs containing and baseline check

* fix sigint handling for checkpoints

* update checkpoint exists behavior

* fix checkpoint baseline behavior

* update tests

* experiments: update gc

* update show tests

* fix type checking errors

* update diff

* scm: add diff, describe

* experiments: generate human readable names

* exp run/resume: allow user specified exp name with -n/--name

* update tests

* experiments: add `exp branch` for promoting experiment to full branch

* fix test

* fix missing file

* experiments: explicitly close scm instances before cleaning up tmp dir
2020-12-02 21:20:57 +09:00

31 lines
1022 B
Python

from funcy import first
def test_diff_empty(tmp_dir, scm, dvc, exp_stage):
assert dvc.experiments.diff() == {
"params": {},
"metrics": {},
}
def test_diff_head(tmp_dir, scm, dvc, exp_stage):
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
exp = first(results)
assert dvc.experiments.diff(a_rev="HEAD", b_rev=exp) == {
"params": {"params.yaml": {"foo": {"diff": 1, "old": 1, "new": 2}}},
"metrics": {"metrics.yaml": {"foo": {"diff": 1, "old": 1, "new": 2}}},
}
def test_diff_exp(tmp_dir, scm, dvc, exp_stage):
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
exp_a = first(results)
results = dvc.experiments.run(exp_stage.addressing, params=["foo=3"])
exp_b = first(results)
assert dvc.experiments.diff(a_rev=exp_a, b_rev=exp_b) == {
"params": {"params.yaml": {"foo": {"diff": 1, "old": 2, "new": 3}}},
"metrics": {"metrics.yaml": {"foo": {"diff": 1, "old": 2, "new": 3}}},
}