mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-18 23:10:14 +01:00
repro: Disable run-cache if --no-commit.
As described in https://github.com/iterative/dvc/issues/4428#issuecomment-778263005. Add `run_cache` argument to `Stage.save`. Set it to `False` if `no_commit`.
This commit is contained in:
+11
-3
@@ -463,7 +463,12 @@ class Stage(params.StageParams):
|
||||
logger.debug("Computed %s md5: '%s'", self, m)
|
||||
return m
|
||||
|
||||
def save(self, allow_missing: bool = False, merge_versioned: bool = False):
|
||||
def save(
|
||||
self,
|
||||
allow_missing: bool = False,
|
||||
merge_versioned: bool = False,
|
||||
run_cache: bool = True,
|
||||
):
|
||||
self.save_deps(allow_missing=allow_missing)
|
||||
|
||||
self.save_outs(
|
||||
@@ -471,7 +476,8 @@ class Stage(params.StageParams):
|
||||
)
|
||||
self.md5 = self.compute_md5()
|
||||
|
||||
self.repo.stage_cache.save(self)
|
||||
if run_cache:
|
||||
self.repo.stage_cache.save(self)
|
||||
|
||||
def save_deps(self, allow_missing=False):
|
||||
from dvc.dependency.base import DependencyDoesNotExistError
|
||||
@@ -584,7 +590,9 @@ class Stage(params.StageParams):
|
||||
if not dry:
|
||||
if kwargs.get("checkpoint_func", None) or no_download:
|
||||
allow_missing = True
|
||||
self.save(allow_missing=allow_missing)
|
||||
|
||||
self.save(allow_missing=allow_missing, run_cache=not no_commit)
|
||||
|
||||
if no_download:
|
||||
self.ignore_outs()
|
||||
if not no_commit:
|
||||
|
||||
@@ -478,7 +478,7 @@ def test_push_pull_all(tmp_dir, scm, dvc, local_remote, key, expected):
|
||||
|
||||
def test_push_pull_fetch_pipeline_stages(tmp_dir, dvc, run_copy, local_remote):
|
||||
tmp_dir.dvc_gen("foo", "foo")
|
||||
run_copy("foo", "bar", no_commit=True, name="copy-foo-bar")
|
||||
run_copy("foo", "bar", name="copy-foo-bar")
|
||||
|
||||
dvc.push("copy-foo-bar")
|
||||
assert len(recurse_list_dir(local_remote.url)) == 1
|
||||
|
||||
@@ -842,7 +842,8 @@ def test_repro_no_commit(tmp_dir, dvc, copy_script, run_stage):
|
||||
remove(dvc.odb.local.path)
|
||||
ret = main(["repro", stage.addressing, "--no-commit"])
|
||||
assert ret == 0
|
||||
assert os.listdir(dvc.odb.local.path) == ["runs"]
|
||||
# run-cache should be skipped if `-no-commit`.
|
||||
assert not os.path.isdir(dvc.odb.local.path)
|
||||
|
||||
|
||||
class TestReproAlreadyCached:
|
||||
|
||||
Reference in New Issue
Block a user