ewokscore


Nameewokscore JSON
Version 0.7.3 PyPI version JSON
download
home_pagehttps://gitlab.esrf.fr/workflow/ewoks/ewokscore/
SummaryAPI for graphs and tasks in Ewoks
upload_time2024-03-13 17:49:23
maintainer
docs_urlNone
authorESRF
requires_python>=3.6
licenseMIT
keywords ewoks
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "ewoks",
    "author": "ESRF",
    "author_email": "wout.de_nolf@esrf.fr",
    "download_url": "https://files.pythonhosted.org/packages/42/10/85a4308cdfded2776e5dfffb68732fc42923568fa71afbba38ebe744fff2/ewokscore-0.7.3.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.7.3",
    "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": "421085a4308cdfded2776e5dfffb68732fc42923568fa71afbba38ebe744fff2",
                "md5": "a581248cf92e68ca476f99992d4304ca",
                "sha256": "6043829022e0f6330232caf50c666e115703b26fee32cb1f9717e4890580a3b1"
            },
            "downloads": -1,
            "filename": "ewokscore-0.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "a581248cf92e68ca476f99992d4304ca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 73241,
            "upload_time": "2024-03-13T17:49:23",
            "upload_time_iso_8601": "2024-03-13T17:49:23.476927Z",
            "url": "https://files.pythonhosted.org/packages/42/10/85a4308cdfded2776e5dfffb68732fc42923568fa71afbba38ebe744fff2/ewokscore-0.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-13 17:49:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ewokscore"
}
        
Elapsed time: 0.20923s