Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions jupyterhub_moss/batch_script.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/bin/bash
#SBATCH --job-name=jupyterhub
#SBATCH --job-name=spawner-jupyterhub
#SBATCH --chdir={{homedir}}
#SBATCH --export={{keepvars}}
#SBATCH --get-user-env=L
#SBATCH --partition={{partition}}
{% if runtime %}#SBATCH --time={{runtime}}
{% if output %}#SBATCH --output={% if not output.startswith('/') %}{{homedir}}/{% endif %}{{output}}
{% endif %}{% if partition %}#SBATCH --partition={{partition}}
{% endif %}{% if runtime %}#SBATCH --time={{runtime}}
{% endif %}{% if memory %}#SBATCH --mem={{memory}}
{% endif %}{% if gres %}#SBATCH --gres={{gres}}
{% endif %}{% if nprocs %}#SBATCH --cpus-per-task={{nprocs}}
{% endif %}{% if mem %}#SBATCH --mem={{mem}}
{% endif %}{% if reservation%}#SBATCH --reservation={{reservation}}
{% endif %}{% if exclusive %}#SBATCH --exclusive
{% endif %}{% if not output %}#SBATCH --output=/dev/null
{% endif %}{% if options %}#SBATCH {{options}}
{% endif %}
{% endif %}{% if options %}#SBATCH {{options}}{% endif %}

set -euo pipefail

trap 'echo SIGTERM received' TERM
{{prologue}}
{{cmd}}
which jupyterhub-singleuser
{% if srun %}{{srun}} {% endif %}{{cmd}}
echo "jupyterhub-singleuser ended gracefully"
{{epilogue}}
14 changes: 11 additions & 3 deletions jupyterhub_moss/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,21 @@ def __update_options(self, options, partition_info):

The options dict is updated.
"""
# Align names with sbatch script
if "mem" in options:
options["memory"] = options["mem"]

# Convert output option from boolean to file pattern
is_output = options.get("output", False)
options["output"] = "slurm-%j.out" if is_output else "/dev/null"

# Specific handling of exclusive flag
# When mem=0 or all CPU are requested, set the exclusive flag
# When memory=0 or all CPU are requested, set the exclusive flag
if (
options.get("nprocs") == partition_info["max_nprocs"]
or options.get("mem") == "0"
or options.get("memory") == "0"
):
options["exclusive"] = True
options["options"] = f"--exclusive {options.get('options', '')}"

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