@ -13,7 +13,7 @@ trap clean_up EXIT
set -m
set -m
OPT_HEADLESS=
HAS_TIME=
HAS_TIME=
process_args() {
process_args() {
@ -24,7 +24,12 @@ process_args() {
(-t|--time|--time=*)
(-t|--time|--time=*)
HAS_TIME=yes
HAS_TIME=yes
;;
;;
(-h|--headless)
OPT_HEADLESS=yes
continue
;;
esac
esac
SLURM_ARGS=( "${SLURM_ARGS[@]}" "$arg" )
done
done
# FIXME: Can do more thorough arg checking later.
# FIXME: Can do more thorough arg checking later.
}
}
@ -73,8 +78,8 @@ if [ -z "$(which jupyter-notebook)" ]; then
fi
fi
# FIXME::
# FIXME::
SLURM_ARGS=( "$@" )
SLURM_ARGS=( )
process_args "${SLURM_ARGS[ @]} "
process_args "$@"
echo
echo
if [ x"$HAS_TIME" != xyes ]; then
if [ x"$HAS_TIME" != xyes ]; then
@ -90,7 +95,7 @@ echo " * launching jupyter notebook server"
(srun -n 1 -c 2 -J juypter "${SLURM_ARGS[@]}" jupyter-notebook --no-browser --port=$((8000 + $RANDOM % 1000)) --ip=0.0.0.0 2>&1 | tee $jupyter_output > /dev/null) &
(srun -n 1 -c 2 -J juypter "${SLURM_ARGS[@]}" jupyter-notebook --no-browser --port=$((8000 + $RANDOM % 1000)) --ip=0.0.0.0 2>&1 | tee $jupyter_output > /dev/null) &
echo " * waiting for Jupyter server to be ready ..."
echo " * waiting for Jupyter server to be ready ..."
for ((i=0; i < 12 0; ++i)); do
for ((i=0; i < 60 0; ++i)); do
tokens=$(awk -F: '/ http:/ {print $3}' $jupyter_output)
tokens=$(awk -F: '/ http:/ {print $3}' $jupyter_output)
if [ -n "$tokens" ]; then
if [ -n "$tokens" ]; then
break
break
@ -119,7 +124,7 @@ url="http://$host:$tokens"
echo " * SLURM job ID: $job_id"
echo " * SLURM job ID: $job_id"
if [ -n "$DISPLAY" ]; then
if [[ -n "$DISPLAY" && "$OPT_HEADLESS" != yes ] ]; then
echo " * launching browser"
echo " * launching browser"
(firefox $url 2>&1 )>/dev/null &
(firefox $url 2>&1 )>/dev/null &
echo " if you close your browser, please the link use below to connect back"
echo " if you close your browser, please the link use below to connect back"