-
Notifications
You must be signed in to change notification settings - Fork 0
/
jpstart.sh
executable file
·59 lines (49 loc) · 1.55 KB
/
jpstart.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
#!/bin/bash
# Removing the temporary files (temperr contains the IP Address)
JUPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
echo "Jupyter directory = $JUPDIR"
cd ~/
while [ -s $JUPDIR/juperr ]; do
rm $JUPDIR/juperr
done
while [ -s $JUPDIR/jupout ]; do
rm $JUPDIR/jupout
done
touch $JUPDIR/juperr
touch $JUPDIR/jupout
JOBIDFILE="$JUPDIR/.jupyter_jobid"
IPFILE="$JUPDIR/.jupyter_ipaddr"
INSTFILE="$JUPDIR/.jupyter_instance_type"
echo "Choose jupyter lab instance type:"
echo "[1] compute cluster (PBS script)"
echo "[2] compute cluster (slurm script)"
echo "[3] remote instance (desktop)"
echo "-------------------------------------"
read INSTANCETYPE
if [ $INSTANCETYPE == '1' ]; then
echo "Running jupyter on compute cluster (PBS)"
# Submitting PBS job to run jupyter notebook
JOBIDFULL=`qsub $JUPDIR/jupyter_start.pbs`
elif [ $INSTANCETYPE == '3' ]; then
echo "Running remote jupyter instance on desktop"
JOBIDFULL=`bash $JUPDIR/remote_jupyter.sh`
else
echo "Running jupyter instance on compute cluster (slurm)"
echo "Instance type not found"
exit 1
fi
echo -n "Initializing Jupyter notebook ..."
while ! [ -s $JUPDIR/juperr ]; do
echo -n ".."
sleep 2
done
sleep 5
echo "Jupyter notebook started"
JOBID=`echo $JOBIDFULL | awk -F. '{print $1}'`
IPADDR=`awk '/http/ {print $4}' $JUPDIR/juperr | cut -c 8- | sed 's/.$//' | rev | cut -c 6- | rev`
# Writing jobID in file (to be able to delete job later)
echo "$JOBID" > $JOBIDFILE
echo "$IPADDR" > $IPFILE
echo "$INSTANCETYPE" > $INSTFILE
echo "jobID = $JOBID"
echo "IPaddr = $IPADDR"