Skip to main content

API for graphs and tasks in Ewoks

Project description

EwoksCore: API for graphs and tasks in Ewoks

Install

python -m pip install ewokscore[test]

Test

pytest --pyargs ewokscore.tests

Getting started

from ewokscore import Task
from ewokscore import execute_graph

# Implement a workflow task
class SumTask(
    Task, input_names=["a"], optional_input_names=["b"], output_names=["result"]
):
    def run(self):
        result = self.inputs.a
        if self.inputs.b:
            result += self.inputs.b
        self.outputs.result = result


# Define a workflow
nodes = [
    {
        "id": "task1",
        "task_type": "class",
        "task_identifier": "__main__.SumTask",
        "default_inputs": [{"name": "a", "value": 1}],
    },
    {
        "id": "task2",
        "task_type": "class",
        "task_identifier": "__main__.SumTask",
        "default_inputs": [{"name": "b", "value": 1}],
    },
    {
        "id": "task3",
        "task_type": "class",
        "task_identifier": "__main__.SumTask",
        "default_inputs": [{"name": "b", "value": 1}],
    },
]
links = [
    {
        "source": "task1",
        "target": "task2",
        "data_mapping": [{"target_input": "a", "source_output": "result"}],
    },
    {
        "source": "task2",
        "target": "task3",
        "data_mapping": [{"target_input": "a", "source_output": "result"}],
    },
]
workflow = {"nodes": nodes, "links": links}

# Execute a workflow (use a proper Ewoks task scheduler in production)
varinfo = {"root_uri": "/tmp/myresults"}  # optional
tasks = execute_graph(workflow, varinfo=varinfo)
print(tasks["task3"].output_values)

Documentation

https://ewokscore.readthedocs.io/

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

ewokscore-0.1.0rc10.tar.gz (67.1 kB view details)

Uploaded Source

File details

Details for the file ewokscore-0.1.0rc10.tar.gz.

File metadata

  • Download URL: ewokscore-0.1.0rc10.tar.gz
  • Upload date:
  • Size: 67.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for ewokscore-0.1.0rc10.tar.gz
Algorithm Hash digest
SHA256 08a15195f0661afd77c9e383fbe9a52d2464c91d307b0f2f49ba5202ed6e903b
MD5 856779d6b5bbb03a68226171bf31a8c4
BLAKE2b-256 e8e8bdbfded513d6ccdf16324427ff78e14b694726517efb310c1983b3e2d370

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