Sharing Jupyter Notebooks using GitHub

Overview

Teaching: 10 min
Exercises: 20 min
Questions
  • How can I share my work outside of publishing in a traditional journal?

  • How can I use GitHub for sharing Jupyter notebooks online?

Objectives
  • Create a repository on GitHub to share your Jupyter Notebook online.

  • Describe the features GitHub provides that enhance its utility for online sharing.

  • Describe GitHub’s limitations for sharing Jupyter Notebooks.

Important notice

This lesson has been taken from https://reproducible-science-curriculum.github.io/sharing-RR-Jupyter/ and is distributed under the Creative Commons Attribution license. The following is a human-readable summary of (and not a substitute for) the full legal text of the CC BY 4.0 license.

Publishing to Github Gist

Share your jupyter dashboards online using Github

In this lesson we will learn:

GitHub

GitHub is a development platform where we “can host and review code, manage projects, and build software.” GitHub hosts source code for 75+ million projects including the pandas package we have been using among many others.

Make sure you have a (free) account otherwise follow our setup instructions.

1. Create a new repository

github-selecting-new-repo.png

Create a new repository:

  • Add a repository name. We choose to name our repository jupyter-dashboard.
  • Personal GitHub accounts require that projects be public.
  • Check the Initialize this repository with a README option.
  • Add a license (for instance BSD 2-Clause “Simplified” License or BSD 3-Clause or MIT license)
  • Click the green Create repository button.

github-new-repo-jupyter-dashboard.png

Congratulations!! We now have created our repository for hosting our jupyter dashboards!

2. Upload our previous working notebook to the repository

In anticipation of our next lesson on sharing using the capability of Binder, we need to upload the notebook that we have been working on.

In our new repository, we will click on the Upload file button as shown below. github-uploading-file.png

Upload our file:

  • Drag and drop the data analysis notebook completed in the previous lesson or click the choose your files link to select the notebook.
    • We will see any files that we have uploaded at the bottom of the drag and drop area.
  • Add a message describing the change we are about to make.
    • Typing “Map and 2D plot data Finse research center” in the subject field.
    • We can either add the same message below in the extended description or leave it blank.
  • Click on Commit changes button to complete the upload.

After commiting the change we should see that there are now three files in the repository: 1) the README and 2) the LICENSE and 3) our dashboard_finse.

github-jupyter-dashboard-uploaded.png

Authoring & Citation

In addition to LICENSE, it is recommended to add:

List of authors

A GitHub repository is very often created by an individual user so adding the list of authors is very important.

Add a new file AUTHORS in your repository

  • Go to your repository in your web browser
  • Click on “Create new file” and name your file AUTHORS
  • Add the list of authors/contributors and commit your changes

Make your GitHub repository citable (DOI)

Your GitHub repository contains your scientific workflow, your programs/software, datasets (or links to your datasets) and jupyter dashboards so it is important to make the work you share on GitHub citable by archiving your GitHub repository to get a DOI. You may have a Data archive in your University or you may use the data archiving tool Zenodo.

Login to Zenodo

Source: https://guides.github.com/activities/citable-code/zenodo-authorize.png

Get a DOI for your Github repository

Then

Your GitHub repository is now linked to Zenodo and you will automatically get a DOI:

Add your DOI to your GitHub repository

Limitations

Sharing your GitHub repository along with your jupyter notebooks/dashboards is an important step for making your research reproducible. However, anyone willing to rerun your programs/dashboards/notebooks need to get the same computational environment (python, additional python packages, etc.).

The next section (using Binder) will show you how to make your research fully reproducible, offering users the same computational environment with no efforts.

Where to find more about GitHub

To learn more about GitHub you can review one or more of these additional (external) resources:

More about Git version control

If you would like to learn about source code version control using the git software, the git in GitHub, please see these resources:

  • Try this 15 minute interactive git tutorial
  • Try some additional git exercises here

Key Points

  • GitHub is a development platform where we “can host and review code, manage projects, and build software.

  • A GitHub repository can be created, populated, and shared without command line or other special-purpose version control tools.

  • Jupyter Notebooks shared through GitHub are rendered, but are static. GitHub does not run the notebook(s) in a repository.