exp queue: remove queued experiments(#7591)

fix: #7591
1. Add a new command `dvc queue`
2. Add two sub-command `dvc queue remove` and `dvc queue kill`
3. Add a unit test to test them

Co-authored-by: Peter Rowlands (변기호) <[email protected]>
This commit is contained in:
karajan1001
2022-07-12 21:39:49 +09:00
committed by Peter Rowlands (변기호)
co-authored by Peter Rowlands
parent 4df5a1321d
commit a6cb4eb72e
5 changed files with 176 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
from dvc.cli import parse_args
from dvc.commands.queue.kill import CmdQueueKill
from dvc.commands.queue.remove import CmdQueueRemove
def test_experiments_remove(dvc, scm, mocker):
cli_args = parse_args(
[
"queue",
"remove",
"--all",
]
)
assert cli_args.func == CmdQueueRemove
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.local.LocalCeleryQueue.clear",
return_value={},
)
assert cmd.run() == 0
m.assert_called_once_with()
cli_args = parse_args(
[
"queue",
"remove",
"exp1",
"exp2",
]
)
assert cli_args.func == CmdQueueRemove
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.local.LocalCeleryQueue.remove",
return_value={},
)
assert cmd.run() == 0
m.assert_called_once_with(revs=["exp1", "exp2"])
def test_experiments_kill(dvc, scm, mocker):
cli_args = parse_args(
[
"queue",
"kill",
"exp1",
"exp2",
]
)
assert cli_args.func == CmdQueueKill
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.local.LocalCeleryQueue.kill",
return_value={},
)
assert cmd.run() == 0
m.assert_called_once_with(revs=["exp1", "exp2"])