Skip to content

Commit

Permalink
add option to require explicit fetch/checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
pbailey-hf committed Jun 6, 2024
1 parent c741562 commit 2d2ca33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def loadd_from(stage, d_list):
for d in d_list:
p = d.pop(Output.PARAM_PATH)
cache = d.pop(Output.PARAM_CACHE, True)
explicit = d.pop(Output.PARAM_EXPLICIT, False)
metric = d.pop(Output.PARAM_METRIC, False)
plot = d.pop(Output.PARAM_PLOT, False)
persist = d.pop(Output.PARAM_PERSIST, False)
Expand All @@ -103,6 +104,7 @@ def loadd_from(stage, d_list):
p,
info=d,
cache=cache,
explicit=explicit,
metric=metric,
plot=plot,
persist=persist,
Expand Down Expand Up @@ -282,6 +284,7 @@ class Output:

PARAM_PATH = "path"
PARAM_CACHE = "cache"
PARAM_EXPLICIT = "explicit"
PARAM_FILES = "files"
PARAM_METRIC = "metric"
PARAM_METRIC_TYPE = "type"
Expand Down Expand Up @@ -312,6 +315,7 @@ def __init__( # noqa: PLR0913
path,
info=None,
cache=True,
explicit=False,
metric=False,
plot=False,
persist=False,
Expand Down Expand Up @@ -384,6 +388,7 @@ def __init__( # noqa: PLR0913
files = [merge_file_meta_from_cloud(f) for f in files]
self.files = files
self.use_cache = False if self.IS_DEPENDENCY else cache
self.explicit = explicit
self.metric = False if self.IS_DEPENDENCY else metric
self.plot = False if self.IS_DEPENDENCY else plot
self.persist = persist
Expand Down Expand Up @@ -1500,6 +1505,7 @@ def _merge_dir_version_meta(self, other: "Output"):
**ARTIFACT_SCHEMA,
**ANNOTATION_SCHEMA,
Output.PARAM_CACHE: bool,
Output.PARAM_EXPLICIT: bool,
Output.PARAM_REMOTE: str,
Output.PARAM_PUSH: bool,
Output.PARAM_FILES: [DIR_FILES_SCHEMA],
Expand Down
7 changes: 6 additions & 1 deletion dvc/repo/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,13 @@ def onerror(target, exc):
raise CheckoutErrorSuggestGit(target) from exc
raise

def outs_filter(out: "Output") -> bool:
if out.explicit and not [t for t in targets if t]:
return False
return True

view = self.index.targets_view(
targets, recursive=recursive, with_deps=with_deps, onerror=onerror
targets, recursive=recursive, with_deps=with_deps, onerror=onerror, outs_filter=outs_filter
)

with ui.progress(unit="entry", desc="Building workspace index", leave=True) as pb:
Expand Down
2 changes: 2 additions & 0 deletions dvc/repo/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def stage_filter(stage: "Stage") -> bool:
def outs_filter(out: "Output") -> bool:
if push and not out.can_push:
return False
if out.explicit and not [t for t in targets if t]:
return False
return not (remote and out.remote and remote != out.remote)

for rev in repo.brancher(
Expand Down

0 comments on commit 2d2ca33

Please sign in to comment.