Skip to main content

JupyterLab extension to create GitHub pull requests

Project description

GitPlus

A JupyterLab plugin for version control of Jupyter notebooks. It can,

  • Push GitHub commits from JupyterLab
  • Create GitHub pull request from JupyterLab

Demo

Create GitHub Pull Request from JupyterLab

Create GitHub Pull Request from JupyterLab

Push GitHub Commits from JupyterLab

Push GitHub Commits from JupyterLab

Requirements

  • JupyterLab 2.x or 3.x
  • Git (running git on cmdline or terminal should work)

Install

1. Install Required Packages

pip install --upgrade jupyterlab_gitplus
jupyter labextension install @reviewnb/jupyterlab_gitplus
jupyter serverextension enable --py jupyterlab_gitplus

2. Setup GitHub token

Tokens are required to make API calls to GitHub to push commits and create pull requests.

  • Head over developer settings on GitHub. Click "Generate New Token".
  • Select repo scope. Click "Generate Token". Copy the generated token.
  • If ~/.jupyter/jupyter_notebook_config.py does not exist then create one by running jupyter notebook --generate-config
  • Open you Jupyter config file ~/.jupyter/jupyter_notebook_config.py & paste the token as shown below
c.GitPlus.github_token = '<your-github-access-token>'

After installation, start JupyterLab normally & you should see "Git-Plus" as a new menu item at the top.

FAQ

Where is pull request (PR) opened in case of forked repositories?

If your repository is forked from another repository (parent) then PR will be created on parent repository.

Which is the base branch used in a pull request?

base branch in a PR is a branch against which your changes are compared and ultimately merged. We use repository's default branch (usually called master) as base branch of PR. We use parent repository's default branch as base in case of forked repo.

Which is the head branch used in a pull request?

head branch in a PR is a branch which contains the latest changes you've made. We create a new branch (e.g. gitplus-xyz123) as head branch. It only contains changes from the files you wish to include in the PR.

How can I edit a pull request opened with GitPlus?

You can head over to GitHub and edit the PR metadata to your liking. For pushing additional file changes to the same PR,

  1. Copy the branch name from GitHub UI (e.g. gitplus-xyz123)
  2. Checkout that branch locally
  3. Make the file changes you want
  4. Use push commit functionality from GitPlus to push new changes

Is GitPlus tied to ReviewNB in any way?

No. GitPlus is it's own open source project. The only connection with ReviewNB is that at the end of PR/Commit creation, GitPlus shows ReviewNB URL along with GitHub URL. You can safely ignore these URLs if you don't want to use ReviewNB.

It's is useful to see visual notebook diffs on ReviewNB instead of hard to read JSON diffs on GitHub. ReviewNB also facilitates discussion on notebooks cells.

What if I don't have a ReviewNB account?

No problem, everything in GitPlus will still work fine. Only the ReviewNB URLs won't work for you.

Can we use GitPlus with Gitlab/BitBucket or any other platforms?

No, currently we only support repositories on GitHub.

Motivation

Our aim is to make notebooks a first class entity in Data science & ML teams. We can achieve this by making notebooks play well with existing tools & processes instead of building expensive proprietary platforms. Other projects in this direction are,

  • ReviewNB - Code review tool for Jupyter notebooks
  • treon - Easy to use test framework for Jupyter notebooks

Roadmap

In future GitPlus will be able to,

  • Pull changes from GitHub
  • Switch/create branches locally
  • Resolve notebook merge conflicts (without messing with underlying JSON)

Development

Install

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment & install dependencies

# Link your development version of the extension with JupyterLab
jupyter labextension link .

# Run jupyterlab in watch mode in one terminal tab
jupyter lab --watch

# Watch the GitPlus source directory in another terminal tab
jlpm watch

# If you make any changes to server side extension (.py files) then reinstall it from source
pip install .

Contributing

If you see any problem, open an issue or send a pull request. You can write to support@reviewnb.com for any questions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_gitplus-0.3.3.tar.gz (112.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlab_gitplus-0.3.3-py3-none-any.whl (160.1 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_gitplus-0.3.3.tar.gz.

File metadata

  • Download URL: jupyterlab_gitplus-0.3.3.tar.gz
  • Upload date:
  • Size: 112.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for jupyterlab_gitplus-0.3.3.tar.gz
Algorithm Hash digest
SHA256 42b1b1067507783555012a128e7335257da681768a61f7ae9403c57e757ff6cd
MD5 36e3bcae9726bc4155ae522696ba53bb
BLAKE2b-256 3b85eca1316195d04215948e50a7522f6c1d00ac087fd2d3cc6a8b82e8208a50

See more details on using hashes here.

File details

Details for the file jupyterlab_gitplus-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: jupyterlab_gitplus-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 160.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for jupyterlab_gitplus-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8cc562ee872dc29ef389cd081275003665c6ea258942f9e0640bbb1055d4f54b
MD5 c6e0ab0560a0e801463192fb4aed9f23
BLAKE2b-256 898890dd30538e5db747a04daf1dae8b75f4a8d720ecd2d28a5eabb6a9d1d4a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page