nesh-linux-cluster-jupyterlab.sh 1.03 KB
Newer Older
Willi Rath's avatar
Willi Rath committed
1 2 3 4
#!/bin/bash
#PBS -N jupyterlab -o jupyterlab.out -j o

## submit with
5
# qsub nesh-linux-cluster-jupyterlab.sh -l elapstim_req=<hh:mm:ss> -b <node-no> -l cpunum_job=<cpu-no> -l memsz_job=<mem-size> -q clmedium
Willi Rath's avatar
Willi Rath committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19

## get job info and token (if running)
# ./nesh-linux-cluster-jupyterlab.sh <jobid>

if [ -n "${1}" ]; then
  status=$(qstat ${1} -f | echo $(string=$(grep 'Current State'); echo ${string##* }))
  if [ "$status" == 'Queued' ]; then
    echo $(qstat ${1} -f | echo "$(grep 'Planned Start Time') (worst case estimate)")
  else
    qstat ${1} -f | echo "scale=2; $(string=$(grep 'Remaining Elapse'); echo ${string//[!0-9]})/60" | \
    echo "$(bc) minutes remaining elapse time at" $(qcat -o -b -n25 ${1} | grep -m1 -e 'host') &&
    qcat -o -b -n25 ${1} | grep -m1 -e 'token' || echo 'Jupyter Lab not yet running...'
  fi
else
Willi Rath's avatar
Willi Rath committed
20
  cd $PBS_O_WORKDIR
Willi Rath's avatar
Willi Rath committed
21 22 23 24 25
  echo "host $(hostname)" && \
  source $HOME/miniconda3/bin/activate base && \
  jupyter lab --ip=$(hostname) --no-browser
  #jupyter lab --ip=$(ifconfig ib0 | awk '/inet / {print$2};') --no-browser
fi