Consulting about how to use Jupyter Notebook+ JupyterHub

317 views
Skip to first unread message

nju08e...@gmail.com

unread,
Mar 11, 2016, 2:24:17 AM3/11/16
to Project Jupyter
Hi all,

      I am Yalan, a software engineer, recently I am investigating into how to deploy Jupyter notebook in our cluster. here are some issues that I encountered when dealing withJupyter:
 
#1 Do we have a way to install Jupyter without internet access? I know that originally IPython can be installed by "python setup.py install" using its tarball, does Jupyter have the similar way? since pip really needs network access.
 
#2 We need to add authentication to many notebooks with many users, I know from official site that we can use JupyterHub to integrate pluggable authentication into it, however, we need to customize an authenticator, but we really don't know where to put the authenticator. I saw some example as the Google anthenticator https://github.com/ryanlovett/jh-google-oauthenticator, do we also need to develop a plugin like that and then use "python setup.py install" to install the anthenticator module and then do the setting in config file?

#3 One confusion about how to user JupyterHub is that do we need to firstly install Jupyter notebook when using JupyterHub, if so, what's the mechanism about  how theJupyterHub will build connection with multiple notebooks with different users, as far as I know, Jupyter notebook has its own config file, and JupyterHub also has its own config file, through the website's hint, I can not see any connecntions between the two files, then how the they can communicate with each other that this jupyter server corresponds to this user?

Really hope you can help me erase these confusions,thanks you in advance and looking forward to your reply!

MinRK

unread,
Mar 11, 2016, 4:21:26 AM3/11/16
to jup...@googlegroups.com

On Fri, Mar 11, 2016 at 8:24 AM, <nju08e...@gmail.com> wrote:

Hi all,

      I am Yalan, a software engineer, recently I am investigating into how to deploy Jupyter notebook in our cluster. here are some issues that I encountered when dealing with Jupyter:
 
#1 Do we have a way to install Jupyter without internet access? I know that originally IPython can be installed by "python setup.py install" using its tarball, does Jupyter have the similar way? since pip really needs network access.

You can use pip without network access. Here is an example. If you download all the wheels or tarballs you need, you can put them in a directory for pip to look in instead of pip. JupyterHub does have one nodejs dependency, and you can do offline installs of nodejs packages with npmbox.

This script will fetch all of the dependencies for JupyterHub (including single-user servers) for offline installation:

#!/usr/bin/env bash
# Script to fetch all dependencies of JupyterHub for offline installation
set -ex

python3 -m venv wheel-env
source wheel-env/bin/activate

pip install --upgrade setuptools pip wheel
mkdir jupyterhub-offline && cd jupyterhub-offline
# notebook only required if single-user servers are to be on the same system
# alternately, you can use a `requirements.txt` here.
pip install jupyterhub notebook
# record all the packages we have installed, including dependencies in a new requirements.txt
pip freeze > jupyterhub-requirements.txt
# Build wheel directory from requirements file:
pip wheel -r jupyterhub-requirements.txt -w wheels

# Now do the same for our javascript dependency:
npm install -g npmbox
npmbox configurable-http-proxy

echo "\n\nJupyterHub offline install resources in $PWD:"
tree

 
#2 We need to add authentication to many notebooks with many users, I know from official site that we can use JupyterHub to integrate pluggable authentication into it, however, we need to customize an authenticator, but we really don't know where to put the authenticator. I saw some example as the Google anthenticator https://github.com/ryanlovett/jh-google-oauthenticator, do we also need to develop a plugin like that and then use "python setup.py install" to install the anthenticator module and then do the setting in config file?

Yes, if your authentication system is not covered by any of the existing implementations, you will need to write a custom Authenticator. An Authenticator is any importable class, so you would install your custom authenticator like any other Python package.

If this is a simple username/password system, you only need to define one method:


from jupyterhub.auth import Authenticator
from tornado.gen import coroutine

class MyAuthenticator(Authenticator):
    @coroutine
    def authenticate(self, handler, data):
        username = data['username']

        password = data['password']
        if my_check_password(username, password):
            return username

Then you can tell JupyterHub to use your Authenticator in your jupyterhub_config.py:

c.JupyterHub.authenticator_class = 'myauthenticator.MyAuthenticator'


#3 One confusion about how to user JupyterHub is that do we need to firstly install Jupyter notebook when using JupyterHub,

think one reason there is confusion is that the answer is: it depends. At a high level, yes, you do need Jupyter Notebook to run JupyterHub. What JupyterHub aims to do is to make it easier to spawn single-user Jupyter Notebook instances on behalf of users, and authenticate with a central system. The Hub itself is only the mechanism for providing:

  1. authentication of users
  2. how/where those single-user servers should be started

Whether you need to install the notebook package in the same place as the Hub depends on how you intend to run the single-user servers. If you are running it all on a single local machine with real users, then yes, you do need to install the notebook in the same place as the Hub. If, instead, you are running single-user servers in Docker containers, then no, notebook is not required where the Hub is running, only in the docker containers.

if so, what's the mechanism about  how theJupyterHub will build connection with multiple notebooks with different users, as far as I know, Jupyter notebook has its own config file, and JupyterHub also has its own config file, through the website's hint, I can not see any connecntions between the two files, then how the they can communicate with each other that this jupyter server corresponds to this user?

When JupyterHub starts a single-user server, it doesn’t call jupyter notebook directly. It runs a script called jupyterhub-singleuser which instantiates a subclass of the normal notebook server. The main modification this subclass makes is to add authentication via the Hub for identifying users.


Really hope you can help me erase these confusions,thanks you in advance and looking forward to your reply!

Hope that helps,

-MinRK

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/ef571f1d-2596-4747-aa45-1f8595a5e4a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages