Requirements

  • Python 3.6+
  • Mantle account with username and password
  • GitHub account

Set up SSH key for GitHub account

In order to pip install the Mantle SDK package using SSH, you need to set up an SSH key for your GitHub account. If you already have one, you can move on to the Install with pip section.

Prerequisites

  • GitHub account
  • Read access to the mantle-sdk GitHub repository

Steps

Check for existing SSH keys on your system

  1. Open your prefered terminal application.
  2. Run the following command to check for existing SSH keys on your system.
ls -al ~/.ssh
  1. Check the output to see if you have any existing SSH keys. The output should look something like this:
total 32
drwx------  5 username username 4096 Jan 29 10:20 .
drwxr-xr-x 35 username username 4096 Feb 24 09:00 ..
-rw-r--r--  1 username username  421 Jan 29 10:20 config
-rw-------  1 username username 1679 Jan 12 08:14 id_rsa
-rw-r--r--  1 username username  399 Jan 12 08:14 id_rsa.pub
-rw-r--r--  1 username username 4444 Jan 18 11:30 known_hosts

If your output contains id_rsa and id_rsa.pub, then you have an existing SSH key and can skip to the section titled “Adding a new SSH key to your GitHub account.”

Generating a new SSH key and adding it to the ssh-agent

  1. Open your prefered terminal application.
  2. Run the following command to generate a new SSH key:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. When prompted to “Enter a file in which to save the key,” press enter to save the key in the default location.
  2. When prompted to “Enter a passphrase,” you can either enter a passphrase or press enter to leave it blank. Note that if you chose to enter a passphrase, you will be prompted to enter it every time you use the key. For more information on passphrases, see https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases.
  3. Run the following command to add your SSH key to the ssh-agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Adding a new SSH key to your GitHub account

  1. Open your prefered terminal application.
  2. Run the following command to copy your SSH key to your clipboard:
cat ~/.ssh/id_rsa.pub | pbcopy
  1. Go to your GitHub account settings and click on “SSH and GPG keys” in the left hand menu.
  2. Click on “New SSH key” in the top right hand corner.
  3. In the “Title” field add a descriptive title for your SSH key.
  4. In the “Key” field paste your public SSH key.
  5. Click “Add SSH key.”

Testing your SSH connection

  1. Open your preferred terminal application.
  2. Run the following command to test your SSH connection:
$ ssh -T git@github.com
# Attempts to SSH to GitHub
  1. When you run the command, you may see a message like the following:
> 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)?
  1. Validate the displayed fingerprint: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
  2. If the fingerprint is correct type yes and press enter
  3. You should see a message like the following
> Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Troubleshooting

If you have any issues with the above steps please refer to the following documentation for more information: https://docs.github.com/en/authentication/troubleshooting-ssh.

Install with pip

To install the Mantle SDK package using pip, use the following command:

pip install git+ssh://git@github.com/mantlebio/mantle-sdk.git@latest

When including the package as a requirement in a requirements.txt file, use the following:

git+ssh://git@github.com:mantlebio/mantle-sdk.git@latest
Adding @latest to the pip install command ensures you are pulling the latest version of the Mantle SDK. To pin to a specific release or branch of the sdk you can use @release_tag or @branch_name

Usage

To use the Mantle SDK in your python code, you can import the mantlebio package and create a new MantleClient instance:

import mantlebio

# Create a new Mantle SDK client
mantle = mantlebio.MantleClient()