From 77415a42e5975ea356393c9f1d5cff0ae8acae2c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 26 Mar 2021 01:44:00 +0100 Subject: [PATCH] Update git_describe() for remote dir usage (#2606) --- utils/torch_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 8f3538ab152a..78c42b6d0c05 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -45,9 +45,10 @@ def init_torch_seeds(seed=0): def git_describe(): # return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe - if Path('.git').exists(): - return subprocess.check_output('git describe --tags --long --always', shell=True).decode('utf-8')[:-1] - else: + s = f'git -C {Path(__file__).resolve().parent} describe --tags --long --always' + try: + return subprocess.check_output(s, shell=True).decode()[:-1] + except subprocess.CalledProcessError as e: return ''