-
Notifications
You must be signed in to change notification settings - Fork 0
/
jupyterlab.sh
executable file
·96 lines (83 loc) · 2 KB
/
jupyterlab.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#SBATCH --job-name=jupyter
#SBATCH --partition=pe2
#SBATCH --time=7-00:00:00
#SBATCH --cpus-per-task=24
#SBATCH --mem=64G
#SBATCH --output=/gpfs/commons/home/khadi/jupyter.log
# module unload python
# module load python/3.9.7
set -a
export thisport=8888
export notebook_directory="sadlfksdfglkhasdlfkhsdfglk_34243987562938472938476_/sdflgkhasdflkjasdglkhsdflkjhdsalkjh123498340957_"
export browser=false
export core=false
export datarate=10000000 ## don't set this too high
export max_size=24000000000
while (( "$#" )); do
case "$1" in
-p|--port)
thisport=$2
shift
shift
;;
-n|--ndir)
notebook_directory=$2
shift
shift
;;
-b|--browser)
browser=true
shift
;;
-c|--core)
core=true
shift
;;
--max_size)
max_size=$2
shift
shift
;;
--datarate)
datarate=$2
shift
shift
;;
--)
shift
break
;;
-*|--*=)
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*)
break
;;
esac
done
dt=$(date +%Y%m%d_%H%M%S)
# host_name=$(cat /etc/hosts | awk '{if (NR == 6) print $2}')
host_name=$(hostname)
log_file=jupyter_${host_name}_${dt}.log
[ -d ${notebook_directory} ] && addon="--notebook-dir ${notebook_directory}"
${core} && addon="${addon} --core-mode"
addon="${addon} --ServerApp.max_buffer_size=${max_size} --NotebookApp.max_buffer_size=${max_size} --ServerApp.iopub_data_rate_limit=${datarate} --NotebookApp.iopub_data_rate_limit=${datarate}"
cat /etc/hosts | tee ${log_file}
echo "see log file"
echo "${log_file}"
if ${browser}; then
set -x
jupyter lab --ip=0.0.0.0 --port=${thisport} \
${addon} \
2>&1 | tee -a ${log_file}
set +x
else
set -x
jupyter lab --ip=0.0.0.0 --port=${thisport} \
${addon} \
--no-browser \
2>&1 | tee -a ${log_file}
set +x
fi