Skip to content

Commit

Permalink
Improve git_describe() fix 1 (#2635)
Browse files Browse the repository at this point in the history
Add stderr=subprocess.STDOUT to catch error messages.
  • Loading branch information
glenn-jocher committed Mar 28, 2021
1 parent 518c095 commit 2e95cf3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ def git_describe(path=Path(__file__).parent): # path must be a directory
# return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe
s = f'git -C {path} describe --tags --long --always'
try:
r = subprocess.check_output(s, shell=True).decode()[:-1]
return '' if r.startswith('fatal: not a git repository') else r
return subprocess.check_output(s, shell=True, stderr=subprocess.STDOUT).decode()[:-1]
except subprocess.CalledProcessError as e:
return ''
return '' # not a git repository


def select_device(device='', batch_size=None):
Expand Down

0 comments on commit 2e95cf3

Please sign in to comment.