From 683643d7cbbd913c8ba85f655a652989f54898c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Tue, 14 Feb 2023 16:49:03 +0545 Subject: [PATCH] scm: use dulwich backend when fetching exps during clone/pull refspecs uses pygit2 backend by default, which does not support git credential helpers. This PR forces to use dulwich backend during clone/pull operations. --- dvc/external_repo.py | 2 +- dvc/repo/experiments/utils.py | 13 ++++++------- dvc/scm.py | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dvc/external_repo.py b/dvc/external_repo.py index e273209c99..97c36ccbdd 100644 --- a/dvc/external_repo.py +++ b/dvc/external_repo.py @@ -253,7 +253,7 @@ def _pull(git: "Git", unshallow: bool = False): git.fetch(unshallow=unshallow) _merge_upstream(git) - fetch_all_exps(git, "origin") + fetch_all_exps(git, "origin", backends=["dulwich"]) def _merge_upstream(git: "Git"): diff --git a/dvc/repo/experiments/utils.py b/dvc/repo/experiments/utils.py index e8ed3ba97a..4bd0759dd1 100644 --- a/dvc/repo/experiments/utils.py +++ b/dvc/repo/experiments/utils.py @@ -5,6 +5,7 @@ from functools import wraps from typing import ( TYPE_CHECKING, + Any, Callable, Dict, Generator, @@ -279,17 +280,15 @@ def check_ref_format(scm: "Git", ref: ExpRefInfo): ) -def fetch_all_exps(scm: "Git", url: str, progress: Optional[Callable] = None): +def fetch_all_exps( + scm: "Git", url: str, progress: Optional[Callable] = None, **kwargs: Any +): refspecs = [ f"{ref}:{ref}" - for ref in iter_remote_refs(scm, url, base=EXPS_NAMESPACE) + for ref in iter_remote_refs(scm, url, base=EXPS_NAMESPACE, **kwargs) if not (ref.startswith(EXEC_NAMESPACE) or ref in STASHES) ] - scm.fetch_refspecs( - url, - refspecs, - progress=progress, - ) + scm.fetch_refspecs(url, refspecs, progress=progress, **kwargs) def get_random_exp_name(scm, baseline_rev): diff --git a/dvc/scm.py b/dvc/scm.py index 0c0c9e838d..04e93767be 100644 --- a/dvc/scm.py +++ b/dvc/scm.py @@ -179,7 +179,7 @@ def clone(url: str, to_path: str, **kwargs): try: git = Git.clone(url, to_path, progress=pbar.update_git, **kwargs) if "shallow_branch" not in kwargs: - fetch_all_exps(git, url, progress=pbar.update_git) + fetch_all_exps(git, url, progress=pbar.update_git, backends=["dulwich"]) return git except InternalCloneError as exc: raise CloneError("SCM error") from exc