Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit c62e9b5

Browse files
committed
add git hash to CLI
1 parent 29a1e00 commit c62e9b5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

paperspace/jobs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def create(params, no_logging=False, extra_files=[]):
152152
jobId = job['id']
153153
print('New jobId: %s' % jobId)
154154
print('Cluster: %s' % job['cluster'])
155+
if job['codeCommit']:
156+
print('Git commit: %s' % job['codeCommit'])
155157
print('Job %s' % job['state'])
156158

157159
if job['state'] == 'Pending':

paperspace/method.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pprint import pprint
88

99
import requests
10+
import subprocess
1011

1112
from . import config
1213

@@ -84,8 +85,18 @@ def method(category, method, params):
8485

8586
files = None
8687
if method == 'createJob' and 'workspace' in params:
87-
8888
workspace = params.get('workspace', None)
89+
if workspace[:1] == '~':
90+
workspace = os.path.expanduser(workspace)
91+
if workspace.find("$") != -1:
92+
workspace = os.path.expandvars(workspace)
93+
if os.path.isdir(os.path.abspath(workspace)+"/.git"):
94+
try:
95+
git_short_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=os.path.abspath(workspace)).strip()
96+
code_commit = git_short_hash.decode("utf-8")
97+
params['codeCommit'] = code_commit
98+
except Exception as e:
99+
pass
89100
ignore_files.extend(['.git', '.gitignore', '__pycache__'])
90101
if workspace:
91102
if workspace != 'none':

0 commit comments

Comments
 (0)