Files
dvc/tests/func/experiments/test_diff.py
T
98bcfad8e7 build(deps-dev): bump scmrepo from 0.1.6 to 0.1.7 (#8821)
* build(deps-dev): bump scmrepo from 0.1.6 to 0.1.7

Bumps [scmrepo](https://github.com/iterative/scmrepo) from 0.1.6 to 0.1.7.
- [Release notes](https://github.com/iterative/scmrepo/releases)
- [Commits](https://github.com/iterative/scmrepo/compare/0.1.6...0.1.7)

---
updated-dependencies:
- dependency-name: scmrepo
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* mypy: remove scmrepo from ignored modules

* Fix mypy issues

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: skshetry <[email protected]>
Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
2023-01-28 14:26:00 +05:45

38 lines
1.2 KiB
Python

from funcy import first
def test_diff_no_commits(tmp_dir):
from dvc.repo import Repo
from dvc.scm import Git
git = Git.init(tmp_dir.fs_path)
assert git.no_commits
assert Repo.init().experiments.diff() == {}
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}}},
}