JupyterLab extensions: GitHub.

JupyterLab extensions: GitHub.

When you install the GitHub extension, an additional filebrowser tab will be added to the left area of JupyterLab. This filebrowser allows you to select GitHub organizations and users, browse their repositories, and open the files in those repositories. If those files are notebooks, you can run them just as you would any other notebook. You can also attach a kernel to text files and run those. Basically, you should be able to open any file in a repository that JupyterLab can handle.

This is not an extension that provides full GitHub access, such as saving files, making commits, forking repositories, etc. If you want to use Git from JupyterLab, you should look at the jupyterlab-git extension.

Getting your credentials from GitHub.

You need to create a personal access token to authenticate yourself to GitHub.

You can get an access token by following these steps:

  • Verify your email address with GitHub.
  • Go to your account settings on GitHub and select "Developer Settings" from the left panel.
  • On the left, select "Personal access tokens"
  • Click the "Generate new token" button, and enter your password.
  • Give the token a description, and check the "repo" scope box.
  • Click "Generate token".

You should be given a string which will be your access token.

This is the only time you'll see this token in GitHub. If you lose it, you'll need to create another one.

Remember that this token is effectively a password for your GitHub account. Do not share it online or check the token into version control, as people can use it to access all of your data on GitHub.

Configure the server extension.

You should now add the credentials you got from GitHub to your notebook configuration file (if you do not have that file, you need to create it).

cat home/username/.jupyter/jupyter_notebook_config.py

To create a jupyter_notebook_config.py file in the .jupyter directory use the following command:

jupyter notebook --generate-config

Then, add the following line to it:

c.GitHubConfig.access_token = "< YOUR_ACCESS_TOKEN >"

where < YOUR_ACCESS_TOKEN > is the string value you obtained above.

Customizing the extension.

You can set the plugin to start showing a particular repository at launch time. Open the "Advanced Settings" editor in the JupyterLab Settings menu, and under the GitHub settings add:

{"defaultRepo": "owner/repository"}

where owner is the GitHub user or group, and repository is the name of the repository you want to open.

Show Comments