Last active
June 6, 2019 15:31
-
-
Save wflynny/34d6123813112e5a01f7c50cd944a5a0 to your computer and use it in GitHub Desktop.
Bash alias/functions to launch jupyter-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_grab_ip() { | |
jobid=$1 | |
port=$2 | |
hostname=$(qstat -f ${jobid} | grep -oP "exec_host = (\K[a-z0-9]+)") | |
echo "http://${hostname}:${port}" | |
} | |
_submit_job() { | |
queue=$1 | |
port=$2 | |
walltime="72:00:00" | |
if [ $queue == "long" ]; then | |
walltime="120:00:00" | |
fi | |
jobid=$(qsub -q $queue -l "walltime=${walltime}" -v "PORT=$port" /path/to/software/bin/jupyter-server) | |
echo $jobid | |
} | |
jup() { | |
queue=$1 | |
port=$2 | |
if [[ -z "${queue}" ]]; then | |
queue=batch | |
fi | |
if [[ -z "${port}" ]]; then | |
port=8899 | |
fi | |
jobid=$(_submit_job $queue $port) | |
echo "Launched Jupyter-Server to job: ${jobid}" | |
jobid="${jobid%%.*}" | |
echo -n "Waiting for ip address... " | |
sleep 15 | |
_grab_ip $jobid $port | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment