Skip to main content

saltant SDK for Python

Project description

Build Status Documentation Status PyPI PyPI - Python Version

saltant SDK for Python

NOTE: this project is an active work in progress

This attempts to follow the coding paradigms of docker-py fairly closely.

Example

from __future__ import print_function
import time
from saltant.client import Client
from saltant.constants import (
    SUCCESSFUL,
    FAILED,
)

API_TOKEN = 'p0gch4mp101fy451do9uod1s1x9i4a'
API_BASE_URL = 'https://shahlabjobs.ca/api/'
TASK_INSTANCE_UUID_TO_GET = '4ce0f9f1-9ae3-4baf-8838-76a19758fb29'


# Instantiate a Client object
client = Client(base_api_url=API_BASE_URL, auth_token=API_TOKEN)

# GET a task instance we know the UUID of. This will return an instance
# of the ExecutableTaskInstance model.
my_task_instance = client.executable_task_instances.get(
    uuid=TASK_INSTANCE_UUID_TO_GET)

# List attributes and methods of the task instance we just got.
print(dir(my_task_instance))

# Launch an instance of executable task type 1 :D
new_task_instance = client.executable_task_instances.create(
    name="saltant-py test",
    arguments={
        "tag_name": None,
        "output_dir": "/shahlab/archive/single_cell_indexing/NextSeq/fastq/160705_NS500668_0105_AHGTTWBGXY",
        "flowcell_id": "AHGTTWBGXY",
        "storage_name": "shahlab",
        "storage_directory": "/shahlab/archive"
    },
    task_queue_id=1,
    task_type_id=1,
)

# Wait until task instance completes
while True:
    # Wait a bit
    time.sleep(3)

    # Get job's status
    status = client.executable_task_instances.get(
        uuid=new_task_instance.uuid).state

    if status == SUCCESSFUL:
        print("yay!")
        break
    elif status == FAILED:
        print("noo!")
        break

Installation

Using pip,

pip install saltant-py

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

saltant-py-0.0.11.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file saltant-py-0.0.11.tar.gz.

File metadata

  • Download URL: saltant-py-0.0.11.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.1 CPython/2.7.15rc1

File hashes

Hashes for saltant-py-0.0.11.tar.gz
Algorithm Hash digest
SHA256 f8cfe8020c32c6198fb8411ff4918084cf904a7cdb7be01d0f47b3fdd6e4f630
MD5 b722e4216aa2f6d7b755ceabdde0cadd
BLAKE2b-256 f7cf0be0c60b36b67d07834d0622575efdbc2d4c73932e016385fe48f51ce312

See more details on using hashes here.

Supported by

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