Skip to content

Commit 0e38525

Browse files
authored
cli: remove dvc run (#9508)
Note that `Repo.run()` API still exists, which will be removed in successive PRs. A lot of tests depend on it that it'll take time before removing it.
1 parent 8acd943 commit 0e38525

File tree

9 files changed

+116
-721
lines changed

9 files changed

+116
-721
lines changed

dvc/cli/parser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
remove,
4242
repro,
4343
root,
44-
run,
4544
stage,
4645
unprotect,
4746
update,
@@ -62,7 +61,6 @@
6261
remove,
6362
move,
6463
unprotect,
65-
run,
6664
repro,
6765
data_sync,
6866
gc,

dvc/commands/run.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

tests/func/test_add.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,6 @@ def test_should_update_state_entry_for_file_after_add(mocker, dvc, tmp_dir):
362362
assert ret == 0
363363
assert file_md5_counter.mock.call_count == 1
364364

365-
ret = main(["run", "--single-stage", "-d", "foo", "echo foo"])
366-
assert ret == 0
367-
assert file_md5_counter.mock.call_count == 1
368-
369365
os.rename("foo", "foo.back")
370366
ret = main(["checkout"])
371367
assert ret == 0
@@ -392,19 +388,14 @@ def test_should_update_state_entry_for_directory_after_add(mocker, dvc, tmp_dir)
392388
assert ret == 0
393389
assert file_md5_counter.mock.call_count == 5
394390

395-
ls = "dir" if os.name == "nt" else "ls"
396-
ret = main(["run", "--single-stage", "-d", "data", "{} {}".format(ls, "data")])
397-
assert ret == 0
398-
assert file_md5_counter.mock.call_count == 7
399-
400391
os.rename("data", "data.back")
401392
ret = main(["checkout"])
402393
assert ret == 0
403-
assert file_md5_counter.mock.call_count == 7
394+
assert file_md5_counter.mock.call_count == 5
404395

405396
ret = main(["status"])
406397
assert ret == 0
407-
assert file_md5_counter.mock.call_count == 9
398+
assert file_md5_counter.mock.call_count == 6
408399

409400

410401
def test_add_commit(tmp_dir, dvc):

tests/func/test_cli.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from dvc.commands.init import CmdInit
1212
from dvc.commands.remove import CmdRemove
1313
from dvc.commands.repro import CmdRepro
14-
from dvc.commands.run import CmdRun
1514
from dvc.commands.status import CmdDataStatus
1615
from dvc.exceptions import NotDvcRepoError
1716

@@ -21,54 +20,6 @@ def test_argparse(dvc):
2120
assert isinstance(args.func(args), CmdInit)
2221

2322

24-
def test_run(dvc):
25-
dep1 = "dep1"
26-
dep2 = "dep2"
27-
28-
out1 = "out1"
29-
out2 = "out2"
30-
31-
out_no_cache1 = "out_no_cache1"
32-
out_no_cache2 = "out_no_cache2"
33-
34-
fname = "dvc.dvc"
35-
cmd = "cmd"
36-
arg1 = "arg1"
37-
arg2 = "arg2"
38-
39-
args = parse_args(
40-
[
41-
"run",
42-
"-d",
43-
dep1,
44-
"--deps",
45-
dep2,
46-
"-o",
47-
out1,
48-
"--outs",
49-
out2,
50-
"-O",
51-
out_no_cache1,
52-
"--outs-no-cache",
53-
out_no_cache2,
54-
"--file",
55-
fname,
56-
cmd,
57-
arg1,
58-
arg2,
59-
]
60-
)
61-
cmd_cls = args.func(args)
62-
assert isinstance(cmd_cls, CmdRun)
63-
assert args.deps == [dep1, dep2]
64-
assert args.outs == [out1, out2]
65-
assert args.outs_no_cache == [out_no_cache1, out_no_cache2]
66-
assert args.file == fname
67-
assert args.command == [cmd, arg1, arg2]
68-
69-
cmd_cls.repo.close()
70-
71-
7223
def test_pull(dvc):
7324
args = parse_args(["pull"])
7425
cmd = args.func(args)

tests/func/test_data_cloud.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ def test_hash_recalculation(mocker, dvc, tmp_dir, local_remote):
147147
assert ret == 0
148148
ret = main(["push"])
149149
assert ret == 0
150-
ret = main(["run", "--single-stage", "-d", "foo", "echo foo"])
151-
assert ret == 0
152150
assert test_file_md5.mock.call_count == 1
153151

154152

tests/func/test_repro.py

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,10 @@ def test_repro_dry_no_exec(tmp_dir, dvc):
335335

336336
ret = main(
337337
[
338-
"run",
339-
"--no-exec",
340-
"--single-stage",
338+
"stage",
339+
"add",
340+
"-n",
341+
f"copy-{idir}-{odir}",
341342
"-d",
342343
idir,
343344
"-o",
@@ -351,18 +352,17 @@ def test_repro_dry_no_exec(tmp_dir, dvc):
351352

352353
ret = main(
353354
[
354-
"run",
355-
"--no-exec",
356-
"--single-stage",
357-
"--file",
358-
DVC_FILE,
355+
"stage",
356+
"add",
357+
"-n",
358+
"ls",
359359
*deps,
360360
"ls {}".format(" ".join(dep for i, dep in enumerate(deps) if i % 2)),
361361
]
362362
)
363363
assert ret == 0
364364

365-
ret = main(["repro", "--dry", DVC_FILE])
365+
ret = main(["repro", "--dry", "ls"])
366366
assert ret == 0
367367

368368

@@ -1114,14 +1114,27 @@ def test_downstream(dvc):
11141114
# \ /
11151115
# A
11161116
#
1117-
assert main(["run", "--single-stage", "-o", "A", "echo A>A"]) == 0
1118-
assert main(["run", "--single-stage", "-d", "A", "-o", "B", "echo B>B"]) == 0
1119-
assert main(["run", "--single-stage", "-d", "A", "-o", "C", "echo C>C"]) == 0
1117+
assert main(["stage", "add", "-n", "stage-A", "--run", "-o", "A", "echo A>A"]) == 0
1118+
assert (
1119+
main(
1120+
["stage", "add", "-n", "stage-B", "--run", "-d", "A", "-o", "B", "echo B>B"]
1121+
)
1122+
== 0
1123+
)
1124+
assert (
1125+
main(
1126+
["stage", "add", "-n", "stage-C", "--run", "-d", "A", "-o", "C", "echo C>C"]
1127+
)
1128+
== 0
1129+
)
11201130
assert (
11211131
main(
11221132
[
1123-
"run",
1124-
"--single-stage",
1133+
"stage",
1134+
"add",
1135+
"-n",
1136+
"stage-D",
1137+
"--run",
11251138
"-d",
11261139
"B",
11271140
"-d",
@@ -1133,13 +1146,21 @@ def test_downstream(dvc):
11331146
)
11341147
== 0
11351148
)
1136-
assert main(["run", "--single-stage", "-o", "G", "echo G>G"]) == 0
1137-
assert main(["run", "--single-stage", "-d", "G", "-o", "F", "echo F>F"]) == 0
1149+
assert main(["stage", "add", "-n", "stage-G", "--run", "-o", "G", "echo G>G"]) == 0
1150+
assert (
1151+
main(
1152+
["stage", "add", "-n", "stage-F", "--run", "-d", "G", "-o", "F", "echo F>F"]
1153+
)
1154+
== 0
1155+
)
11381156
assert (
11391157
main(
11401158
[
1141-
"run",
1142-
"--single-stage",
1159+
"stage",
1160+
"add",
1161+
"-n",
1162+
"stage-E",
1163+
"--run",
11431164
"-d",
11441165
"D",
11451166
"-d",
@@ -1160,22 +1181,25 @@ def test_downstream(dvc):
11601181
# /
11611182
# B
11621183
#
1163-
evaluation = dvc.reproduce("B.dvc", downstream=True, force=True)
1184+
evaluation = dvc.reproduce("stage-B", downstream=True, force=True)
11641185

11651186
assert len(evaluation) == 3
1166-
assert evaluation[0].relpath == "B.dvc"
1167-
assert evaluation[1].relpath == "D.dvc"
1168-
assert evaluation[2].relpath == "E.dvc"
1187+
assert evaluation[0].addressing == "stage-B"
1188+
assert evaluation[1].addressing == "stage-D"
1189+
assert evaluation[2].addressing == "stage-E"
11691190

11701191
# B, C should be run (in any order) before D
11711192
# See https://github.com/iterative/dvc/issues/3602
1172-
evaluation = dvc.reproduce("A.dvc", downstream=True, force=True)
1193+
evaluation = dvc.reproduce("stage-A", downstream=True, force=True)
11731194

11741195
assert len(evaluation) == 5
1175-
assert evaluation[0].relpath == "A.dvc"
1176-
assert {evaluation[1].relpath, evaluation[2].relpath} == {"B.dvc", "C.dvc"}
1177-
assert evaluation[3].relpath == "D.dvc"
1178-
assert evaluation[4].relpath == "E.dvc"
1196+
assert evaluation[0].addressing == "stage-A"
1197+
assert {evaluation[1].addressing, evaluation[2].addressing} == {
1198+
"stage-B",
1199+
"stage-C",
1200+
}
1201+
assert evaluation[3].addressing == "stage-D"
1202+
assert evaluation[4].addressing == "stage-E"
11791203

11801204

11811205
def test_repro_when_cmd_changes(tmp_dir, dvc, run_copy, mocker):

0 commit comments

Comments
 (0)