Skip to content

Commit ec5e972

Browse files
authored
Merge pull request #170 from Hoeze/master
add 'gres' option to SlurmSpawner
2 parents 9e7d557 + 50da68f commit ec5e972

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Added (user)
2424
* Add `req_prologue` and `req_epilogue` options to scripts which are inserted before/after the main jupyterhub-singleuser command, which allow for generic setup/cleanup without overriding the entire script. #96
2525
* SlurmSpawner: add the `req_reservation` option. #91
2626
* Add basic support for JupyterHub progress updates, but this is not used much yet. #86
27+
# PR #170: SlurmSpawner: add `req_gres` to specify `-go-res`.
2728

2829
Added (developer)
2930

batchspawner/batchspawner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ class SlurmSpawner(UserEnvMixin,BatchSpawnerRegexStates):
598598
{% if partition %}#SBATCH --partition={{partition}}
599599
{% endif %}{% if runtime %}#SBATCH --time={{runtime}}
600600
{% endif %}{% if memory %}#SBATCH --mem={{memory}}
601+
{% endif %}{% if gres %}#SBATCH --gres={{gres}}
601602
{% endif %}{% if nprocs %}#SBATCH --cpus-per-task={{nprocs}}
602603
{% endif %}{% if reservation%}#SBATCH --reservation={{reservation}}
603604
{% endif %}{% if options %}#SBATCH {{options}}{% endif %}
@@ -631,6 +632,10 @@ class SlurmSpawner(UserEnvMixin,BatchSpawnerRegexStates):
631632
help="Reservation name to submit to resource manager"
632633
).tag(config=True)
633634

635+
req_gres = Unicode('', \
636+
help="Additional resources (e.g. GPUs) requested"
637+
).tag(config=True)
638+
634639
# outputs line like "Submitted batch job 209"
635640
batch_submit_cmd = Unicode('sbatch --parsable').tag(config=True)
636641
# outputs status and exec node like "RUNNING hostname"

batchspawner/tests/test_spawners.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,15 @@ def test_slurm(db, io_loop):
375375
'req_prologue': 'PROLOGUE',
376376
'req_epilogue': 'EPILOGUE',
377377
'req_reservation': 'RES123',
378+
'req_gres': 'GRES123',
378379
}
379380
batch_script_re_list = [
380381
re.compile(r'PROLOGUE.*srun batchspawner-singleuser singleuser_command.*EPILOGUE', re.S),
381382
re.compile(r'^#SBATCH \s+ --cpus-per-task=5', re.X|re.M),
382383
re.compile(r'^#SBATCH \s+ --time=3-05:10:10', re.X|re.M),
383384
re.compile(r'^#SBATCH \s+ some_option_asdf', re.X|re.M),
384385
re.compile(r'^#SBATCH \s+ --reservation=RES123', re.X|re.M),
386+
re.compile(r'^#SBATCH \s+ --gres=GRES123', re.X|re.M),
385387
]
386388
from .. import SlurmSpawner
387389
run_spawner_script(db, io_loop, SlurmSpawner, normal_slurm_script,

0 commit comments

Comments
 (0)