From 4179ac5234c7dfaeaee7d748c415609a7c83c60c Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 12 Apr 2024 20:29:36 +0300 Subject: [PATCH] Fix git pulling on cached invalid git entry. On error, re-clone the entire repo again (disable using "agent.vcs_cache.clone_on_pull_fail: false") --- clearml_agent/helper/repo.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/clearml_agent/helper/repo.py b/clearml_agent/helper/repo.py index c191093..4826640 100644 --- a/clearml_agent/helper/repo.py +++ b/clearml_agent/helper/repo.py @@ -777,7 +777,21 @@ def clone_repository_cached(session, execution, destination): # We clone the entire repository, not a specific branch vcs.clone() # branch=execution.branch) - vcs.pull() + print("pulling git") + try: + vcs.pull() + except Exception as ex: + if ( + session.config.get("agent.vcs_cache.enabled", False) and + session.config.get("agent.vcs_cache.clone_on_pull_fail", True) + ): + print("pulling git failed, re-cloning: {}".format(no_password_url)) + rm_tree(cached_repo_path) + vcs.clone() + else: + raise ex + print("pulling git completed") + rm_tree(destination) shutil.copytree(Text(cached_repo_path), Text(clone_folder), symlinks=select_for_platform(linux=True, windows=False),