Context
Ensuring seamless synchronization and backup of files is crucial for researchers, scientists, and data enthusiasts leveraging platforms like the WEkEO JupyterHub.
With the integration of the JupyterHub GitHub Plugin, users gain a powerful solution to effortlessly synchronize their work on the JupyterHub environment with GitHub repositories. This seamless integration not only facilitates efficient collaboration but also provides a reliable backup mechanism, offering peace of mind in the face of potential data loss or system disruptions.
Whether working on complex data analysis projects or collaborative research endeavors, the JupyterHub GitHub Plugin empowers users to maintain version control, enhance productivity, and safeguard their valuable work effectively.
⚠️Files that can be uploaded to GitHub are limited to 50 MB each. Therefore, we further recommend to store large files outside of the working folder (but be aware they won't be backed up).
Step-by-step Guide
Step 1. Create a GitHub Account
Log in to the site and follow the steps to create an account or log in to an existing account: GitHub.
Step 2. Create a new repository for the WEkEO JupyterHub backup
Access your repositories and create a new one:
Create a file inside the repository to check the synchronization later:
Step 3. Log in to the WEkEO JupyterHub
From the WEkEO home page, sign in to your WEkEO account and click on My WEkEO to reach your dashboard:
From the dashboard, you can access the WEkEO JupyterHub by clicking on Open in the Workspace service:
After following the few steps described in this article, you'll reach the JupyterLab interface:
Step 4. Create an ssh key for authenticating with GitHub
Execute the following code in the terminal inside the WEkEO JupyterHub:
ssh-keygen -t ed25519 -C "email@email.com"
by replacing theemail@email.com
with the email address you used for setting up the GitHub account:
Step 5. Add the SSH key to you GitHub account
Go to SSH and GPG keys:
Copy the public key which is saved in your JupyterHub files and enter it in the GitHub page. You can execute the following code in the terminal inside the JupyterHub to see the key:
nano /home/jovyan/.ssh/id_ed25519.pub
where the path is the one in which your public key has been saved:Check if the ssh set up was successful. Execute the following code in the terminal inside the WEkEO JupyterHub:
ssh -T git@github.com
You may see a warning like this:> The authenticity of host 'github.com (IP ADDRESS)' can't be established.> ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
> Are you sure you want to continue connecting (yes/no)?Enter “yes”.
You should now see a message like this in the terminal:
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
Step 6. Clone the new repository
To clone the new repository you set up in Step 2, you can use the Git Extension: on the left of the JupyterHub,
(1)
click on the Git extension icon, then(2)
click on Clone a Repository:
Go to your GitHub repository (on GitHub) and copy the URL:
Then paste it into WEkEO JupyterHub:
Now the GitHub repository appears in the JupyterHub working directory:
Step 7. Enable the ssh key for the repository
In the terminal, go to your repository:
cd wekeo_backup
Run the following command:
git remote set-url origin git@github.com:<gitaccount>/wekeo_backup.git
by replacing<gitaccount>
with your actual GitHub account.
💡WEkEO Pro Tip: you only should have to do this once for each repository
Step 8. Create a file in the WEkEO JupyterHub
In your cloned GitHub repository, you can create a notebook for example:
Once the file is created, you'll see there are untracked changes in the git section:
Step 9. Sync the JupyterHub with GitHub
Method 1. Using the git extension graphical interface
Track changes by clicking the + when you slide the mouse over the “untracked” section.
The changes will now appear in the section “Staged”:
Commit the changes by filling out the “Summary” and a description of the changes in the bottom of the menu:
Click on Commit.
Enter your name and email:
When the commit is successful, a confirmation appears at the bottom:
Push the committed changes to your GitHub repository.You can now see that your repository version inside the JupyterHub is one commit ahead of the version in GitHub. Push the commits to GitHub to synchronize both versions by clicking on the button (
):
Because you set up the ssh connection, this works now without your username and password!
Method 2. Using git in the command line
Let's create another notebook called
test2_notebook.ipynb
:In the terminal go to the wekeo_backup folger and type:
git status
You will get the untracked files here:On branch main
Your branch is up to date with 'origin/main'.
Untracked files:
(use git add <file>... to include in what will be committed)
.ipynb_checkpoints/test2_notebook-checkpoint.ipynb
test2_notebook.ipynb
nothing added to commit but untracked files present (use "git add" to track)Next we stage the changes using (stace all changes by adding the -A ):
git add -A
Next, we commit the changes and add a commit message:
git commit -am "added additional notebook and push using command line"
Next, we push it in the command line using:
git push
Step 10. Check if the push worked
We see that the notebooks are now available in our GitHub repository:
And that's it!
You've successfully configured GitHub in your WEkEO JupyterHub workspace. You can now synchronize your files! 💪
What's next?
Several articles are available in the WEkEO Help Center, but if you have any questions, issues or suggestions, feel free to contact us through a chat session available in the bottom right corner of the page.