mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
exp remove: rename --all-commits flag and unify the collection of revs (#7155)
fix: #7155 1. rename flags `-A/--all-commits` in `exp remove` 2. add new flag `-n/--num` in `exp remove` 3. unify the revision collection in `exp remove` 4. add unit and func tests for `exp remove` Co-authored-by: Jorge Orpinel <[email protected]>
This commit is contained in:
committed by
Gao
co-authored by
Jorge Orpinel
parent
244637e299
commit
efc021da73
@@ -338,18 +338,22 @@ def test_experiments_pull(dvc, scm, mocker):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"queue,clear_all,remote",
|
||||
[(True, False, None), (False, True, None), (False, False, True)],
|
||||
)
|
||||
def test_experiments_remove(dvc, scm, mocker, queue, clear_all, remote):
|
||||
if queue:
|
||||
args = ["--queue"]
|
||||
if clear_all:
|
||||
args = ["--all"]
|
||||
if remote:
|
||||
args = ["--git-remote", "myremote", "exp-123", "exp-234"]
|
||||
cli_args = parse_args(["experiments", "remove"] + args)
|
||||
def test_experiments_remove(dvc, scm, mocker, capsys, caplog):
|
||||
cli_args = parse_args(
|
||||
[
|
||||
"experiments",
|
||||
"remove",
|
||||
"--all-commits",
|
||||
"--rev",
|
||||
"foo",
|
||||
"--num",
|
||||
"2",
|
||||
"--git-remote",
|
||||
"myremote",
|
||||
"exp-123",
|
||||
"exp-234",
|
||||
]
|
||||
)
|
||||
assert cli_args.func == CmdExperimentsRemove
|
||||
|
||||
cmd = cli_args.func(cli_args)
|
||||
@@ -358,10 +362,20 @@ def test_experiments_remove(dvc, scm, mocker, queue, clear_all, remote):
|
||||
assert cmd.run() == 0
|
||||
m.assert_called_once_with(
|
||||
cmd.repo,
|
||||
exp_names=["exp-123", "exp-234"] if remote else [],
|
||||
queue=queue,
|
||||
clear_all=clear_all,
|
||||
remote="myremote" if remote else None,
|
||||
exp_names=["exp-123", "exp-234"],
|
||||
all_commits=True,
|
||||
rev="foo",
|
||||
num=2,
|
||||
queue=False,
|
||||
git_remote="myremote",
|
||||
)
|
||||
|
||||
cmd = cli_args.func(parse_args(["exp", "remove"]))
|
||||
with pytest.raises(InvalidArgumentError) as excinfo:
|
||||
cmd.run()
|
||||
assert (
|
||||
str(excinfo.value) == "Either provide an `experiment` argument"
|
||||
", or use the `--rev` or `--all-commits` flag."
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user