Skip to content

Commit 08ea294

Browse files
authored
Merge pull request #86 from silx-kit/update-sbatch-script
Make sbatch script as close as possible as the default one
2 parents f37bf0c + b4f831f commit 08ea294

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

jupyterhub_moss/batch_script.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/bin/bash
2-
#SBATCH --job-name=jupyterhub
2+
#SBATCH --job-name=spawner-jupyterhub
33
#SBATCH --chdir={{homedir}}
44
#SBATCH --export={{keepvars}}
55
#SBATCH --get-user-env=L
6-
#SBATCH --partition={{partition}}
7-
{% if runtime %}#SBATCH --time={{runtime}}
6+
{% if output %}#SBATCH --output={% if not output.startswith('/') %}{{homedir}}/{% endif %}{{output}}
7+
{% endif %}{% if partition %}#SBATCH --partition={{partition}}
8+
{% endif %}{% if runtime %}#SBATCH --time={{runtime}}
9+
{% endif %}{% if memory %}#SBATCH --mem={{memory}}
810
{% endif %}{% if gres %}#SBATCH --gres={{gres}}
911
{% endif %}{% if nprocs %}#SBATCH --cpus-per-task={{nprocs}}
10-
{% endif %}{% if mem %}#SBATCH --mem={{mem}}
1112
{% endif %}{% if reservation%}#SBATCH --reservation={{reservation}}
12-
{% endif %}{% if exclusive %}#SBATCH --exclusive
13-
{% endif %}{% if not output %}#SBATCH --output=/dev/null
14-
{% endif %}{% if options %}#SBATCH {{options}}
15-
{% endif %}
13+
{% endif %}{% if options %}#SBATCH {{options}}{% endif %}
1614

1715
set -euo pipefail
1816

1917
trap 'echo SIGTERM received' TERM
2018
{{prologue}}
21-
{{cmd}}
19+
which jupyterhub-singleuser
20+
{% if srun %}{{srun}} {% endif %}{{cmd}}
21+
echo "jupyterhub-singleuser ended gracefully"
22+
{{epilogue}}

jupyterhub_moss/spawner.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,21 @@ def __update_options(self, options, partition_info):
359359
360360
The options dict is updated.
361361
"""
362+
# Align names with sbatch script
363+
if "mem" in options:
364+
options["memory"] = options["mem"]
365+
366+
# Convert output option from boolean to file pattern
367+
has_output = options.get("output", False)
368+
options["output"] = "slurm-%j.out" if has_output else "/dev/null"
369+
362370
# Specific handling of exclusive flag
363-
# When mem=0 or all CPU are requested, set the exclusive flag
371+
# When memory=0 or all CPU are requested, set the exclusive flag
364372
if (
365373
options.get("nprocs") == partition_info["max_nprocs"]
366-
or options.get("mem") == "0"
374+
or options.get("memory") == "0"
367375
):
368-
options["exclusive"] = True
376+
options["options"] = f"--exclusive {options.get('options', '')}"
369377

370378
# Specific handling of ngpus as gres
371379
ngpus = options.get("ngpus", 0)

0 commit comments

Comments
 (0)