Browse Source

Improve git_describe() fix 1 (#2635)

Add stderr=subprocess.STDOUT to catch error messages.
5.0
Glenn Jocher GitHub 3 years ago
parent
commit
2e95cf3d79
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions
  1. +2
    -3
      utils/torch_utils.py

+ 2
- 3
utils/torch_utils.py View File

@@ -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):

Loading…
Cancel
Save