Skip to content

Commit

Permalink
fetch: support passing config
Browse files Browse the repository at this point in the history
For now not exposing it in CLI since there is no need/use yet.

Requirement for https://github.com/iterative/studio/pull/6541
  • Loading branch information
efiop committed Jul 25, 2023
1 parent 92cae74 commit 9c89841
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dvc/repo/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ def _collect_indexes( # noqa: PLR0913
revs=None,
max_size=None,
types=None,
config=None,
):
indexes = {}
collection_exc = None

config = config or {}
if remote:
core = config.get("core") or {}
core["remote"] = remote
config["core"] = core

for rev in repo.brancher(
revs=revs,
all_branches=all_branches,
all_tags=all_tags,
all_commits=all_commits,
):
saved_remote = repo.config["core"].get("remote")
try:
if remote:
repo.config["core"]["remote"] = remote
repo.config.update(config)

idx = repo.index.targets_view(
targets,
Expand All @@ -46,9 +52,6 @@ def _collect_indexes( # noqa: PLR0913
except Exception as exc: # pylint: disable=broad-except
collection_exc = exc
logger.exception("failed to collect '%s'", rev or "workspace")
finally:
if remote:
repo.config["core"]["remote"] = saved_remote

if not indexes and collection_exc:
raise collection_exc
Expand All @@ -71,6 +74,7 @@ def fetch( # noqa: C901, PLR0913
revs=None,
max_size=None,
types=None,
config=None,
) -> int:
"""Download data items from a cloud and imported repositories
Expand Down Expand Up @@ -114,6 +118,7 @@ def fetch( # noqa: C901, PLR0913
revs=revs,
max_size=max_size,
types=types,
config=config,
)

cache_key = ("fetch", tokenize(sorted(indexes.keys())))
Expand Down

0 comments on commit 9c89841

Please sign in to comment.