diff --git a/turing/calculations/launch_jupyter b/turing/calculations/launch_jupyter index 57b1d22..dcd5c92 100755 --- a/turing/calculations/launch_jupyter +++ b/turing/calculations/launch_jupyter @@ -13,7 +13,7 @@ trap clean_up EXIT set -m - +OPT_HEADLESS= HAS_TIME= process_args() { @@ -24,7 +24,12 @@ process_args() { (-t|--time|--time=*) HAS_TIME=yes ;; + (-h|--headless) + OPT_HEADLESS=yes + continue + ;; esac + SLURM_ARGS=( "${SLURM_ARGS[@]}" "$arg" ) done # FIXME: Can do more thorough arg checking later. } @@ -73,8 +78,8 @@ if [ -z "$(which jupyter-notebook)" ]; then fi # FIXME:: -SLURM_ARGS=( "$@" ) -process_args "${SLURM_ARGS[@]}" +SLURM_ARGS=( ) +process_args "$@" echo 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) & echo " * waiting for Jupyter server to be ready ..." -for ((i=0; i < 120; ++i)); do +for ((i=0; i < 600; ++i)); do tokens=$(awk -F: '/ http:/ {print $3}' $jupyter_output) if [ -n "$tokens" ]; then break @@ -119,7 +124,7 @@ url="http://$host:$tokens" echo " * SLURM job ID: $job_id" -if [ -n "$DISPLAY" ]; then +if [[ -n "$DISPLAY" && "$OPT_HEADLESS" != yes ]]; then echo " * launching browser" (firefox $url 2>&1 )>/dev/null & echo " if you close your browser, please the link use below to connect back"