Skip to content

Getting Started

Install Polly Python using pip

pip install polly-python

Import from libraries

The following libraries need to be imported over the development environment to access the data.

from polly.auth import Polly
from polly.omixatlas import OmixAtlas
from polly.workspaces import Workspaces
from polly.cohort import Cohort

Authentication

Authentication of the account is required to be able to access the capabilities of the Polly Python library.

Run this code to automatically authenticate.

import os
from polly.auth import Polly
AUTH_TOKEN = (os.environ['POLLY_REFRESH_TOKEN'])
Polly.auth(AUTH_TOKEN)

Copying authentication token or key

To get this token, follow the steps below:

  1. Go to Polly

  2. Click the User Options icon from the left-most panel

  3. Click on Authentication on the panel that appears

  4. Click on Copy to copy the authentication token or key

There are two ways to authenticate to Polly, using TOKENS (expires in 30 days) and using API KEYS (doesn't expire). While using Polly Notebooks, users can just use POLLY_REFRESH_TOKEN instead of having to copy the token from Authentication panel. This is further described below.

Using the token

The following code is required to add the authentication function in the Polly Python library

AUTH_TOKEN = "<copied_authentication_token>"
Polly.auth(AUTH_TOKEN)

Using the key

Go to authentication keys and input the name, description to generate a key. This can be copied and used as shown below:-

AUTH_KEY = "<copied_authentication_key>"
Polly.auth(AUTH_KEY)

Calling a function

In order to call a functions from a particular class, corresponding object should be defined.

E.g. for functions related to OmixAtlas,

omixatlas = OmixAtlas()
output = omixatlas.<function_name>(<args if any>)
Similarly, for functions related to Workspaces,
workspaces = Workspaces()
output = workspaces.=<function_name>(<args if any>)
And, for functions related to Cohorts,

cohort = Cohort()
output = cohort.<function_name>(<args if any>)

For example,

omixatlas = OmixAtlas()
result = omixatlas.query_metadata(<sql_query>)

Get installed version of polly-python

import polly
polly.__version__
0.2.9