glenn-jocher commited on
Commit
2e95cf3
1 Parent(s): 518c095

Improve git_describe() fix 1 (#2635)

Browse files

Add stderr=subprocess.STDOUT to catch error messages.

Files changed (1) hide show
  1. utils/torch_utils.py +2 -3
utils/torch_utils.py CHANGED
@@ -55,10 +55,9 @@ def git_describe(path=Path(__file__).parent): # path must be a directory
55
  # return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe
56
  s = f'git -C {path} describe --tags --long --always'
57
  try:
58
- r = subprocess.check_output(s, shell=True).decode()[:-1]
59
- return '' if r.startswith('fatal: not a git repository') else r
60
  except subprocess.CalledProcessError as e:
61
- return ''
62
 
63
 
64
  def select_device(device='', batch_size=None):
 
55
  # return human-readable git description, i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe
56
  s = f'git -C {path} describe --tags --long --always'
57
  try:
58
+ return subprocess.check_output(s, shell=True, stderr=subprocess.STDOUT).decode()[:-1]
 
59
  except subprocess.CalledProcessError as e:
60
+ return '' # not a git repository
61
 
62
 
63
  def select_device(device='', batch_size=None):