Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Mar 2, 2024
1 parent 8178eab commit 23cd0fe
Showing 1 changed file with 167 additions and 15 deletions.
182 changes: 167 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
[![Build Status](https://travis-ci.org/ohsu-comp-bio/py-tes.svg?branch=master)](https://travis-ci.org/ohsu-comp-bio/py-tes)
[![Coverage Status](https://coveralls.io/repos/github/ohsu-comp-bio/py-tes/badge.svg?branch=master)](https://coveralls.io/github/ohsu-comp-bio/py-tes?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# py-tes {#manual-main}

py-tes
======
[![GitHub Actions Test Status](https://img.shields.io/github/actions/workflow/status/ohsu-comp-bio/py-tes/tests.yml?logo=github)](https://github.com/ohsu-comp-bio/py-tes/actions) [![image](https://coveralls.io/repos/github/ohsu-comp-bio/py-tes/badge.svg?branch=master)](https://coveralls.io/github/ohsu-comp-bio/py-tes?branch=master) [![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

_py-tes_ is a library for interacting with servers implementing the [GA4GH Task Execution Schema](https://github.com/ga4gh/task-execution-schemas).
*py-tes* is a library for interacting with servers implementing the
[GA4GH Task Execution
Schema](https://github.com/ga4gh/task-execution-schemas).


### Install
## Install

Available on [PyPI](https://pypi.org/project/py-tes/).

```
pip install py-tes
```
pip install py-tes

### Example
## Example

```
``` python
import tes

# define task
task = tes.Task(
executors=[
tes.Executor(
Expand All @@ -30,8 +27,163 @@ task = tes.Task(
]
)

cli = tes.HTTPClient("http://localhost:8000", timeout=5)
# create client
cli = tes.HTTPClient("https://funnel.example.com", timeout=5)

# access endpoints
service_info = cli.get_service_info()
task_id = cli.create_task(task)
res = cli.get_task(task_id)
task_info = cli.get_task(task_id, view="BASIC")
cli.cancel_task(task_id)
tasks_list = cli.list_tasks(view="MINIMAL") # default view
```

## How to...

> Makes use of the objects above...
### ...export a model to a dictionary

``` python
task_dict = task.as_dict(drop_empty=False)
```

`task_dict` contents:

``` console
{'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

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

`task_json` contents:

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

### ...pretty print a model

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

Output:

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

### ...access a specific task from the task list

``` python
specific_task = tasks_list.tasks[5]
```

`specific_task` contents:

``` console
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

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

Output:

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

### ...instantiate a model from a JSON representation

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

`task_from_json` contents:

``` console
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`:

``` python
print(task_from_json == task)
```

Output:

``` console
True
```

## Support {#main-support}

- For releases, see `Changelog <changelog>`{.interpreted-text
role="ref"}.
- Check
`frequently asked questions (FAQ) <project_info-faq>`{.interpreted-text
role="ref"}.
- For **bugs and feature requests**, please use the [issue
tracker](https://github.com/ohsu-comp-bio/tes/issues).
- For **contributions**, visit py-tes on
[Github](https://github.com/ohsu-comp-bio/py-tes)

## Resources {#main-resources}

[ga4gh-tes](https://github.com/microsoft/ga4gh-tes)

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

[cwl-tes](https://github.com/ohsu-comp-bio/cwl-tes)

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

[Funnel](https://ohsu-comp-bio.github.io/funnel/)

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

[Snakemake](https://snakemake.github.io/)

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

[Nextflow](https://www.nextflow.io/)

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

0 comments on commit 23cd0fe

Please sign in to comment.