exp: remove unused ApplyConflictError

This commit is contained in:
Peter Rowlands
2023-02-20 14:36:38 +09:00
committed by Peter Rowlands (변기호)
parent e218431f64
commit 0c95cde712
2 changed files with 2 additions and 35 deletions
+2 -23
View File
@@ -110,15 +110,13 @@ def test_failed_exp_workspace(
def test_apply(tmp_dir, scm, dvc, exp_stage):
from dvc.exceptions import InvalidArgumentError
from dvc.repo.experiments.exceptions import ApplyConflictError
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"], tmp_dir=True)
exp_a = first(results)
results = dvc.experiments.run(
dvc.experiments.run(
exp_stage.addressing, params=["foo=3"], tmp_dir=True, name="foo"
)
exp_b = first(results)
with pytest.raises(InvalidArgumentError):
dvc.experiments.apply("bar")
@@ -127,12 +125,6 @@ def test_apply(tmp_dir, scm, dvc, exp_stage):
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2"
assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 2"
with pytest.raises(ApplyConflictError):
dvc.experiments.apply(exp_b, force=False)
# failed apply should revert everything to prior state
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2"
assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 2"
dvc.experiments.apply("foo")
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 3"
@@ -168,8 +160,6 @@ def test_apply_failed(tmp_dir, scm, dvc, failed_exp_stage, test_queue):
def test_apply_queued(tmp_dir, scm, dvc, exp_stage):
from dvc.repo.experiments.exceptions import ApplyConflictError
metrics_original = (tmp_dir / "metrics.yaml").read_text().strip()
dvc.experiments.run(
exp_stage.addressing, params=["foo=2"], name="exp-a", queue=True
@@ -186,29 +176,18 @@ def test_apply_queued(tmp_dir, scm, dvc, exp_stage):
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2"
assert (tmp_dir / "metrics.yaml").read_text().strip() == metrics_original
with pytest.raises(ApplyConflictError):
dvc.experiments.apply(queue_revs["exp-b"], force=False)
dvc.experiments.apply(queue_revs["exp-b"])
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
assert (tmp_dir / "metrics.yaml").read_text().strip() == metrics_original
def test_apply_untracked(tmp_dir, scm, dvc, exp_stage):
from dvc.repo.experiments.exceptions import ApplyConflictError
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
exp = first(results)
tmp_dir.gen("untracked", "untracked")
tmp_dir.gen("params.yaml", "conflict")
with pytest.raises(ApplyConflictError):
dvc.experiments.apply(exp, force=False)
assert (tmp_dir / "untracked").read_text() == "untracked"
assert (tmp_dir / "params.yaml").read_text() == "conflict"
dvc.experiments.apply(exp, force=True)
dvc.experiments.apply(exp)
assert (tmp_dir / "untracked").read_text() == "untracked"
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2"