mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix the missing parameter in get_sha function (#51290)
Summary: get_sha() function didn't pass in the pytorch_root argument, so subprocess.check_output always raise exception since pytorch_root is not defined, thus always return 'Unknown'. Pull Request resolved: https://github.com/pytorch/pytorch/pull/51290 Reviewed By: soumith Differential Revision: D26219051 Pulled By: malfet fbshipit-source-id: fee2c4f5fdfc61983559eec1600b9accb344c527
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ab4623da16
commit
62f6e55439
@ -4,7 +4,7 @@ import subprocess
|
||||
from pathlib import Path
|
||||
from distutils.util import strtobool
|
||||
|
||||
def get_sha():
|
||||
def get_sha(pytorch_root):
|
||||
try:
|
||||
return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=pytorch_root).decode('ascii').strip()
|
||||
except Exception:
|
||||
@ -22,7 +22,7 @@ def get_torch_version(sha=None):
|
||||
version += '.post' + str(build_number)
|
||||
elif sha != 'Unknown':
|
||||
if sha is None:
|
||||
sha = get_sha()
|
||||
sha = get_sha(pytorch_root)
|
||||
version += '+' + sha[:7]
|
||||
return version
|
||||
|
||||
@ -40,7 +40,7 @@ if __name__ == "__main__":
|
||||
|
||||
pytorch_root = Path(__file__).parent.parent
|
||||
version_path = pytorch_root / "torch" / "version.py"
|
||||
sha = get_sha()
|
||||
sha = get_sha(pytorch_root)
|
||||
version = get_torch_version(sha)
|
||||
|
||||
with open(version_path, 'w') as f:
|
||||
|
Reference in New Issue
Block a user