diff --git a/dvc/cache/base.py b/dvc/cache/base.py index 5dca5a096..6f3240da0 100644 --- a/dvc/cache/base.py +++ b/dvc/cache/base.py @@ -537,6 +537,7 @@ class CloudCache: progress_callback=None, relink=False, filter_info=None, + quiet=False, ): if path_info.scheme not in ["local", self.tree.scheme]: raise NotImplementedError @@ -544,10 +545,11 @@ class CloudCache: failed = None skip = False if not hash_info: - logger.warning( - "No file hash info found for '%s'. " "It won't be created.", - path_info, - ) + if not quiet: + logger.warning( + "No file hash info found for '%s'. It won't be created.", + path_info, + ) self.safe_remove(path_info, force=force) failed = path_info @@ -558,11 +560,12 @@ class CloudCache: elif self.changed_cache( hash_info, path_info=path_info, filter_info=filter_info ): - logger.warning( - "Cache '%s' not found. File '%s' won't be created.", - hash_info, - path_info, - ) + if not quiet: + logger.warning( + "Cache '%s' not found. File '%s' won't be created.", + hash_info, + path_info, + ) self.safe_remove(path_info, force=force) failed = path_info diff --git a/dvc/output/base.py b/dvc/output/base.py index e57c7ba29..24af234bc 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -330,6 +330,7 @@ class BaseOutput: relink=False, filter_info=None, allow_missing=False, + **kwargs, ): if not self.use_cache: if progress_callback: @@ -346,6 +347,7 @@ class BaseOutput: progress_callback=progress_callback, relink=relink, filter_info=filter_info, + **kwargs, ) except CheckoutError: if allow_missing: diff --git a/dvc/repo/checkout.py b/dvc/repo/checkout.py index 58576412d..6b2914031 100644 --- a/dvc/repo/checkout.py +++ b/dvc/repo/checkout.py @@ -47,6 +47,7 @@ def checkout( relink=False, recursive=False, allow_missing=False, + **kwargs, ): from dvc.stage.exceptions import ( StageFileBadNameError, @@ -98,6 +99,7 @@ def checkout( relink=relink, filter_info=filter_info, allow_missing=allow_missing, + **kwargs, ) for key, items in result.items(): stats[key].extend(_fspath_dir(path) for path in items) diff --git a/dvc/repo/experiments/__init__.py b/dvc/repo/experiments/__init__.py index b1b5d704d..b6ab1d43c 100644 --- a/dvc/repo/experiments/__init__.py +++ b/dvc/repo/experiments/__init__.py @@ -403,7 +403,7 @@ class Experiments: ) exp_rev = first(results) if exp_rev is not None: - self.checkout_exp(exp_rev, allow_missing=checkpoint) + self.checkout_exp(exp_rev) return results def reproduce_queued(self, **kwargs): @@ -753,7 +753,7 @@ class Experiments: raise UploadError(fails) @scm_locked - def checkout_exp(self, rev, allow_missing=False): + def checkout_exp(self, rev, **kwargs): """Checkout an experiment to the user's workspace.""" from git.exc import GitCommandError @@ -762,12 +762,17 @@ class Experiments: baseline_rev = self._check_baseline(rev) self._scm_checkout(rev) + branch = self._get_branch_containing(rev) + m = self.BRANCH_RE.match(branch) + if m and m.group("checkpoint"): + kwargs.update({"allow_missing": True, "quiet": True}) + tmp = tempfile.NamedTemporaryFile(delete=False).name self.scm.repo.head.commit.diff( baseline_rev, patch=True, full_index=True, binary=True, output=tmp ) - dirty = self.repo.scm.is_dirty() + dirty = self.repo.scm.is_dirty(untracked_files=True) if dirty: logger.debug("Stashing workspace changes.") self.repo.scm.repo.git.stash("push", "--include-untracked") @@ -787,7 +792,7 @@ class Experiments: self._unstash_workspace() if need_checkout: - dvc_checkout(self.repo, allow_missing=allow_missing) + dvc_checkout(self.repo, **kwargs) def _check_baseline(self, exp_rev): baseline_sha = self.repo.scm.get_rev() @@ -852,12 +857,20 @@ class Experiments: def _get_branch_containing(self, rev): from git.exc import GitCommandError - if self.scm.repo.head.is_detached: - self._checkout_default_branch() try: names = self.scm.repo.git.branch(contains=rev).strip().splitlines() + + if ( + names + and self.scm.repo.head.is_detached + and names[0].startswith("* (HEAD detached") + ): + # Ignore detached head entry if it exists + del names[0] + if not names: return None + if len(names) > 1: raise MultipleBranchError(rev) name = names[0] diff --git a/dvc/repo/experiments/executor.py b/dvc/repo/experiments/executor.py index 111de674a..5cdacd54c 100644 --- a/dvc/repo/experiments/executor.py +++ b/dvc/repo/experiments/executor.py @@ -168,7 +168,9 @@ class LocalExecutor(ExperimentExecutor): # is not polluted with the (persistent) out from an unrelated # experiment run checkpoint = kwargs.pop("checkpoint", False) - dvc.checkout(allow_missing=checkpoint, force=checkpoint) + dvc.checkout( + allow_missing=checkpoint, force=checkpoint, quiet=checkpoint + ) stages = dvc.reproduce( on_unchanged=filter_pipeline, allow_missing=checkpoint,