Git Repositories

Connecting to Git repositories (GitHub, BitBucket, GitLab, etc..)

Using a private git repo in Saturn Cloud

This section will cover:

  • How to use Credentials in Saturn to access private git repositories on GitHub
  • How to install and use a Python package from a git repository in Jupyter and on a Dask cluster
  • How to use a Start Script in Saturn to create custom, reproducible environments

This tutorial focuses only on GitHub, but the same principles apply to private git repositories on other hosted version control systems like GitLab, BitBucket, or AWS CodeCommit.

Set up Access Token in GitHub

This tutorial uses Access Tokens to clone git repositories. This is a form of authentication where you generate a single purpose private token with specific permissions so GitHub can verify that you are allowed to clone a repo.

To create a new access token, follow the steps in this tutorial:

Stop right after you’ve created the token. You should see your token and be able to copy it.

Add Credentials in Saturn

Copy the access token that you just set up. In the Saturn UI, navigate to the Credentials page. Click +.

  • Shared With: choose your username
  • Name: GITHUB_TOKEN
  • Value: Paste in the contents of your GitHub access token

Click Save to create this credential.

Clone with a start script

The GITHUB_TOKEN will now automatically be present whenever you start up a Jupyter, Dask cluster, or Deployment. Next, let’s use a Start Script that takes advantage of that fact.

The Start Script is a shell script that runs whenever Saturn creates resources like Jupyter servers, Dask workers, or Deployments.

Navigate to the Jupyter page. In the Create Server form, scroll down to the Advanced Settings and enter the following in the Start Script box.

GITHUB_REPO=github.com/your_org/your_repo
mkdir -p /tmp/repos

pushd /tmp/repos
    yes | git clone https://${GITHUB_TOKEN}@${GITHUB_REPO}
popd

After filling out the Start Script, click Create. Now you will have the git repo cloned into your Jupyter files.

You can push and pull from that repo without any further authentication.