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 load_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", "class": "__main__.SumTask", "inputs": {"a": 1}},
    {"id": "task2", "class": "__main__.SumTask", "inputs": {"b": 1}},
    {"id": "task3", "class": "__main__.SumTask", "inputs": {"b": 1}},
]
links = [
    {"source": "task1", "target": "task2", "arguments": {"a": "result"}},
    {"source": "task2", "target": "task3", "arguments": {"a": "result"}},
]
workflow = {"nodes": nodes, "links": links}

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

Documentation

https://workflow.gitlab-pages.esrf.fr/ewoks/ewokscore

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.0.1a2.tar.gz (27.2 kB view hashes)

Uploaded Source

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