From 47147e3237f96d7bbb88b7d3c778d26e819bb9d9 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 19 Apr 2024 23:50:17 +0300 Subject: [PATCH] Fix cached repositories were not passing user/token when pulling, agent.vcs_cache.clone_on_pull_fail now defaults to false --- clearml_agent/helper/repo.py | 6 +++++- docs/clearml.conf | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clearml_agent/helper/repo.py b/clearml_agent/helper/repo.py index 4826640..dc71720 100644 --- a/clearml_agent/helper/repo.py +++ b/clearml_agent/helper/repo.py @@ -322,6 +322,8 @@ class VCS(object): return # rewrite ssh URLs only if either ssh port or ssh user are forced in config + # TODO: fix, when url is in the form of `git@domain.com:user/project.git` we will fail to get scheme + # need to add ssh:// and replace first ":" with / , unless port is specified if parsed_url.scheme == "ssh" and ( self.session.config.get('agent.force_git_ssh_port', None) or self.session.config.get('agent.force_git_ssh_user', None) @@ -595,6 +597,7 @@ class Git(VCS): ) def pull(self): + self._set_ssh_url() self.call("fetch", "--all", "--recurse-submodules", cwd=self.location) def _git_pass_auth_wrapper(self, func, *args, **kwargs): @@ -781,9 +784,10 @@ def clone_repository_cached(session, execution, destination): try: vcs.pull() except Exception as ex: + print("git pull failed: {}".format(ex)) if ( session.config.get("agent.vcs_cache.enabled", False) and - session.config.get("agent.vcs_cache.clone_on_pull_fail", True) + session.config.get("agent.vcs_cache.clone_on_pull_fail", False) ): print("pulling git failed, re-cloning: {}".format(no_password_url)) rm_tree(cached_repo_path) diff --git a/docs/clearml.conf b/docs/clearml.conf index 3a8befa..b47410a 100644 --- a/docs/clearml.conf +++ b/docs/clearml.conf @@ -163,7 +163,7 @@ agent { path: ~/.clearml/vcs-cache # if git pull failed, always revert to re-cloning the repo, it protects against old user name changes - # clone_on_pull_fail: true + # clone_on_pull_fail: false }, # DEPRECATED: please use `venvs_cache` and set `venvs_cache.path`