Skip to content

Commit a7117a7

Browse files
committed
run: try to save deps before running the command
Unlike old `_check_missing_deps`, this also verifies that we are able to save more complex dependencies such as parameters, where we not only care about the config file, but also about the parameters in it. Fixes #3707
1 parent d998c0a commit a7117a7

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

dvc/stage/__init__.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
StagePathNotDirectoryError,
2222
StageCommitError,
2323
StageUpdateError,
24-
MissingDep,
2524
MissingDataSource,
2625
)
2726
from . import params
@@ -374,8 +373,7 @@ def is_cached(self):
374373

375374
# NOTE: need to save checksums for deps in order to compare them
376375
# with what is written in the old stage.
377-
for dep in self.deps:
378-
dep.save()
376+
self._save_deps()
379377

380378
old_d = old.dumpd()
381379
new_d = self.dumpd()
@@ -482,10 +480,13 @@ def _compute_md5(self):
482480
logger.debug("Computed {} md5: '{}'".format(self, m))
483481
return m
484482

485-
def save(self):
483+
def _save_deps(self):
486484
for dep in self.deps:
487485
dep.save()
488486

487+
def save(self):
488+
self._save_deps()
489+
489490
for out in self.outs:
490491
out.save()
491492

@@ -526,12 +527,6 @@ def commit(self):
526527
for out in self.outs:
527528
out.commit()
528529

529-
def _check_missing_deps(self):
530-
missing = [dep for dep in self.deps if not dep.exists]
531-
532-
if any(missing):
533-
raise MissingDep(missing)
534-
535530
@staticmethod
536531
def _warn_if_fish(executable): # pragma: no cover
537532
if (
@@ -570,8 +565,6 @@ def _check_duplicated_arguments(self):
570565

571566
@unlocked_repo
572567
def _run(self):
573-
self._check_missing_deps()
574-
575568
kwargs = {"cwd": self.wdir, "env": fix_env(None), "close_fds": True}
576569

577570
if os.name == "nt":
@@ -667,6 +660,7 @@ def run(
667660
logger.info("Stage is cached, skipping.")
668661
self.checkout()
669662
else:
663+
self._save_deps()
670664
logger.info("Running command:\n\t{}".format(self.cmd))
671665
self._run()
672666

dvc/stage/exceptions.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ def __init__(self, path):
7373
)
7474

7575

76-
class MissingDep(DvcException):
77-
def __init__(self, deps):
78-
assert len(deps) > 0
79-
80-
dep = "dependencies" if len(deps) > 1 else "dependency"
81-
msg = "missing '{}': {}".format(dep, ", ".join(map(str, deps)))
82-
super().__init__(msg)
83-
84-
8576
class MissingDataSource(DvcException):
8677
def __init__(self, missing_files):
8778
assert len(missing_files) > 0

tests/func/test_run_single_stage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
StagePathOutsideError,
2727
StagePathNotFoundError,
2828
StagePathNotDirectoryError,
29-
MissingDep,
3029
)
3130
from dvc.system import System
3231
from dvc.utils import file_md5
@@ -79,7 +78,9 @@ def test(self):
7978

8079
class TestRunMissingDep(TestDvc):
8180
def test(self):
82-
with self.assertRaises(MissingDep):
81+
from dvc.dependency.base import DependencyDoesNotExistError
82+
83+
with self.assertRaises(DependencyDoesNotExistError):
8384
self.dvc.run(
8485
cmd="",
8586
deps=["non-existing-dep"],

0 commit comments

Comments
 (0)