Skip to content

Commit e956082

Browse files
committed
Add prologue and epilogue options to other spawners
- These options first appeared in dff4482 for SlurmSpawner - Add tests for this option - Not currently implemented for CondorSpawner, since it uses a different method using `bash -c`. It could be added there, but someone with local knowledge should do that.
1 parent ecc8dd8 commit e956082

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

batchspawner/batchspawner.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ class TorqueSpawner(BatchSpawnerRegexStates):
460460
#PBS -v {keepvars}
461461
#PBS {options}
462462
463+
{prologue}
463464
{cmd}
465+
{epilogue}
464466
""").tag(config=True)
465467

466468
# outputs job id string
@@ -582,7 +584,9 @@ class GridengineSpawner(BatchSpawnerBase):
582584
#$ -v {keepvars}
583585
#$ {options}
584586
587+
{prologue}
585588
{cmd}
589+
{epilogue}
586590
""").tag(config=True)
587591

588592
# outputs job id string
@@ -668,7 +672,9 @@ class LsfSpawner(BatchSpawnerBase):
668672
#BSUB -o {homedir}/.jupyterhub.lsf.out
669673
#BSUB -e {homedir}/.jupyterhub.lsf.err
670674
675+
{prologue}
671676
{cmd}
677+
{epilogue}
672678
''').tag(config=True)
673679

674680

batchspawner/tests/test_spawners.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,11 @@ def test_torque(db, io_loop):
279279
'req_nprocs': '5',
280280
'req_memory': '5678',
281281
'req_options': 'some_option_asdf',
282+
'req_prologue': 'PROLOGUE',
283+
'req_epilogue': 'EPILOGUE',
282284
}
283285
batch_script_re_list = [
284-
re.compile(r'singleuser_command'),
286+
re.compile(r'^PROLOGUE.*^singleuser_command.*^EPILOGUE', re.S|re.M),
285287
re.compile(r'mem=5678'),
286288
re.compile(r'ppn=5'),
287289
re.compile(r'^#PBS some_option_asdf', re.M),
@@ -305,9 +307,11 @@ def test_moab(db, io_loop):
305307
'req_nprocs': '5',
306308
'req_memory': '5678',
307309
'req_options': 'some_option_asdf',
310+
'req_prologue': 'PROLOGUE',
311+
'req_epilogue': 'EPILOGUE',
308312
}
309313
batch_script_re_list = [
310-
re.compile(r'singleuser_command'),
314+
re.compile(r'^PROLOGUE.*^singleuser_command.*^EPILOGUE', re.S|re.M),
311315
re.compile(r'mem=5678'),
312316
re.compile(r'ppn=5'),
313317
re.compile(r'^#PBS some_option_asdf', re.M),
@@ -332,9 +336,11 @@ def test_slurm(db, io_loop):
332336
'req_nprocs': '5',
333337
'req_memory': '5678',
334338
'req_options': 'some_option_asdf',
339+
'req_prologue': 'PROLOGUE',
340+
'req_epilogue': 'EPILOGUE',
335341
}
336342
batch_script_re_list = [
337-
re.compile(r'srun .* singleuser_command', re.X|re.M),
343+
re.compile(r'PROLOGUE.*srun singleuser_command.*EPILOGUE', re.S),
338344
re.compile(r'^#SBATCH \s+ --cpus-per-task=5', re.X|re.M),
339345
re.compile(r'^#SBATCH \s+ --time=3-05:10:10', re.X|re.M),
340346
re.compile(r'^#SBATCH \s+ some_option_asdf', re.X|re.M),
@@ -407,9 +413,11 @@ def test_lfs(db, io_loop):
407413
'req_memory': '5678',
408414
'req_options': 'some_option_asdf',
409415
'req_queue': 'some_queue',
416+
'req_prologue': 'PROLOGUE',
417+
'req_epilogue': 'EPILOGUE',
410418
}
411419
batch_script_re_list = [
412-
re.compile(r'^singleuser_command', re.M),
420+
re.compile(r'^PROLOGUE.*^singleuser_command.*^EPILOGUE', re.S|re.M),
413421
re.compile(r'#BSUB\s+-q\s+some_queue', re.M),
414422
]
415423
script = [

0 commit comments

Comments
 (0)