Skip to content

Commit c61fefa

Browse files
author
Jarno Rantaharju
committed
Submit returns exit code
1 parent 298e536 commit c61fefa

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

rynner/rynner.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: future_fstrings -*-
21
import uuid
32
import os
43
import pickle
@@ -212,7 +211,7 @@ def download(self, run):
212211
def submit(self, run):
213212
# copy execution script to remote
214213

215-
runscript_name = f'rynner_exec_{run.job_name}'
214+
runscript_name = 'rynner_exec_{}'.format((run.job_name))
216215
script_dir = self.provider.script_dir
217216
local_script_path = os.path.join(self.provider.script_dir, runscript_name)
218217

@@ -227,16 +226,24 @@ def submit(self, run):
227226

228227
# submit run
229228

230-
submit_script = f'{self._record_time("start", run)}; \
231-
cd {run.remote_dir.as_posix()}; \
232-
./{runscript_name}; \
229+
submit_script = '{}; \
230+
cd {}; \
231+
./{}; \
233232
cd ; \
234-
{self._record_time("end", run)}'
233+
{}'.format((self._record_time("start", run)), (run.remote_dir.as_posix()), (runscript_name), (self._record_time("end", run)))
235234

236-
run['qid'] = self.provider.submit(submit_script, 1)
237-
run['status'] = Rynner.StatusPending
235+
qid = self.provider.submit(submit_script, 1)
236+
237+
if qid == None:
238+
# Failed to submit
239+
return False
240+
else :
241+
# Succesfully submitted
242+
run['qid'] = qid
243+
run['status'] = Rynner.StatusPending
238244

239-
self.save_run_config( run )
245+
self.save_run_config( run )
246+
return True
240247

241248
def cancel(self, run):
242249
self._record_time('cancel', run)
@@ -246,7 +253,7 @@ def cancel(self, run):
246253

247254
def _record_time(self, label, run, execute=False):
248255
times_file = run.remote_dir.joinpath('rynner.times').as_posix()
249-
remote_cmd = f'echo "{label}: $(date +%s)" >> {times_file}'
256+
remote_cmd = 'echo "{}: $(date +%s)" >> {}'.format((label), (times_file))
250257
if execute:
251258
self.provider.channel.execute_wait(remote_cmd)
252259

@@ -318,7 +325,7 @@ def save_run_config(self, run):
318325
Saves the run configuration on the cluster
319326
'''
320327

321-
filename = f'rynner_data_{run.job_name}.pkl'
328+
filename = 'rynner_data_{}.pkl'.format((run.job_name))
322329
filepath = run.remote_dir.joinpath( filename ).as_posix()
323330

324331
sftp_client = self.provider.channel.sftp_client
@@ -363,4 +370,3 @@ def get_runs(self, namespace = ''):
363370

364371
return runs
365372

366-

0 commit comments

Comments
 (0)