Skip to main content

Octopod API client

Project description

Octopod wrapper & CLI tool

Library to work with GalateaBio API via python or via CLI tool.

Supported features:

  • File uploading via API and SFTP
  • File deletion
  • Get organization's information and available models
  • Searching files
  • Submitting orders
  • Cancelling orders
  • Searching/adding/editing tags
  • Downloading order's results

Installation

Via pip from PyPI

pip install galatea-cli

Local Installation

git clone repository

In your project run

pip install file://<path_to_repo>

Wrapper usage

Create Octopod client

base_url = 'Octopod API URL'  # Example https://<OCTOPOD_API_HOST>
api_key = 'Octopod API Key'

octopod_client = OctopodClient(base_url=base_url, api_key=api_key)

Also wrapper supports authentication with username and password

base_url = 'Octopod API URL'  # Example https://<OCTOPOD_API_HOST>
auth_json = OctopodClient.authenticate(
    username='my_username',
    password='my_password',
    base_url=base_url,
)
api_key = auth_json.get('access')  # fetched api_key has short lifetime!
octopod_client = OctopodClient(base_url=base_url, api_key=api_key)

Upload file

API upload. Only for files less than 50 mb

file_obj = octopod_client.file_api.upload_file('my_file.zip')

or

file_name = 'my_file.zip'
with open(file_name, "rb") as fh:
    buf = BytesIO(fh.read())
    file_obj = octopod_client.file_api.upload_file_from_io(buf, file_name)

SFTP upload. For any file size. (Preferable to use)

sftp_keyfile = 'File name with Octopod SFTP private key'
sftp_octopod_client = OctopodSftpClient(
  sftp_host='Octopod SFTP host',
  sftp_user='Octopod SFTP user',
  sftp_password=None,
  sftp_keyfile=sftp_keyfile,
)
file_name = sftp_octopod_client.upload_file_from_file(
  file_name='my_file.zip',
  remote_filename='my_file.zip',
  remote_folder='my_awesome_folder_name',
)

List files/get file information

file_name = 'my_file.zip'
files_objs = octopod_client.file_api.list_files(**{'file': file_name})
if files_objs.get('count', 0) > 0:
    file_id = files_objs.get('results', [])[0].get('id')
    file_obj = octopod_client.file_api.find_file_by_id(file_id)

Get organization's available models

org_info = octopod_client.organization_api.get_organization_info()
available_model_names = org_info.get('available_models', [])

Submit order

file_id = 'my_file_id'
model_name = 'my_model_name'
order_obj = octopod_client.order_api.submit_order(file_id=file_id, model_name=model_name)

Submit order with PDF reports for Mysterio model

file_id = 'my_file_id'
model_name = 'my_model_name'
pdf_report_types = ['PRS_RUO_CARDIO', 'PRS_RUO_CANCER', 'PRS_CLINICAL_CARDIO', 'PRS_CLINICAL_CANCER']  # all possible PDF report types
order_obj = octopod_client.order_api.submit_order(
    file_id=file_id, 
    model_name=model_name, 
    pdf_report_types=pdf_report_types,
)

Get order information

order_id_or_file_id = 'my_order_id_or_file_id'
order_obj = octopod_client.order_api.find_order_by_id_or_file_id(order_id_or_file_id)
order_status = order_obj.get('status')
order_result_types = order_obj.get('result_types')

Download order's result

order_id = 'my_order_id'
result_type = octopod_client.result_api.RESULT_TYPE_SUMMARY_CHROMS  
# result_type = order_obj.get('result_types')[0]  # get result type from order info
result_file_content, result_file_name = octopod_client.result_api.download_result_file(
  order_id=order_id, 
  result_type=result_type,
)

Octopod CLI usage

Set config options

CLI tool supports 2 ways to communicate with API:

  • Via API key. api_mode=1. Required parameters
  • Via Username & password. api_mode=2. Required parameters api_username, api_password
octo set-config 
--api_mode=1
--api_key="<api_key>"
--api_username="<user_username>"
--api_password="user_password" 
--api_base_url="<api_base_url>" 
--sftp_host="<sftp_host>" 
--sftp_user="<sftp_user>" 
--sftp_keyfile="<sftp_keyfile>" 
--download_folder="<download_folder>"

Get config options

octo get-config

Clear config options

octo clear-config

File upload

API upload. Only for files less than 50 mb

octo api-upload-file --file_name="<full_file_name>"

SFTP upload. For any file size. (Preferable to use)

octo sftp-upload-file --file_name="<full_file_name>"

Get file information

octo find-file --file_id="<file_id>"
octo find-file --file_name="<file_name>"

Get organization's available models

octo get-organization-info

Submit order

octo submit-order --file_id="<file_id>" --model="<model_name>"

Submit order with PDF reports for Mysterio model

octo submit-order --file_id="<file_id>" --model="<model_name>" --pdf_report_types="PRS_RUO_CARDIO,PRS_RUO_CANCER,PRS_CLINICAL_CARDIO,PRS_CLINICAL_CANCER"

Get order information

octo find-order --order_id_or_file_id="<order_id_or_file_id>"

Download order's result

octo download-result-file --order_id="<order_id>" --result_type="SUMMARY_SUPERSET"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

galatea_cli-0.0.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

galatea_cli-0.0.1-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file galatea_cli-0.0.1.tar.gz.

File metadata

  • Download URL: galatea_cli-0.0.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for galatea_cli-0.0.1.tar.gz
Algorithm Hash digest
SHA256 131a012c24d152db9656f62f5759fa4a680e5238cc2cedddc1421be5be9d5b74
MD5 61d9d75e3f61099f563e5412081d4d80
BLAKE2b-256 1a0b371aac95bf122db07c236e600521d4f40ef1478658523ebdce9d8f37190f

See more details on using hashes here.

File details

Details for the file galatea_cli-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: galatea_cli-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for galatea_cli-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90b7900d626492ff3bd90227ad0fb52accc9728f39c69c70196c3033ce39d05d
MD5 49dcd15b8e7f48d10a1a5f7aa2956ac9
BLAKE2b-256 2fe03589472eee33d18163240cc2366ecf1a1854226148b3dce49b677591c89e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page