Skip to content

Include nbserverproxy or describe how to use it in the docs #111

Closed

Description

@guillaumeeb

See #80 (comment).

To prevent from doing a lot of ssh tunneling, using nbserverproxy could be helpful!

Activity

  1. guillaumeeb commented on Aug 1, 2018

    @guillaumeeb
    MemberAuthor

    Cross referencing the work of @jhamman on pangeo-data/pangeo#304 here, this already work in progress!

  2. jakirkham commented on Aug 4, 2018

    @jakirkham
    Member

    Probably worth linking this comment as well since that has a little more details about how to set it up. Not that there is much to setup at all.

  3. guillaumeeb commented on Aug 4, 2018

    @guillaumeeb
    MemberAuthor

    @jakirkham, I tried nbserverproxy with no luck, as mentionned in pangeo thread. Could you look at it to see if you're doing things differently? I'll give it another go when I have some time.

  4. raybellwaves commented on Aug 6, 2018

    @raybellwaves
    Member

    @guillaumeeb I was the same. I ended up opening an issue over there jupyterhub/jupyter-server-proxy#45 but closed it once I had the ssh solution working.

  5. guillaumeeb commented on Aug 7, 2018

    @guillaumeeb
    MemberAuthor

    Okay, so I've found the problem with my setup : Dask dashboard was bind to a given network interface, but apparently nbserverproxy was not able to proxy to this one, it was probably trying another interface, don't know why though.

    So in order to make nbserverproxy work, I add to use the trick described in #90: bind the dashboard to all interfaces.

  6. guillaumeeb commented on Aug 8, 2018

    @guillaumeeb
    MemberAuthor

    @raybellwaves, could you give another go to nbserverproxy solution, now that #119 is in master?

  7. raybellwaves commented on Aug 9, 2018

    @raybellwaves
    Member

    I haven't actually used jupyterhub before so you may want to ask someone with more experience than I. I still gave it a go though and my build notes from scratch are below. I made it as far as to 'sign up with github button' but it wasn't really responding after that

    $ conda create -n djq_nbs python=3.6
    $ conda activate dqj_nbs
    $ pip install git+https://github.com/dask/dask-jobqueue.git
    $ conda install -c conda-forge psutil jupyterhub nbserverproxy bokeh
    $ pip install install oauthenticator
    $ jupyter serverextension enable --py nbserverproxy
    $ jupyterhub --generate-config
    
    # Not sure if now needed with github login method
    $ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -subj '/CN=XX.XXX.XXX.XXX'
    # Horrible hack to get rid of bad password phrase error when starting jupyterhub ( https://github.com/jupyterhub/jupyterhub/issues/1134; https://github.com/mcollina/mosca/issues/421)
    $ cp key.pem key.old.pem
    $ openssl rsa -in key.pem -out newkey.pem
    
    # use github for logging in https://github.com/settings/applications/new
    # Setup as environmental files (in your .bashrc
    OAUTH_CALLBACK_URL=https://XX.XXX.XXX.X:8000/hub/oauth_callback
    GITHUB_CLIENT_ID=xxx
    GITHUB_CLIENT_SECRET=xxx
    
    # edit jupyterhub_config.py:
    import os
    from oauthenticator.github import GitHubOAuthenticator
    c.JupyterHub.authenticator_class = GitHubOAuthenticator
    c.MyOAuthenticator.oauth_callback_url = 'https://XX.XXX.XXX.X:8000/hub/oauth_callback'
    c.MyOAuthenticator.client_id = 'XXX'
    c.MyOAuthenticator.client_secret = 'XXX'
    c.JupyterHub.admin_access = True
    c.Authenticator.admin_users = {'GITHUBUSERNAME'}
    c.JupyterHub.ssl_key = 'newkey.pem'
    c.JupyterHub.ssl_cert = 'cert.pem'
    c.Authenticator.whitelist = {'GITHUBUSERNAME'}
    c.LocalAuthenticator.create_system_users = True
    
    $ jupyterhub --ip XX.XXX.XXX.XXX --port 8000
    
    # On laptop open https://XX.XXX.XXX.XXX:8000
    
  8. guillaumeeb commented on Aug 9, 2018

    @guillaumeeb
    MemberAuthor

    @raybellwaves ah sorry, I did not make myself clear enough. I just wanted you to test the nbserverproxy solution with your current procedure : user launched notebook. Something like that :

    pip install git+https://github.com/dask/dask-jobqueue.git
    pip install nbserverproxy
    jupyter serverextension enable --py nbserverproxy
    jupyter lab --no-browser --ip=`hostname` --port=8888
    

    Do the ssh tunneling thing to access to your notebook (and only your notebook). Then in your notebook, launch Dask using jobqueue, and go to

    http://localhost:8888/proxy/8787/status
    

    or wathever port Dask Dashboard has been launched to.

  9. raybellwaves commented on Aug 9, 2018

    @raybellwaves
    Member

    No problem. I've been meaning to try jupyterhub for a while anyway so it was a good learning experience.

    Ok. I'll give it a go later or tomorrow.

  10. raybellwaves commented on Aug 10, 2018

    @raybellwaves
    Member

    The setup worked thanks but nothing displayed in the dashboard. I tried just the notebook and jupyter lab but both gave the same response.

    pip install git+https://github.com/dask/dask-jobqueue.git
    conda install -c conda-forge psutil jupyter jupyterlab nbserverproxy widgetsnbextension ipywidgets bokeh pandas
    jupyter serverextension enable --py nbserverproxy
    jupyter notebook --no-browser --ip=`hostname` --port=8888
    
    # on laptop
    ssh -N -L 8888:`hostname`:8888 username@domain
    # open notebook in browser at http://`localhost`:8888
    # Contents of notebook is
    from dask_jobqueue import LSFCluster
    from dask.distributed import Client
    cluster = LSFCluster(cores=2, memory='2 GB')
    cluster
    # start 2 workers
    client = Client(cluster)
    client
    # open the dashboard in browser at http://`localhost`:8888/proxy/`dashboardport`/status
    

    screen shot 2018-08-10 at 12 04 46 pm

    Here's the logs from my terminal running the notebook

    [I 12:02:43.327 NotebookApp] Client sent subprotocols: []
    ERROR:asyncio:Future exception was never retrieved
    future: <Future finished exception=IndexError('list index out of range',)>
    Traceback (most recent call last):
      File "/nethome/rxb826/local/bin/miniconda3/envs/djq_nbs/lib/python3.6/site-packages/tornado/gen.py", line 326, in wrapper
        yielded = next(result)
      File "/nethome/rxb826/local/bin/miniconda3/envs/djq_nbs/lib/python3.6/site-packages/tornado/websocket.py", line 721, in _accept_connection
        self.selected_subprotocol = self.handler.select_subprotocol(subprotocols)
      File "/nethome/rxb826/local/bin/miniconda3/envs/djq_nbs/lib/python3.6/site-packages/nbserverproxy/handlers.py", line 300, in select_subprotocol
        return subprotocols[0]
    IndexError: list index out of range
    
  11. guillaumeeb commented on Aug 10, 2018

    @guillaumeeb
    MemberAuthor

    That's better.
    Were your workers started at that moment?

  12. raybellwaves commented on Aug 10, 2018

    @raybellwaves
    Member

    Yes. I just checked again.

    Actually it works now if I just click on the dashboard link

    screen shot 2018-08-10 at 4 15 36 pm

    screen shot 2018-08-10 at 4 14 18 pm

    I may do a quick test without nbserverproxy. I think your recent PR's helped my problem in #116 (comment)

  13. guillaumeeb commented on Aug 10, 2018

    @guillaumeeb
    MemberAuthor

    @raybellwaves it looks like you're not using nbserverproxy in your last comment. Is is probably as you say, just the binding to all interface that solved your problem.

    Could you try again with the http://localhost:8888/proxy/dashboardport/status URL? Maybe its what you just did and there still was a problem?

  14. raybellwaves commented on Aug 10, 2018

    @raybellwaves
    Member

    it looks like you're not using nbserverproxy in your last comment

    Correct. It seems to work without nbserverproxy for me now.

    Could you try again with the http://localhost:8888/proxy/dashboardport/status URL?

    Yes. I made sure that my jobs were running. I still get the empty dashboard as shown above
    I don't think I am missing something in the setup of the nbserverproxy?

  15. guillaumeeb commented on Aug 30, 2018

    @guillaumeeb
    MemberAuthor

    Yes. I made sure that my jobs were running. I still get the empty dashboard as shown above
    I don't think I am missing something in the setup of the nbserverproxy

    You could be on a dashboard from another cluster, maybe the dashboard port is not the right one.

  16. jakirkham commented on Aug 30, 2018

    @jakirkham
    Member

    It sounds like this is a bug fixed in master. Though downgrading should be equally effective at resolving the issue.

    xref: jupyterhub/jupyter-server-proxy#39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions