ncar-xdev / jupyter-forward

Launch Jupyter Lab over SSH with a single command!
https://jupyter-forward.readthedocs.io/
Apache License 2.0
31 stars 12 forks source link

Parsing hang fix #152

Closed kmpaul closed 2 years ago

kmpaul commented 2 years ago

Change Summary

This PR fixes the problem referenced in #148, and it includes a mild refactor. This PR changes the run_command method to accept an asynchronous argument and skip error checking / early exit when True. Then, to assure that the arguments to the self.shell part of the remote command are correct (i.e., uses -lc when not using csh-style shells), the call to remotely launch Jupyter Lab is sent using run_command, to be consistent with all other remote commands used throughout Jupyter Forward.

Related issue number

Closes #148

Checklist

It is my belief that this change is internal and doesn't need additional documentation.

A test of the run_command method should be added to test the asynchronous argument.

rsignell-usgs commented 2 years ago

Tested it on Windows 10 WSL2, works great -- opens browser tab and everything!

$ jupyter-forward rsignell@denali --launch-command "srun -A woodshole -N 1 -t 00:30:00" --conda-env pangeo --port 8889
************************************************************************************** Authenticating **************************************************************************************
Authenticating user (rsignell) from client (IGSAGIEGLTRSI10) to remote host (denali.cr.usgs.gov)
✅ The client is authenticated successfully
********************************************************************************* Verifying shell location *********************************************************************************
✅ Using shell: /bin/bash
****************************************************************************** Running jupyter sanity checks *******************************************************************************
/bin/bash -lc "source activate pangeo && which jupyter"
/home/rsignell/miniconda3/bin/jupyter
*************************************************************************  Creating log file on denali.cr.usgs.gov *************************************************************************
/bin/bash -lc "printenv TMPDIR"
/bin/bash -lc "printenv HOME"
/home/rsignell
/bin/bash -lc "touch $HOME/foobar && rm -rf $HOME/foobar && echo '$HOME is WRITABLE' || echo '$HOME is NOT WRITABLE'"
/home/rsignell is WRITABLE
/bin/bash -lc "mkdir -p $HOME/.jupyter_forward"
✅ Log directory is set to $HOME/.jupyter_forward
/bin/bash -lc "touch $HOME/.jupyter_forward/log_2022-03-26T07-15-14.txt"
✅ Log file is set to $HOME/.jupyter_forward/log_2022-03-26T07-15-14.txt
******************************************************************************** Preparing Batch Job script ********************************************************************************
/bin/bash -lc "echo -n '#!' > $HOME/.jupyter_forward/batch_job_script_2022-03-26T07-15-14"
/bin/bash -lc "echo /bin/bash -l >> $HOME/.jupyter_forward/batch_job_script_2022-03-26T07-15-14"
/bin/bash -lc "echo 'source activate pangeo && jupyter lab --no-browser --ip=\$(hostname -f) > $HOME/.jupyter_forward/log_2022-03-26T07-15-14.txt 2>&1' >> $HOME/.jupyter_forward/batch_job_script_2022-03-26T07-15-14"
/bin/bash -lc "chmod +x $HOME/.jupyter_forward/batch_job_script_2022-03-26T07-15-14"
✅ Batch Job script resides in $HOME/.jupyter_forward/batch_job_script_2022-03-26T07-15-14
********************************************************************************** Launching Jupyter Lab ***********************************************************************************
/bin/bash -lc "srun -A woodshole -N 1 -t 00:30:00 $HOME/.jupyter_forward/batch_job_script_2022-03-26T07-15-14"
******************************************************************************** Setting up port forwarding ********************************************************************************
remote_host: nid00025, remote_port: 8888, local_port: 8889
************************************************************************ Opening Jupyter Lab interface in a browser ************************************************************************
Jupyter Lab URL: http://localhost:8889
*********************************************************************************************  *********************************************************************************************
/bin/bash -lc "tail -f $HOME/.jupyter_forward/log_2022-03-26T07-15-14.txt"
[I 2022-03-26 06:16:13.500 ServerApp] jupyter_server_proxy | extension was successfully loaded.
[I 2022-03-26 06:16:13.501 LabApp] JupyterLab extension loaded from /home/rsignell/miniconda3/lib/python3.9/site-packages/jupyterlab
[I 2022-03-26 06:16:13.501 LabApp] JupyterLab application directory is /home/rsignell/miniconda3/share/jupyter/lab
[I 2022-03-26 06:16:13.505 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-03-26 06:16:13.506 ServerApp] Serving notebooks from local directory: /home/rsignell
[I 2022-03-26 06:16:13.506 ServerApp] Jupyter Server 1.13.4 is running at:
[I 2022-03-26 06:16:13.506 ServerApp] http://nid00025:8888/lab
[I 2022-03-26 06:16:13.506 ServerApp]  or http://127.0.0.1:8888/lab
rsignell-usgs commented 2 years ago

@kmpaul or @andersy005, could we cut a new release so folks can install from conda-forge?

andersy005 commented 2 years ago

@rsignell-usgs, the latest version is available on PyPI. it might take a while for it to be available on conda-forge