Using Git Repositories in Saturn Cloud

Add your Git repositories to Saturn Cloud

This article describes how to work with git repositories in Saturn Cloud. As of this writing, only GitHub repos have built-in support.

If you need to work with a repo on another hosted source control management (SCM) service such as AWS CodeCommit, BitBucket, GitLab, or any other SCM service that supports cloning repos over SSH, skip to “Using a Start Script”.

Set up SSH Keys

To add Repositories in Saturn Cloud, you’ll need to use SSH credentials.

You will need to set up SSH to make the connection between Saturn Cloud and Github. Your first step is to add an SSH Private Key Credential to your Saturn Cloud account. The SSH Public Key will then go in Github.

If you need help setting up a Credential, please visit our reference page about credentials in Saturn Cloud.

If you need help setting up your SSH keys on your laptop, there are some reference options elsewhere online.

If you need help adding the SSH Public Key to Github, they have great reference materials:

Add Repository

Note: you are always welcome to manually clone a repo inside Jupyter when working in Saturn Cloud. This instruction will show you how to make a persistent connection to that repo that can be easily reused. Persistent connections are available on your Dask clusters, deployments, jobs and anything else associated with the project.

Now that your credentials are added, click “Tools” in the menu and choose “Git Repositories”. Click the “Create” button in the top right corner.

Screenshot of side menu of Saturn Cloud product with Git Repositories selected

This will take you to a form, where you can set up the repository you wish to use.

In this form, you’ll fill in your repository details.

  • Remote URL: in Github, this is the link you’d use when running git clone at terminal. It must be the SSH link, not an HTTPS link.
  • Filepath: You can choose whatever you like here, but it will be made a filepath inside your projects.
  • Remote Visibility: This is to let Saturn Cloud know if the repo you’re adding requires credentials.
  • Branch: You can choose to check out a non-main branch by default if you would like, and you’d make that selection here.
  • Expected Usage: select whether you will be only using this repo for reading from, and would like it to be refreshed to the remote state every time you start the project, or if you’d like it to be read/write, so your edits will be persisted and not overwritten.
Screenshot of Saturn Cloud Add Repository form

Attach Credentials

After you’ve filled out this form, you’ll be asked to specify the credential you want to use to access the repo, if it is not public. Use the dropdown to choose the SSH Private Key that you added above.

Screenshot of Saturn Cloud new repository named benchmarks, where Credential select dropdown is shown

At this point, you should add your Repository to a project in order to use it. If you have already created a project, edit it, and add repository as shown below. If you have not created a project, follow our instructions for doing that, including the step where you can add a Repository.

Screenshot of Saturn Cloud project setup page, where Repositories section is centered

Now, when you log in to your Jupyter Server, at the top level of your file system, you’ll see the folder git-repos which contains all the repositories you have attached to this project. You can also clone others inside the terminal in your Jupyter server if you need to.

Using a Start Script

For remote hosts that are not supported by Saturn’s git repo integration, you can set up automatic repo cloning using a feature called the “start script”. This is a small shell script which runs every time Saturn creates a Jupyter server, Deployment, Dask worker, or Prefect Cloud flow run.

  1. Create an SSH keypair. Put the public key on your source code management system, and add the private key as a Saturn credential with location set to /home/jovyan/.ssh/id_rsa_example. See “Set up SSH Keys” for instructions.

  2. In your Saturn project, expand the “Advanced Settings” section.

    Screenshot of Saturn Cloud project creation page Advanced Settings section
  3. Paste something like the following into the “Start Script” section.

    This script tells Saturn to use the SSH private key credential you added, and includes code to make sure that the repository you cloned isn’t overwritten if you restart a resource.
    # tell git where to look for an SSH private key to use with #
    if ! grep gitlab /home/jovan/.ssh/config; then
        echo "Host ${REPO_HOST}" >> /home/jovyan/.ssh/config
        echo " HostName ${REPO_HOST}" >> /home/jovyan/.ssh/config
        echo " User git" >> /home/jovyan/.ssh/config
        echo " IdentityFile ${PRIVATE_KEY_LOCATION}" >> /home/jovyan/.ssh/config
        echo " StrictHostKeyChecking no" >> /home/jovyan/.ssh/config
    # only clone if the repo is not already there
    mkdir -p /home/jovyan/git-repos
    if [ ! -d /home/jovyan/git-repos/eigen/.git ]; then
        echo "cloning Eigen from GitLab"
        git clone /home/jovyan/git-repos/eigen

Need help, or have more questions? Contact us at:We'll be happy to help you and answer your questions!