# ewokscore
*ewokscore* provides an API to define workflows and implement tasks in [ewoks](https://ewoks.readthedocs.io/).
## Install
```bash
pip install ewokscore[test]
```
## Test
```bash
pytest --pyargs ewokscore.tests
```
## Getting started
```python
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 with default inputs
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": [{"source_output": "result", "target_input": "a"}],
},
{
"source": "task2",
"target": "task3",
"data_mapping": [{"source_output": "result", "target_input": "a"}],
},
]
workflow = {"graph": {"id": "testworkflow"}, "nodes": nodes, "links": links}
# Define task inputs
inputs = [{"id": "task1", "name": "a", "value": 10}]
# Execute a workflow (use a proper Ewoks task scheduler in production)
varinfo = {"root_uri": "/tmp/myresults"} # optionally save all task outputs
result = execute_graph(workflow, varinfo=varinfo, inputs=inputs)
print(result)
```
## Documentation
https://ewokscore.readthedocs.io/
Raw data
{
"_id": null,
"home_page": "https://gitlab.esrf.fr/workflow/ewoks/ewokscore/",
"name": "ewokscore",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "ewoks",
"author": "ESRF",
"author_email": "wout.de_nolf@esrf.fr",
"download_url": "https://files.pythonhosted.org/packages/bf/49/985354d965fa79967aba4f9def60e143d79f541b7dbff2651bb3d72c85c4/ewokscore-0.14.0.tar.gz",
"platform": null,
"description": "# ewokscore\n\n*ewokscore* provides an API to define workflows and implement tasks in [ewoks](https://ewoks.readthedocs.io/).\n\n## Install\n\n```bash\npip install ewokscore[test]\n```\n\n## Test\n\n```bash\npytest --pyargs ewokscore.tests\n```\n\n## Getting started\n\n```python\nfrom ewokscore import Task\nfrom ewokscore import execute_graph\n\n\n# Implement a workflow task\nclass SumTask(\n Task, input_names=[\"a\"], optional_input_names=[\"b\"], output_names=[\"result\"]\n):\n def run(self):\n result = self.inputs.a\n if self.inputs.b:\n result += self.inputs.b\n self.outputs.result = result\n\n\n# Define a workflow with default inputs\nnodes = [\n {\n \"id\": \"task1\",\n \"task_type\": \"class\",\n \"task_identifier\": \"__main__.SumTask\",\n \"default_inputs\": [{\"name\": \"a\", \"value\": 1}],\n },\n {\n \"id\": \"task2\",\n \"task_type\": \"class\",\n \"task_identifier\": \"__main__.SumTask\",\n \"default_inputs\": [{\"name\": \"b\", \"value\": 1}],\n },\n {\n \"id\": \"task3\",\n \"task_type\": \"class\",\n \"task_identifier\": \"__main__.SumTask\",\n \"default_inputs\": [{\"name\": \"b\", \"value\": 1}],\n },\n]\nlinks = [\n {\n \"source\": \"task1\",\n \"target\": \"task2\",\n \"data_mapping\": [{\"source_output\": \"result\", \"target_input\": \"a\"}],\n },\n {\n \"source\": \"task2\",\n \"target\": \"task3\",\n \"data_mapping\": [{\"source_output\": \"result\", \"target_input\": \"a\"}],\n },\n]\nworkflow = {\"graph\": {\"id\": \"testworkflow\"}, \"nodes\": nodes, \"links\": links}\n\n# Define task inputs\ninputs = [{\"id\": \"task1\", \"name\": \"a\", \"value\": 10}]\n\n# Execute a workflow (use a proper Ewoks task scheduler in production)\nvarinfo = {\"root_uri\": \"/tmp/myresults\"} # optionally save all task outputs\nresult = execute_graph(workflow, varinfo=varinfo, inputs=inputs)\nprint(result)\n```\n\n## Documentation\n\nhttps://ewokscore.readthedocs.io/\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "API for graphs and tasks in Ewoks",
"version": "0.14.0",
"project_urls": {
"Documentation": "https://ewokscore.readthedocs.io/",
"Homepage": "https://gitlab.esrf.fr/workflow/ewoks/ewokscore/",
"Source": "https://gitlab.esrf.fr/workflow/ewoks/ewokscore/",
"Tracker": "https://gitlab.esrf.fr/workflow/ewoks/ewokscore/issues/"
},
"split_keywords": [
"ewoks"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bf49985354d965fa79967aba4f9def60e143d79f541b7dbff2651bb3d72c85c4",
"md5": "065f8cd47353c044fece4fb3245ac452",
"sha256": "acd8496a263c096c8ff47b407c5c6055f116e2dd899519fa1dea0b80d107fd88"
},
"downloads": -1,
"filename": "ewokscore-0.14.0.tar.gz",
"has_sig": false,
"md5_digest": "065f8cd47353c044fece4fb3245ac452",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 77018,
"upload_time": "2024-11-06T19:07:51",
"upload_time_iso_8601": "2024-11-06T19:07:51.802095Z",
"url": "https://files.pythonhosted.org/packages/bf/49/985354d965fa79967aba4f9def60e143d79f541b7dbff2651bb3d72c85c4/ewokscore-0.14.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-06 19:07:51",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ewokscore"
}