Skip to content
Snippets Groups Projects
Commit 257a7389 authored by Sofiane Bendoukha's avatar Sofiane Bendoukha
Browse files

Added first support for singularity.

parent 6c86102e
No related branches found
No related tags found
No related merge requests found
...@@ -93,6 +93,11 @@ SJ_INCFILE="" ...@@ -93,6 +93,11 @@ SJ_INCFILE=""
# where jupyter is running need a shared home file system. # where jupyter is running need a shared home file system.
readonly SJ_FRONTEND_HOST="mistralpp.dkrz.de" readonly SJ_FRONTEND_HOST="mistralpp.dkrz.de"
# Image
#
# start the jupyter notebook in a singularity container from a given
# image name.
SJ_IMAGE=""
function clean_up () { function clean_up () {
trap - ERR EXIT trap - ERR EXIT
...@@ -136,13 +141,14 @@ Available values for OPTION include: ...@@ -136,13 +141,14 @@ Available values for OPTION include:
-p partition run job on partition -p partition run job on partition
-t time job runtime -t time job runtime
-u username use username for login -u username use username for login
-s image singularity image
EOF EOF
} }
function parse_options () { function parse_options () {
local option local option
while getopts 'A:c:di:n:p:t:u:' option; do while getopts 'A:c:di:n:p:t:u:s:' option; do
case ${option} in case ${option} in
A) SJ_ACCTCODE="$OPTARG" A) SJ_ACCTCODE="$OPTARG"
;; ;;
...@@ -160,6 +166,8 @@ function parse_options () { ...@@ -160,6 +166,8 @@ function parse_options () {
;; ;;
u) SJ_USERNAME="$OPTARG" u) SJ_USERNAME="$OPTARG"
;; ;;
s) SJ_IMAGE="$OPTARG"
;;
?) usage ?) usage
exit 1 exit 1
;; ;;
...@@ -173,6 +181,7 @@ function parse_options () { ...@@ -173,6 +181,7 @@ function parse_options () {
readonly SJ_PARTITION readonly SJ_PARTITION
readonly SJ_RUNTIME readonly SJ_RUNTIME
readonly SJ_USERNAME readonly SJ_USERNAME
readonly SJ_IMAGE
} }
function ssh_frontend () { function ssh_frontend () {
...@@ -206,16 +215,19 @@ function which_jupyter() { ...@@ -206,16 +215,19 @@ function which_jupyter() {
local which local which
which="$(source_incfile "which jupyter")" which="$(source_incfile "which jupyter")"
ssh_frontend "/bin/bash -lc \"${which}\"" ssh_frontend "/bin/bash -lc \"${which}\""
} }
function assemble_commandline () { function assemble_commandline () {
local logfile="$1" local logfile="$1"
local commandline="jupyter ${SJ_COMMAND} --no-browser 2>> ${logfile}" local commandline="jupyter ${SJ_COMMAND} --no-browser 2>> ${logfile}"
# If we are not running a job, we have to perform our own scheduling # If we are not running a job, we have to perform our own scheduling
if [[ -z ${SJ_ACCTCODE} ]]; then if [[ -z ${SJ_ACCTCODE} ]]; then
commandline="nohup ${commandline} > /dev/null & echo \$!" commandline="nohup ${commandline} > /dev/null & echo \$!"
fi fi
if [[ -n ${SJ_IMAGE} ]]; then
commandline="singularity exec ${SJ_IMAGE} ${commandline}"
fi
commandline="$(source_incfile "${commandline}")" commandline="$(source_incfile "${commandline}")"
echo "${commandline}" echo "${commandline}"
} }
...@@ -342,6 +354,7 @@ function main () { ...@@ -342,6 +354,7 @@ function main () {
trap clean_up INT QUIT TERM ERR EXIT trap clean_up INT QUIT TERM ERR EXIT
echo "Establishing ssh master connection." echo "Establishing ssh master connection."
set -x
# Set up control master for connection sharing # Set up control master for connection sharing
mkdir -p "${HOME}/.ssh" mkdir -p "${HOME}/.ssh"
ssh_socket_dir="$(mktemp -d "${HOME}/.ssh/socket.XXXXX")" ssh_socket_dir="$(mktemp -d "${HOME}/.ssh/socket.XXXXX")"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment