Skip to content

Commit 88d29ed

Browse files
committed
run/repro: rename "build cache" -> "run cache"
Part of iterative#3777
1 parent 3916d4f commit 88d29ed

File tree

11 files changed

+45
-35
lines changed

11 files changed

+45
-35
lines changed

dvc/command/repro.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ def run(self):
3333
interactive=self.args.interactive,
3434
pipeline=self.args.pipeline,
3535
all_pipelines=self.args.all_pipelines,
36-
ignore_build_cache=self.args.ignore_build_cache,
36+
run_cache=not self.args.no_run_cache,
3737
no_commit=self.args.no_commit,
3838
downstream=self.args.downstream,
3939
recursive=self.args.recursive,
40+
force_downstream=self.args.force_downstream,
4041
)
4142

4243
if len(stages) == 0:
@@ -136,7 +137,16 @@ def add_parser(subparsers, parent_parser):
136137
help="Reproduce all stages in the specified directory.",
137138
)
138139
repro_parser.add_argument(
139-
"--ignore-build-cache",
140+
"--no-run-cache",
141+
action="store_true",
142+
default=False,
143+
help=(
144+
"Execute stage commands even if they have already been run with "
145+
"the same command/dependencies/outputs/etc before."
146+
),
147+
)
148+
repro_parser.add_argument(
149+
"--force-downstream",
140150
action="store_true",
141151
default=False,
142152
help="Reproduce all descendants of a changed stage even if their "

dvc/command/run.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run(self):
4242
wdir=self.args.wdir,
4343
no_exec=self.args.no_exec,
4444
overwrite=self.args.overwrite_dvcfile,
45-
ignore_build_cache=self.args.ignore_build_cache,
45+
run_cache=not self.args.no_run_cache,
4646
no_commit=self.args.no_commit,
4747
outs_persist=self.args.outs_persist,
4848
outs_persist_no_cache=self.args.outs_persist_no_cache,
@@ -165,11 +165,13 @@ def add_parser(subparsers, parent_parser):
165165
help="Overwrite existing DVC-file without asking for confirmation.",
166166
)
167167
run_parser.add_argument(
168-
"--ignore-build-cache",
168+
"--no-run-cache",
169169
action="store_true",
170170
default=False,
171-
help="Run this stage even if it has been already ran with the same "
172-
"command/dependencies/outputs/etc before.",
171+
help=(
172+
"Execute the command even if this stage has already been run "
173+
"with the same command/dependencies/outputs/etc before."
174+
),
173175
)
174176
run_parser.add_argument(
175177
"--no-commit",

dvc/repo/reproduce.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ def _reproduce_stages(
162162
if stage not in pipeline:
163163
pipeline.append(stage)
164164

165+
force_downstream = kwargs.pop("force_downstream", False)
165166
result = []
166167
for stage in pipeline:
167168
try:
168169
ret = _reproduce_stage(stage, **kwargs)
169170

170-
if len(ret) != 0 and kwargs.get("ignore_build_cache", False):
171+
if len(ret) != 0 and force_downstream:
171172
# NOTE: we are walking our pipeline from the top to the
172173
# bottom. If one stage is changed, it will be reproduced,
173174
# which tells us that we should force reproducing all of

dvc/repo/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def run(self, fname=None, no_exec=False, single_stage=False, **kwargs):
8585
else:
8686
stage.run(
8787
no_commit=kwargs.get("no_commit", False),
88-
ignore_build_cache=kwargs.get("ignore_build_cache", False),
88+
run_cache=kwargs.get("run_cache", True),
8989
)
9090

9191
dvcfile.dump(stage, update_pipeline=True)

dvc/stage/__init__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def create_stage(cls, repo, path, **kwargs):
7070

7171
if stage and stage.dvcfile.exists():
7272
has_persist_outs = any(out.persist for out in stage.outs)
73-
ignore_build_cache = (
74-
kwargs.get("ignore_build_cache", False) or has_persist_outs
73+
ignore_run_cache = (
74+
not kwargs.get("run_cache", True) or has_persist_outs
7575
)
7676
if has_persist_outs:
7777
logger.warning("Build cache is ignored when persisting outputs.")
7878

79-
if not ignore_build_cache and stage.can_be_skipped:
79+
if not ignore_run_cache and stage.can_be_skipped:
8080
logger.info("Stage is cached, skipping.")
8181
return None
8282

@@ -623,9 +623,7 @@ def _run(self):
623623
raise StageCmdFailedError(self, retcode)
624624

625625
@rwlocked(read=["deps"], write=["outs"])
626-
def run(
627-
self, dry=False, no_commit=False, force=False, ignore_build_cache=False
628-
):
626+
def run(self, dry=False, no_commit=False, force=False, run_cache=True):
629627
if (self.cmd or self.is_import) and not self.locked and not dry:
630628
self.remove_outs(ignore_remove=False, force=False)
631629

@@ -670,9 +668,7 @@ def run(
670668
if not stage_cached:
671669
self._save_deps()
672670
use_build_cache = (
673-
not force
674-
and not ignore_build_cache
675-
and stage_cache.is_cached(self)
671+
not force and run_cache and stage_cache.is_cached(self)
676672
)
677673

678674
if use_build_cache:

scripts/completion/dvc.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ _dvc_remote_modify='--global --system --local -u --unset'
6868
_dvc_remote_remove='--global --system --local'
6969
_dvc_remove='-o --outs -p --purge -f --force'
7070
_dvc_remove_COMPGEN=_dvc_compgen_DVCFiles
71-
_dvc_repro='-f --force -s --single-item -c --cwd -m --metrics --dry -i --interactive -p --pipeline -P --all-pipelines --ignore-build-cache --no-commit -R --recursive --downstream'
71+
_dvc_repro='-f --force -s --single-item -c --cwd -m --metrics --dry -i --interactive -p --pipeline -P --all-pipelines --no-run-cache --force-downstream --no-commit -R --recursive --downstream'
7272
_dvc_repro_COMPGEN=_dvc_compgen_DVCFiles
7373
_dvc_root=''
74-
_dvc_run='--no-exec -f --file -d --deps -o --outs -O --outs-no-cache --outs-persist --outs-persist-no-cache -m --metrics -M --metrics-no-cache --overwrite-dvcfile --ignore-build-cache --no-commit -w --wdir'
74+
_dvc_run='--no-exec -f --file -d --deps -o --outs -O --outs-no-cache --outs-persist --outs-persist-no-cache -m --metrics -M --metrics-no-cache --overwrite-dvcfile --no-run-cache --no-commit -w --wdir'
7575
_dvc_run_COMPGEN=_dvc_compgen_DVCFiles
7676
_dvc_status='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -c --cloud'
7777
_dvc_status_COMPGEN=_dvc_compgen_DVCFiles

scripts/completion/dvc.zsh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ _dvc_repro=(
239239
{-p,--pipeline}"[Reproduce the whole pipeline that the specified stage file belongs to.]"
240240
{-P,--all-pipelines}"[Reproduce all pipelines in the repo.]"
241241
{-R,--recursive}"[Reproduce all stages in the specified directory.]"
242-
"--ignore-build-cache[Reproduce all descendants of a changed stage even if their direct dependencies didn't change.]"
242+
"--force-downstream[Reproduce all descendants of a changed stage even if their direct dependencies didn't change.]"
243+
"--no-run-cache[Run changed stage even if it has been already ran with the same command/dependencies/outputs/etc before.]"
243244
"--no-commit[Don't put files/directories into cache.]"
244245
"--downstream[Start from the specified stages when reproducing pipelines.]"
245246
"*:Stages:_files -g '(*.dvc|Dvcfile)'"
@@ -259,7 +260,7 @@ _dvc_run=(
259260
"--no-exec[Only create stage file without actually running it.]"
260261
{-y,--yes}"[Deprecated, use --overwrite-dvcfile instead]"
261262
"--overwrite-dvcfile[Overwrite existing DVC-file without asking for confirmation.]"
262-
"--ignore-build-cache[Run this stage even if it has been already ran with the same command/dependencies/outputs/etc before.]"
263+
"--no-run-cache[Run this stage even if it has been already ran with the same command/dependencies/outputs/etc before.]"
263264
"--remove-outs[Deprecated, this is now the default behavior]"
264265
"--no-commit[Don't put files/directories into cache.]"
265266
"--outs-persist[Declare output file or directory that will not be removed upon repro.]:Output persistent:_files"

tests/func/test_repro.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def test(self):
437437
self.assertEqual(len(stages), 3)
438438

439439

440-
class TestReproIgnoreBuildCache(TestDvc):
440+
class TestReproForceDownstream(TestDvc):
441441
def test(self):
442442
stages = self.dvc.add(self.FOO)
443443
self.assertEqual(len(stages), 1)
@@ -480,7 +480,7 @@ def test(self):
480480
with open(code2, "a") as fobj:
481481
fobj.write("\n\n")
482482

483-
stages = self.dvc.reproduce(file3_stage.path, ignore_build_cache=True)
483+
stages = self.dvc.reproduce(file3_stage.path, force_downstream=True)
484484
self.assertEqual(len(stages), 2)
485485
self.assertEqual(stages[0].path, file2_stage.path)
486486
self.assertEqual(stages[1].path, file3_stage.path)

tests/func/test_run_single_stage.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def test(self):
343343
[
344344
"run",
345345
"--overwrite-dvcfile",
346-
"--ignore-build-cache",
346+
"--no-run-cache",
347347
"--single-stage",
348348
"-d",
349349
self.CODE,
@@ -401,7 +401,7 @@ def test(self):
401401
[
402402
"run",
403403
"--overwrite-dvcfile",
404-
"--ignore-build-cache",
404+
"--no-run-cache",
405405
"--single-stage",
406406
"-d",
407407
self.CODE,
@@ -460,7 +460,7 @@ def test(self):
460460
[
461461
"run",
462462
"--overwrite-dvcfile",
463-
"--ignore-build-cache",
463+
"--no-run-cache",
464464
"--single-stage",
465465
"-d",
466466
self.CODE,
@@ -545,7 +545,7 @@ def test(self):
545545
"-d",
546546
self.CODE,
547547
"--overwrite-dvcfile",
548-
"--ignore-build-cache",
548+
"--no-run-cache",
549549
"--single-stage",
550550
"-o",
551551
"out",
@@ -664,8 +664,7 @@ def test_rerun_deterministic_ignore_cache(tmp_dir, run_copy):
664664

665665
assert run_copy("foo", "out", single_stage=True) is not None
666666
assert (
667-
run_copy("foo", "out", ignore_build_cache=True, single_stage=True)
668-
is not None
667+
run_copy("foo", "out", run_cache=False, single_stage=True) is not None
669668
)
670669

671670

@@ -932,7 +931,7 @@ def test(self):
932931

933932

934933
class TestPersistentOutput(TestDvc):
935-
def test_ignore_build_cache(self):
934+
def test_ignore_run_cache(self):
936935
warning = "Build cache is ignored when persisting outputs."
937936

938937
with open("immutable", "w") as fobj:

tests/unit/command/test_repro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
"downstream": False,
88
"dry": False,
99
"force": False,
10-
"ignore_build_cache": False,
10+
"run_cache": True,
1111
"interactive": False,
1212
"no_commit": False,
1313
"pipeline": False,
1414
"single_item": False,
1515
"recursive": False,
16+
"force_downstream": False,
1617
}
1718

1819

tests/unit/command/test_run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_run(mocker, dvc):
2424
"wdir",
2525
"--no-exec",
2626
"--overwrite-dvcfile",
27-
"--ignore-build-cache",
27+
"--no-run-cache",
2828
"--no-commit",
2929
"--outs-persist",
3030
"outs-persist",
@@ -58,7 +58,7 @@ def test_run(mocker, dvc):
5858
wdir="wdir",
5959
no_exec=True,
6060
overwrite=True,
61-
ignore_build_cache=True,
61+
run_cache=False,
6262
no_commit=True,
6363
always_changed=True,
6464
cmd="command",
@@ -85,7 +85,7 @@ def test_run_args_from_cli(mocker, dvc):
8585
wdir=None,
8686
no_exec=False,
8787
overwrite=False,
88-
ignore_build_cache=False,
88+
run_cache=True,
8989
no_commit=False,
9090
always_changed=False,
9191
cmd="echo foo",
@@ -112,7 +112,7 @@ def test_run_args_with_spaces(mocker, dvc):
112112
wdir=None,
113113
no_exec=False,
114114
overwrite=False,
115-
ignore_build_cache=False,
115+
run_cache=True,
116116
no_commit=False,
117117
always_changed=False,
118118
cmd='echo "foo bar"',

0 commit comments

Comments
 (0)