Commit de97fe49 authored by Willi Rath's avatar Willi Rath

Merge branch 'potential-jobscript-fix' into 'master'

Jobscript fixes

See merge request !37
parents 7d6e8920 11415aee
......@@ -152,7 +152,6 @@ With [`nesh-linux-cluster-jupyterlab.sh`](job-scripts/nesh-linux-cluster-jupyter
```shell
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 <batch-class>
......
......@@ -30,11 +30,15 @@ if [ -n "${1}" ]; then
cat ${ofile} | grep -m1 -e 'token' || echo 'Jupyter Lab not yet properly running... please wait.'
fi
else
# Sets JupyterLab base directory.
cd ${HOME}
# Will be fetched by above scontrol commands.
echo "host $(hostname)"
# Properly initialize non-interactive Bash shell.
# Works only for conda>=4.6 set up with `${HOME}/miniconda3/bin/conda init bash`
eval "$(conda shell.bash hook)"
# Activate JupyterLab environment
conda activate base && \
# Launch JupyterLab instance
jupyter lab --ip=$(hostname) --no-browser
# for conda versions below 4.6 use
# source $HOME/miniconda3/bin/activate base && \
# jupyter lab --ip=$(hostname) --no-browser
fi
#!/bin/bash
#PBS -N jupyterlab -o jupyterlab.out -j o
#!/usr/bin/env bash
#PBS -N jupyterlab -o jupyterlab.%s.log -j o
#
# NEC frontends
# Frontends
#
# ./nesh-linux-cluster-jupyterlab.sh
# $ ./nesh-linux-cluster-jupyterlab.sh
#
# workflow for NEC Linux cluster:
# ```
# $ 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 <batch-class>
# Linux cluster
#
# $ qsub nesh-linux-cluster-jupyterlab.sh -l elapstim_req=<hh:mm:ss> -l cpunum_job=<cpu-no> -l memsz_job=<mem-size> -q <batch-class>
# $ ./nesh-linux-cluster-jupyterlab.sh <jobid>
# $ qdel <jobid> # free resources after you are done!
# ```
# $ qdel <jobid> # free cluster resources after you are done!
#
#
#
# short example:
# ```
# $ qsub nesh-linux-cluster-jupyterlab.sh -l elapstim_req=00:05:00 -b 1 -l cpunum_job=4 -l memsz_job=8gb -q clmedium
# Example request
#
# $ qsub nesh-linux-cluster-jupyterlab.sh -l elapstim_req=00:05:00 -l cpunum_job=4 -l memsz_job=8gb -q clmedium
# Request 134408.nesh-batch submitted to queue: clmedium.
#
# $ ./nesh-linux-cluster-jupyterlab.sh 134408
# 4.53 minutes remaining elapse time at host neshcl305
# 4.53 minutes remaining at execution host neshcl305
# [I 16:38:35.025 LabApp] http://neshcl305:8889/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# $ qdel 134408
# Request 134408.nesh-batch was deleted.
# ```
#
if [ -n "${1}" ]; then
qstat ${1} | grep -q "does not exist" && { echo "Job does not exist..."; exit; }
status=$(qstat ${1} -f | echo $(string=$(grep 'Current State'); echo ${string##* }))
if [ "$status" == 'Queued' ]; then
echo $(qstat ${1} -f | echo "$(grep 'Planned Start Time')")
else
remote_host=$(qcat -o -b -n25 ${1} | grep -m1 -e 'host'); remote_host=${remote_host//'host '}
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 properly running... please wait.'
echo "$(bc) minutes remaining at execution host ${remote_host}" &&
qcat -o -b -n25 ${1} | grep -m1 -e "://${remote_host}:" || echo 'JupyterLab not yet properly running... please wait.'
fi
else
cd $PBS_O_WORKDIR
# Sets JupyterLab base directory.
cd ${HOME}
# Will be fetched by above qstat commands.
echo "host $(hostname)"
# ensure bashrc is sourced
if [ -f ~/.bashrc ]; then
. ~/.bashrc;
fi
# Properly initialize non-interactive Bash shell.
# Works only for conda>=4.6 set up with `${HOME}/miniconda3/bin/conda init bash`
eval "$(conda shell.bash hook)"
# Activate JupyterLab environment
conda activate base && \
jupyter lab --ip=$(hostname) --no-browser
# for conda versions below 4.6 use
# source $HOME/miniconda3/bin/activate base && \
# jupyter lab --ip=$(hostname) --no-browser
# Launch JupyterLab instance
jupyter lab --ip=$(hostname) --no-browser
fi
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