diff --git a/dvc/stage/__init__.py b/dvc/stage/__init__.py index c75210bace..40c0d07b76 100644 --- a/dvc/stage/__init__.py +++ b/dvc/stage/__init__.py @@ -463,7 +463,12 @@ def compute_md5(self): 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 @@ def save(self, allow_missing: bool = False, merge_versioned: bool = False): ) 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 @@ def run( 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: diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index f864fb73c3..2350ac7ebe 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -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 diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py index 627f6ce689..c0edde6938 100644 --- a/tests/func/test_repro.py +++ b/tests/func/test_repro.py @@ -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: