Python Library

Jobs can be submitted and results retrieved using a python 3 client library. The client object can be constructed on one of two ways:

If you construct the client with no arguments, the config values stored in $HOME/.engine_config.json when you ran cyrus init will be used

from engine import EngineClient
client = EngineClient()

Alternately you can configure the client manually

  • client_id — The client ID obtained from https://api-authorization.levitate.bio
  • secret — The secret obtained from https://api-authorization.levitate.bio
  • server — The address of your Cyrus API server. This will be provided to you during onboarding
  • port — The Cyrus API server port, you should use port 443 unless otherwise instructed during onboarding.
    from engine import EngineClient
    client = EnglineClient(
    client_id="client_id",
    secret="secret",
    server="engine.customername.levitate.bio",
    port=443)
    
    

Once the client is constructed it can be used to submit jobs and retrieve results

Submitting Jobs

There for each API service, the client provides a submit_<servicename> method. For example, to submit an epitope scan job:

mhc_list = ["H-2-IAb"]
sequence = "NLYIQWLKDGGPSSGRPPPS"
job_id = client.submit_epitope_scan(mhc_list=mhc_list, sequence=sequence)

Retrieving job results

You can get the status of the job by running:

client.get_status(job_id)

where job_id is the object returned by a submit_ method

The client.get_results() method will not return your results until the job is complete. Once complete, this method will return an dictionary containing the results. The results object will have attributes for each file produced by the API job. For example, to download the “csv” artifact produced by the epitope scan API to the directory “output_dir/” you could use code like this:

results = client.get_results(job_id)
results["csv"].dump(“output_dir/”)

Updated: