To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 33da5332 authored by João Sousa's avatar João Sousa
Browse files

Added the option to choose the cluster directory

parent 7553333b
......@@ -31,19 +31,20 @@ fi
# function to print usage instructions
function print_usage {
echo -e "Usage:\t start_jupyter_nb.sh CLUSTER NETHZ_USERNAME NUM_CORES RUN_TIME MEM_PER_CORE\n"
echo -e "Usage:\t start_jupyter_nb.sh CLUSTER NETHZ_USERNAME NUM_CORES RUN_TIME MEM_PER_CORE CLUSTER_DIR\n"
echo -e "Arguments:\n"
echo -e "CLUSTER\t\t\t Name of the cluster on which the jupyter notebook should be started (Euler or LeoOpen)"
echo -e "CLUSTER\t\t\tName of the cluster on which the jupyter notebook should be started (Euler or Leonhard)"
echo -e "NETHZ_USERNAME\t\tNETHZ username for which the notebook should be started"
echo -e "NUM_CORES\t\tNumber of cores to be used on the cluster (<36)"
echo -e "RUN_TIME\t\tRun time limit for the jupyter notebook on the cluster (HH:MM)"
echo -e "MEM_PER_CORE\t\tMemory limit in MB per core\n"
echo -e "MEM_PER_CORE\t\tMemory limit in MB per core"
echo -e "CLUSTER_DIR\t\tCluster folder directory where Jupyter notebook will run (Default: /cluster/home/NETHZ_USERNAME/)\n"
echo -e "Example:\n"
echo -e "./start_jupyter_nb.sh Euler sfux 4 01:20 2048\n"
echo -e "./start_jupyter_nb.sh Leonhard josousa 4 01:20 2048 /cluster/home/josousa/Jupyter\n"
}
# if number of command line arguments is different from 5 or if $1==-h or $1==--help
if [ "$#" != 5 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
# if number of command line arguments is different from 6 or if $1==-h or $1==--help
if [ "$#" -lt 5 ] || [ "$#" -gt 6 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
print_usage
exit
fi
......@@ -59,20 +60,20 @@ CLUSTERNAME="$1"
if [ "$CLUSTERNAME" == "Euler" ]; then
CHOSTNAME="euler.ethz.ch"
PCOMMAND="new gcc/4.8.2 r/3.6.0 python/3.6.1 eth_proxy"
elif [ "$CLUSTERNAME" == "LeoOpen" ]; then
elif [ "$CLUSTERNAME" == "Leonhard" ]; then
CHOSTNAME="login.leonhard.ethz.ch"
PCOMMAND="r/3.5.1 python_cpu/3.6.4 eth_proxy"
else
echo -e "Incorrect cluster name. Please specify Euler or LeoOpen as cluster and and try again.\n"
echo -e "Incorrect cluster name. Please specify Euler or Leonhard as cluster and and try again.\n"
print_usage
exit
fi
echo -e "\nCluster: $CLUSTERNAME"
echo -e "\nCluster:\t\t$CLUSTERNAME"
# no need to do checks on the username. If it is wrong, the SSH commands will not work
USERNAME="$2"
echo -e "NETHZ username: $USERNAME"
echo -e "NETHZ username:\t\t$USERNAME"
# number of cores to be used
NUM_CORES=$3
......@@ -90,7 +91,7 @@ if [ "$NUM_CORES" -gt "36" ]; then
print_usage
exit
fi
echo -e "Jupyter notebook will run on $NUM_CORES cores"
echo -e "Number of cores:\t$NUM_CORES"
# run time limit
RUN_TIME="$4"
......@@ -101,7 +102,7 @@ if ! [[ "$RUN_TIME" =~ ^[0-9][0-9]:[0-9][0-9]$ ]]; then
print_usage
exit
else
echo -e "Run time limit set to $RUN_TIME"
echo -e "Run time limit:\t\t$RUN_TIME"
fi
# memory per core
......@@ -114,7 +115,17 @@ if ! [[ "$MEM_PER_CORE" =~ ^[0-9]+$ ]]
print_usage
exit
fi
echo -e "Memory per core set to $MEM_PER_CORE MB\n"
echo -e "Memory per core:\t$MEM_PER_CORE MB"
# Cluster folder directory
CLUSTER_DIR=$6
#check if CLUSTER_DIR is empty or not a directory
if [ -z "$6" ]; then
echo -e "\nNo cluster folder diretory supplied"
CLUSTER_DIR="/cluster/home/$USERNAME/"
fi
echo -e "Cluster folder:\t\t$CLUSTER_DIR\n"
# check if some old files are left from a previous session and delete them
echo -e "Checking for left over files from previous sessions"
......@@ -141,7 +152,7 @@ module load $PCOMMAND
export XDG_RUNTIME_DIR=
IP_REMOTE="\$(hostname -i)"
echo "Remote IP:\$IP_REMOTE" >> /cluster/home/$USERNAME/jnbip
jupyter notebook --no-browser --ip "\$IP_REMOTE" &> /cluster/home/$USERNAME/jnbinfo
jupyter notebook --no-browser --ip "\$IP_REMOTE" --notebook-dir $CLUSTER_DIR &> /cluster/home/$USERNAME/jnbinfo
ENDBSUB
# wait until jupyternotebook has started, poll every 10 seconds to check if $HOME/jupyternbinfo exists
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment