mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
exp: remove unused ApplyConflictError
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
e218431f64
commit
0c95cde712
@@ -66,18 +66,6 @@ class MultipleBranchError(DvcException):
|
||||
self.ref_infos = ref_infos
|
||||
|
||||
|
||||
class ApplyConflictError(InvalidArgumentError):
|
||||
def __init__(self, name):
|
||||
super().__init__(
|
||||
f"Experiment '{name}' cannot be applied to because your current "
|
||||
"workspace contains changes which would be overwritten. Either "
|
||||
"'git stash' your current changes before applying this "
|
||||
"experiment, or re-run this command with '--force' to overwrite "
|
||||
"your current changes."
|
||||
)
|
||||
self.name = name
|
||||
|
||||
|
||||
class AmbiguousExpRefInfo(InvalidArgumentError):
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user