From 101e5393d1ba73462a6a85df55a2dfb4b629cb0d Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 1 Apr 2020 19:06:30 +0300 Subject: [PATCH] Fix TRAINS_VCS_ROOT path conversion --- trains/backend_interface/task/repo/detectors.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/trains/backend_interface/task/repo/detectors.py b/trains/backend_interface/task/repo/detectors.py index c843aa69..67672b1c 100644 --- a/trains/backend_interface/task/repo/detectors.py +++ b/trains/backend_interface/task/repo/detectors.py @@ -224,19 +224,12 @@ class EnvDetector(Detector): @staticmethod def _normalize_root(root): """ - Get the absolute location of the parent folder (where .git resides) + Convert to absolute and squash 'path/../folder' """ - root_parts = list(reversed(Path(root).parts)) - cwd_abs = list(reversed(Path.cwd().parts)) - count = len(cwd_abs) - for i, p in enumerate(cwd_abs): - if i >= len(root_parts): - break - if p == root_parts[i]: - count -= 1 - cwd_abs.reverse() - root_abs_path = Path().joinpath(*cwd_abs[:count]) - return str(root_abs_path) + try: + return os.path.abspath((Path.cwd() / root).absolute().as_posix()) + except: + return Path.cwd() def _get_info(self, _, include_diff=False): repository_url = VCS_REPOSITORY_URL.get()