Skip to main content

Library for communicating with the GA4GH Task Execution API

Project description

py-tes 🐍

Build Status

Test Coverage

License

py-tes is a library for interacting with servers implementing the GA4GH Task Execution Schema.

Quick Start ⚡

TES version py-tes version Example Notebook
1.1.0 (latest) 1.1.0 Open in Colab
1.0.0 1.0.0 Open in Colab

Installation 🌀

Install py-tes from PyPI and run it in your script:

 pip install py-tes

➜ python example.py

example.py 🐍

import tes
import json

# Define task
task = tes.Task(
    executors=[
        tes.Executor(
            image="alpine",
            command=["echo", "hello"]
        )
    ]
)

# Create client
cli = tes.HTTPClient("http://localhost:8000", timeout=5)

# Create and run task
task_id = cli.create_task(task)
cli.wait(task_id, timeout=5)

# Fetch task info
task_info = cli.get_task(task_id, view="BASIC")
j = json.loads(task_info.as_json())

# Pretty print task info
print(json.dumps(j, indent=2))

How to...

Makes use of the objects above...

...export a model to a dictionary

task_dict = task.as_dict(drop_empty=False)

task_dict contents:

{'id': None, 'state': None, 'name': None, 'description': None, 'inputs': None, 'outputs': None, 'resources': None, 'executors': [{'image': 'alpine', 'command': ['echo', 'hello'], 'workdir': None, 'stdin': None, 'stdout': None, 'stderr': None, 'env': None}], 'volumes': None, 'tags': None, 'logs': None, 'creation_time': None}

...export a model to JSON

task_json = task.as_json()  # also accepts `drop_empty` arg

task_json contents:

{"executors": [{"image": "alpine", "command": ["echo", "hello"]}]}

...pretty print a model

print(task.as_json(indent=3))  # keyword args are passed to `json.dumps()`

Output:

{
  "executors": [
    {
      "image": "alpine",
      "command": ["echo", "hello"]
    }
  ]
}

...access a specific task from the task list

specific_task = tasks_list.tasks[5]

specific_task contents:

Task(id='393K43', state='COMPLETE', name=None, description=None, inputs=None, outputs=None, resources=None, executors=None, volumes=None, tags=None, logs=None, creation_time=None)

...iterate over task list items

for t in tasks_list[:3]:
    print(t.as_json(indent=3))

Output:

{
   "id": "task_A2GFS4",
   "state": "RUNNING"
}
{
   "id": "task_O8G1PZ",
   "state": "CANCELED"
}
{
   "id": "task_W246I6",
   "state": "COMPLETE"
}

...instantiate a model from a JSON representation

task_from_json = tes.client.unmarshal(task_json, tes.Task)

task_from_json contents:

Task(id=None, state=None, name=None, description=None, inputs=None, outputs=None, resources=None, executors=[Executor(image='alpine', command=['echo', 'hello'], workdir=None, stdin=None, stdout=None, stderr=None, env=None)], volumes=None, tags=None, logs=None, creation_time=None)

Which is equivalent to task:

print(task_from_json == task)

Output:

True

Additional Resources 📚

  • ga4gh-tes : C# implementation of the GA4GH TES API; provides distributed batch task execution on Microsoft Azure

  • cwl-tes : cwl-tes submits your tasks to a TES server. Task submission is parallelized when possible.

  • Funnel: Funnel is a toolkit for distributed task execution with a simple API.

  • Snakemake : The Snakemape workflow management system is a tool to create reproducible and scalable data analyses

  • Nextflow: Nextflow enables scalable and reproducible scientific workflows using software containers. It allows the adaptation of pipelines written in the most common scripting languages.

  • GA4GH TES: Main page for the Task Execution Schema — a standardized schema and API for describing batch execution tasks.

  • TES GitHub: Source repo for the Task Execution Schema

  • Awesome TES: A curated list of awesome GA4GH TES projects and programs

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

py_tes-1.1.0rc3.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

py_tes-1.1.0rc3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file py_tes-1.1.0rc3.tar.gz.

File metadata

  • Download URL: py_tes-1.1.0rc3.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for py_tes-1.1.0rc3.tar.gz
Algorithm Hash digest
SHA256 7a8bd8f400b7c4ebc5ee49118793469c955929d6cc13dfa90c1702336640a5e2
MD5 e6ac844bf6e573e4f2fed1532f24986f
BLAKE2b-256 adb8ef96cedc3990f20efbece675fe679b6d2874bd0ea253466e5bc4f6b3276a

See more details on using hashes here.

File details

Details for the file py_tes-1.1.0rc3-py3-none-any.whl.

File metadata

  • Download URL: py_tes-1.1.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for py_tes-1.1.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 50568ba8abd47406b49daff21d4d991a34b63341e860e4c3ba2f7c2a478016c4
MD5 153faa0a152742ae4ff0e4786b5aa9bd
BLAKE2b-256 352db8813281f96b14e4f011022f48fd0069ca3631073ca313741a838ab25551

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