How to Upload Jupyer Notebook T Gihub

Jupyter Notebook is a web-based evolution tool that makes information technology easier for developers to manage projects. With a user-friendly interface, Jupyter includes interactive elements to create and share alive documents that contain code, visuals, equations, and fifty-fifty narrative texts.

I've already written about how to install Jupyter Notebook in my slice "Jupyter Notebooks: The Web-Based Dev Tool You've Been Seeking," so you lot should read through that tutorial to get Jupyter upwards and running.

Matter is, with a default Jupyter installation, you miss out on GitHub integration. And given how so many developers depend on the likes of GitHub, this is a feature that is sorely missed.

Fortunately, a developer has created an extension that makes it possible for you to use Jupyter with GitHub. Unfortunately, since the developer created the extension for Jupyter/GitHub, things have inverse on the side of GitHub, so there's one caveat to using this tool (I'll explain afterwards). Only even with that caveat, this extension is a skillful way to continue your Jupyter Notebooks in sync with a GitHub repository (otherwise, all of those notebooks will remain on your local machine).

Let'southward go these ii pieces of technology connected.

Before you first this process, brand certain yous've taken care of getting Jupyter installed. Make certain you don't launch a notebook even so. We'll exercise that in a fleck.

Installing the Extension

You've already installed the necessary dependencies for Jupyter (Python and pip). You lot now need to install the Jupyter GitHub extension. Log into your machine that contains Jupyter and open a terminal window. From the CLI, issue the post-obit commands:

alias pip=pip3

pip install git+https://github.com/sat28/githubcommit.git

jupyter serverextension enable --py githubcommit

jupyter nbextension install --py githubcommit --user

jupyter nbextension enable githubcommit --user --py

The above commands will install the extension and brand sure information technology is bachelor for all notebooks.

Install the remaining dependencies

You probably already take git installed, but on the off-chance you don't, event the command (I'g demonstrating on Ubuntu Desktop 21.04):

sudo apt-get install git -y

If you lot're using a Cerise Lid-based distribution, that command would be:

sudo dnf install git -y

Generate SSH keys

You'll besides demand SSH keys (so you tin can clone the necessary repository). For this, run the control:

ssh-keygen

Make sure to accept the defaults and give the key a unique and strong password.

One time you've generated the central, view the public fundamental with the control:

less ~/.ssh/id_rsa.pub

Copy the contents of that fundamental and head over to your GitHub business relationship. Go to Settings > SSH and GPG keys and click New SSH Key. In the resulting window, paste the SSH fundamental you lot simply generated, give it a proper name, and click Add SSH Key (Figure i).

Figure 1: Adding an SSH key to GitHub.

Clone the Repository

We need to clone the extension repository, with the control:

git clone [email protected]:sat28/githubcommit.git

You volition be asked for the countersign for your SSH key you just created. When this finishes, a new directory will be created, named githubcommit.

With the repository cloned, let's make sure Git knows who nosotros are. Issue the following two control:

git --global user.email E-mail

git --global user.name NAME

Where Electronic mail is your email address and Name is your proper noun.

Create a GitHub Access Token

Next, you need to create a GitHub access token. Get to your GitHub business relationship and then to Settings > Developer Settings > Personal Admission Tokens. Click Generate New Token and then, in the resulting window, give it a name and check the boxes for repo and write:packages. Scroll to the bottom and click Generate token. You'll so need to copy that access token to your clipboard.

Configure the Extension

Change into the githubcommit folder with the command:

cd githubcommit

Open the env.sh configuration file with the command:

nano env.sh

In that file, you must configure the following section:

Where:

  • REPONAME is the proper name of a GitHub repository you lot'll apply for this.
  • Co-operative is the repository branch (probably "primary")
  • USERNAME is your GitHub username
  • Email is the e-mail accost associated with your GitHub account
  • ATOKEN is the access token yous merely created.

Save and close the file.

Source the env.sh file and launch a notebook

The next step is to source the env.sh file with the command:

source ~/githubcommit/env.sh

You lot will be prompted for your SSH primal password. Once you've done that, the repository yous configured in the env.sh file will clone to your local drive (in your dwelling house directory). When that completes, change into the new directory that cloned from your GitHub repository (in my case it was named newstack).

From inside that directory, launch the notebook with the command:

jupyter notebook --ip 0.0.0.0

Your notebook should open up to reveal all of the files from your GitHub repository (Effigy 2).

Effigy 2: Jupyter Notebook with files from the newstack repository I created.

If you create a new file or open one, you'll now come across a GitHub logo in your notebook (Figure iii).

Figure 3: The GitHub logo now shows up in the Jupyter Notebook.

Hither's where the caveat comes into play. You should be able to click that button and then commit any new code to the connected GitHub repository. Unfortunately, it's non working. I take a feeling this is considering of the changes GitHub has made recently to authentication. Considering of that, it'due south on the programmer to set this problem.

Fortunately, I have a workaround.

Subsequently you've created all of your new files and are finished working in Jupyter Notebook, they'll all exist found in the directory pulled downward from your configured GitHub repository. In my case, I used a test repository I created on GitHub, named newstack.

Change into that folder then go through the usual process with git:

git add .

git commit -m "Added new files"

git push

Once yous've taken care of the above steps, all of your new files will be uploaded to the GitHub repository.

The second caveat is that Jupyter doesn't automatically pull downwardly any new files created by other teammates or from within GitHub itself. For that, go back to the last window and issue the command:

git pull

In other words, to push and pull new content to and from GitHub, you must use the command line (at to the lowest degree until the programmer fixes the upshot). But fifty-fifty with having to do this, being able to integrate Jupyter Notebooks with GitHub makes the tool even more useful.

Hopefully, former soon, the developer volition resolve the issue with the push and pull of content. Until then, you lot tin can go around the issues with a little manual git pull and git push.

burmeisteroura1948.blogspot.com

Source: https://thenewstack.io/integrate-jupyter-notebooks-with-github/

0 Response to "How to Upload Jupyer Notebook T Gihub"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel