Tools for Sharing Jupyter Notebooks Online | by Rebecca Vickery | Towards Data Science

I recently started helping out on a new data project set up by a friend of mine. The data side of the project is an analysis piece applying some natural language processing to text-based responses from a survey. I created a Github repository for the project and completed the analysis in a Jupyter Notebook.
As part of this project, I want to be able to share the notebooks with non-programmers who won’t necessarily be set up with or familiar with Github. This is a common problem that most data scientists face.
Jupyter Notebooks are a great tool for exploratory data analysis but it is pretty common to need to share this analysis with non-programmer stakeholders in a project. Fortunately, there are a number of tools available to host notebooks online for non-Github users.
In the following article, I am going to walk through how to use three of these tools and discuss the pros and cons of each.
To test each of these tools I have created a Github repository and a sample notebook.
If you don’t already have a Github account you can create one for free. If you are unfamiliar with creating, cloning and pushing to a Github repository I have previously written a guide here.
I have created a Github Repository for testing with the following structure.
The notebooks folder contains a notebook consisting of a machine learning workflow for a Kaggle data set containing tweets labelled disaster or non-disaster. The information about this data set and the data can be found at this link.
A snapshot of the notebook can be viewed below.
Let’s now look at some methods for sharing this notebook with non-programmers.
Jupyter nbviewer is a tool created by the Jupyer community for rendering a notebook hosted on Github online.
It is extremely simple to use. Simply paste the URL to the notebook into this web page.
The notebook is now rendered via a unique link which you can share with others.
Advantages
Extremely simple to use.
Link stays active as long as the notebook remains in the same location in the Github repository.
Disadvantages
Nbviewer only renders the inputs and outputs of the notebook. The code in the link is not executable.
To cut down on rendering time nbviewer caches the output for around 10 minutes. There is, therefore, a delay in viewing any changes you make in the link.
Binder is another open-source project for sharing notebooks. Binder not only renders the inputs and outputs in the notebook but also builds a Docker image of the repository making the hosted notebook interactive.
To share the notebook navigate to this link. Unlike nbviewer you need to add the repository URL, rather than the path to the notebook, in the form as shown below. You can optionally add the path to the notebook but if left blank Binder will make the entire repository available via the link.
Binder will take a couple of minutes to build the docker image.
The notebook is now available online. Recipients of the link can view and interact with the code and outputs.
Advantages
The notebook is made available as executable code and therefore means that the recipient can reproduce and interact with your project.
Simple to use, no need to register for an account or anything.
The docker image is automatically rebuilt when a new commit is made to the repository.
Disadvantages
The Github repository needs to contain a configuration file for the Docker image. Accepted formats include environment.yml, Pipfile, requirements.txt, setup.py. Not really a disadvantage but if you don’t already work with these files this may be added complexity for you.
Jovian is a platform for tracking and collaborating on data science projects. Part of the platform is a tool for hosting Jupyter notebooks online which differs slightly from the other tools mentioned above. Jovian is open-source but also has some enterprise elements to the pricing. The free tier gives you unlimited public projects and access to 5 private projects. This is enough for quickly sharing the occasional notebook.
To upload a notebook you first have to create an account. Once signed up you need to install jovian locally on your machine in your project virtual environment. This can be installed via pip with pip install jovian .
To upload a notebook add import jovian . Once you are ready to share the notebook type the following.
jovian.commit()
This will ask for the API key which can be found on your account on the jovian.ml website.
Once you have entered the key after a few seconds you will get a “Committed Successfully!” message.
If you now go to your profile page you will see your notebook. Jovian.ml captures and uploads the python virtual environment along with the notebook so that collaborators can interact with the code.
If you navigate to the notebook you can add collaborators or use the link to share with others.
Advantages
The sharing options are suitable for both programmers and non-programmers as you have the option to simply view the static inputs and outputs, or to clone and run your own version.
Jovian allows cell level commenting and discussion which is a really nice feature.
Disadvantages
You need to have a Jovian.ml account and need to locally install jovian to share your notebooks, and therefore this tool requires a little more set up compared to the other two options.
The notebook needs to be uploaded separately to Jovian.ml so if you are using Github for version control you need to make two commits and your project will potentially be in two separate places.
This article has given an overview of three tools available to share Jupyter Notebooks online. Each tool is very useful in its own right and I would definitely use all three. However, for my purpose that I set out at the beginning of the article, which is to share the notebook with non-programmers, nbviewer is definitely the option I will choose. It is the simplest option and provides me with exactly what I need which is a view-only form of sharing.
Thanks for reading!
I send out a monthly newsletter if you would like to join please sign up via this link. Looking forward to being part of your learning journey!