GitPlus - A JupyterLab Extension for GitHub Integration

2 minute read

Integrating Jupyter Notebooks with GitHub has always been a challenge. First & foremost, GitHub does not render proper diffs for notebook JSON. ReviewNB helps solve this problem with rich Jupyter diffs. Secondly, even if the team decides to use GitHub for Jupyter notebooks, not every data scientist is familiar with Git commands.

There are JupyterLab extensions to help you version control notebooks with a graphical UI so you don’t need to worry about Git commands. Today, we’re going to introduce you to one such extension - JupyterLab GitPlus.

JupyterLab GitPlus

This is an open source JupyterLab extension that lets you,

Installation

Installation is pretty straightforward but you do need to provide a GitHub access token for the extension to be able to push commits & open pull request.

After the installation process, open your local JupyterLab. If everything goes smoothly, you will see a new extension called Git-Plus in the menu panel as shown below -

How to push commits

It’s really simple -

  1. Navigate to the GitHub repository in JupyterLab (the repository needs to have been cloned beforehand)
  2. Open the notebook, make your changes, save the changed notebook.
  3. Go to menu Git-Plus -> Push Commit

  4. Select Repository

  5. Select Files

  6. Provide commit message

  7. Commit is pushed. You can click on the link to review the commit diff on GitHub or ReviewNB as shown below.

ReviewNB provides you rich diffs so you can easily track changes in a Jupyter Notebook commit. Example screenshot below.

How to Create Pull Request

Pull Requests are useful for discussion & feedback on the changes before merging them into the master.

  1. Navigate to the GitHub repository in JupyterLab (the repository needs to have been cloned beforehand)
  2. Open the notebook, make your changes, save the changed notebook.
  3. Go to menu Git-Plus -> Create Pull Request

  4. Select Repository

  5. Select Files

  6. Provide Pull Request title & commit message

  7. Pull Request created. You can click on the link to review the pull request diff on GitHub or ReviewNB

While GitHub does not provide a way to discuss notebook changes easily, you can do so with ReviewNB. It shows you rich notebook diffs and lets you comment on a notebook cell or line.

Conclusion

We’ve seen how you can use JupyterLab GitPlus to push GitHub commits & create pull requests directly from the Jupyter UI. There’s also a JupyterLab Git extension which helps with many other Git operations.

We’ve also seen how you can use ReviewNB for rich notebook diffs and discussion on Jupyter Notebook pull requests.