Skip to content

Commit bf48b92

Browse files
committed
Update exec_prefix handling: template this separate from batch command.
- It would be possible to have exec_prefix use string formatting and the command itself use jinja2 formatting, and when combined the string formatting would fail. To handle this, template them separately and then concatenate.
1 parent c0da1f3 commit bf48b92

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

batchspawner/batchspawner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def _get_batch_script(self, **subvars):
215215
@gen.coroutine
216216
def submit_batch_script(self):
217217
subvars = self.get_req_subvars()
218-
cmd = self.exec_prefix + ' ' + self.batch_submit_cmd
219-
cmd = format_template(cmd, **subvars)
218+
cmd = ' '.join((format_template(self.exec_prefix, **subvars),
219+
format_template(self.batch_submit_cmd, **subvars)))
220220
subvars['cmd'] = self.cmd_formatted_for_batch()
221221
if hasattr(self, 'user_options'):
222222
subvars.update(self.user_options)
@@ -246,8 +246,8 @@ def read_job_state(self):
246246
return self.job_status
247247
subvars = self.get_req_subvars()
248248
subvars['job_id'] = self.job_id
249-
cmd = self.exec_prefix + ' ' + self.batch_query_cmd
250-
cmd = format_template(cmd, **subvars)
249+
cmd = ' '.join((format_template(self.exec_prefix, **subvars),
250+
format_template(self.batch_query_cmd, **subvars)))
251251
self.log.debug('Spawner querying job: ' + cmd)
252252
try:
253253
out = yield self.run_command(cmd)
@@ -266,8 +266,8 @@ def read_job_state(self):
266266
def cancel_batch_job(self):
267267
subvars = self.get_req_subvars()
268268
subvars['job_id'] = self.job_id
269-
cmd = self.exec_prefix + ' ' + self.batch_cancel_cmd
270-
cmd = format_template(cmd, **subvars)
269+
cmd = ' '.join((format_template(self.exec_prefix, **subvars),
270+
format_template(self.batch_cancel_cmd, **subvars)))
271271
self.log.info('Cancelling job ' + self.job_id + ': ' + cmd)
272272
yield self.run_command(cmd)
273273

0 commit comments

Comments
 (0)