Skip to content

Commit 011b200

Browse files
committed
Create separate _get_batch_script method for testing batch_script subst
1 parent 8920725 commit 011b200

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

batchspawner/batchspawner.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ def run_command(self, cmd, input=None, env=None):
206206
out = out.decode().strip()
207207
return out
208208

209+
@gen.coroutine
210+
def _get_batch_script(self, **subvars):
211+
"""Format batch script from vars"""
212+
# Colud be overridden by subclasses, but mainly useful for testing
213+
return format_template(self.batch_script, **subvars)
214+
209215
@gen.coroutine
210216
def submit_batch_script(self):
211217
subvars = self.get_req_subvars()
@@ -214,8 +220,7 @@ def submit_batch_script(self):
214220
subvars['cmd'] = self.cmd_formatted_for_batch()
215221
if hasattr(self, 'user_options'):
216222
subvars.update(self.user_options)
217-
script = format_template(self.batch_script, **subvars)
218-
self._last_batch_script = script # used for testing only
223+
script = yield self._get_batch_script(**subvars)
219224
self.log.info('Spawner submitting job using ' + cmd)
220225
self.log.info('Spawner submitted script:\n' + script)
221226
out = yield self.run_command(cmd, input=script, env=self.get_env())

0 commit comments

Comments
 (0)