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

Commit 8828d84

Browse files
colin-welchsanfilip
authored andcommitted
tweak: Add support for the "Cancelled" job state.
1 parent e5b3572 commit 8828d84

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

paperspace/jobs.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def waitfor(params):
208208
or (state == 'Running' and params['state'] == 'Pending')
209209
or state == 'Error'
210210
or state == 'Stopped'
211-
or state == 'Failed'):
211+
or state == 'Failed'
212+
or state == 'Cancelled'):
212213
return job
213214
time.sleep(5)
214215

@@ -231,7 +232,7 @@ def create(params, no_logging=False):
231232
print_json_pretty(job)
232233
return job
233234

234-
if job['state'] != 'Error':
235+
if job['state'] != 'Error' and job['state'] != 'Cancelled':
235236
print('Awaiting logs...')
236237
if logs({'jobId': jobId}, tail=True):
237238
job = method('jobs', 'getJob', {'jobId': jobId})
@@ -241,10 +242,12 @@ def create(params, no_logging=False):
241242
print_json_pretty(job)
242243
return job
243244

244-
if job['state'] != 'Error':
245-
print('Job %s; exitCode %d' % (job['state'], job['exitCode']))
246-
else:
245+
if job['state'] == 'Error':
247246
print('Job %s: %s' % (job['state'], job['jobError']))
247+
elif job['state'] == 'Cancelled':
248+
print('Job %s' % (job['state']))
249+
else:
250+
print('Job %s; exitCode %d' % (job['state'], job['exitCode']))
248251
return job
249252

250253

0 commit comments

Comments
 (0)