Name | hymir JSON |
Version |
0.1.6
JSON |
| download |
home_page | None |
Summary | Simple workflows. |
upload_time | 2024-04-02 14:39:47 |
maintainer | None |
docs_url | None |
author | Tyler Kennedy |
requires_python | <4.0,>=3.10 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Hymir
Hymir is a python library for creating and running simple workflows by composing
together Chains (which run sequentially) and Groups (which run in parallel) of
jobs.
Hymir is built on top of [redis][] for intermediate storage and tracking
workflow state, and comes with an Executor for running the workflows using
[Celery][].
## Installation
```bash
pip install hymir
```
## Usage
Using the `@job` decorator is the simplest way to define a job. The decorated
function should return a `Success`, `Failure`, `Retry`, or `CheckLater` object.
The only limitations are:
- The decorated function must be importable from other files
(`from mymodule import myjob` should work)
- The outputs and inputs of a job must be JSON-safe.
When jobs depend on the output of other jobs, you can specify the inputs of the
job using the `inputs` parameter of the `@job` decorator and the output of the
job using the `output` parameter.
```python
from hymir.job import Success
from hymir.config import Config, set_configuration
from hymir.executors.celery import CeleryExecutor
from hymir.workflow import (
Workflow,
job,
Group,
Chain,
)
@set_configuration
def set_config(config: Config):
config.redis_url = "redis://localhost:6379/0"
@job(output="words")
def uppercase_word(word: str):
return Success(word.upper())
@job(inputs=["words"], output="count")
def count_uppercase_words(words: list[str]):
count = sum(1 for word in words if word.isupper())
return Success(count)
workflow = Workflow(
Chain(
Group(
uppercase_word("hello"),
uppercase_word("world"),
),
count_uppercase_words()
)
)
# This assumes you've already setup & configured a celery app before you
# get here.
executor = CeleryExecutor()
workflow_id = executor.run(workflow)
```
[Celery]: https://docs.celeryproject.org/en/stable/
[Redis]: https://redis.io/
Raw data
{
"_id": null,
"home_page": null,
"name": "hymir",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Tyler Kennedy",
"author_email": "tk@tkte.ch",
"download_url": "https://files.pythonhosted.org/packages/72/a3/cad7a054a18391fbd304ad4f94742b7aa42cff2a880f8a17434ef266c98e/hymir-0.1.6.tar.gz",
"platform": null,
"description": "# Hymir\n\nHymir is a python library for creating and running simple workflows by composing\ntogether Chains (which run sequentially) and Groups (which run in parallel) of\njobs.\n\nHymir is built on top of [redis][] for intermediate storage and tracking\nworkflow state, and comes with an Executor for running the workflows using\n[Celery][].\n\n## Installation\n\n```bash\npip install hymir\n```\n\n## Usage\n\nUsing the `@job` decorator is the simplest way to define a job. The decorated\nfunction should return a `Success`, `Failure`, `Retry`, or `CheckLater` object.\nThe only limitations are:\n\n- The decorated function must be importable from other files\n (`from mymodule import myjob` should work)\n- The outputs and inputs of a job must be JSON-safe.\n\nWhen jobs depend on the output of other jobs, you can specify the inputs of the\njob using the `inputs` parameter of the `@job` decorator and the output of the\njob using the `output` parameter.\n\n```python\nfrom hymir.job import Success\nfrom hymir.config import Config, set_configuration\nfrom hymir.executors.celery import CeleryExecutor\nfrom hymir.workflow import (\n Workflow,\n job,\n Group,\n Chain,\n)\n\n\n@set_configuration\ndef set_config(config: Config):\n config.redis_url = \"redis://localhost:6379/0\"\n \n \n@job(output=\"words\")\ndef uppercase_word(word: str):\n return Success(word.upper())\n\n\n@job(inputs=[\"words\"], output=\"count\")\ndef count_uppercase_words(words: list[str]):\n count = sum(1 for word in words if word.isupper())\n return Success(count)\n\n\nworkflow = Workflow(\n Chain(\n Group(\n uppercase_word(\"hello\"),\n uppercase_word(\"world\"),\n ),\n count_uppercase_words()\n )\n)\n\n# This assumes you've already setup & configured a celery app before you\n# get here.\nexecutor = CeleryExecutor()\nworkflow_id = executor.run(workflow)\n```\n\n[Celery]: https://docs.celeryproject.org/en/stable/\n[Redis]: https://redis.io/\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple workflows.",
"version": "0.1.6",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e415cbb7a927fbe90d467d0640c11d05fd7635f4f70ebcb89a55b65d8f0fb468",
"md5": "a29e79c402dbf335d0bc9872458a6ea2",
"sha256": "3afe66908c43161d261d1557120740807e1b112b35fb69edd826fe7ab53c84fd"
},
"downloads": -1,
"filename": "hymir-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a29e79c402dbf335d0bc9872458a6ea2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 14891,
"upload_time": "2024-04-02T14:39:46",
"upload_time_iso_8601": "2024-04-02T14:39:46.061850Z",
"url": "https://files.pythonhosted.org/packages/e4/15/cbb7a927fbe90d467d0640c11d05fd7635f4f70ebcb89a55b65d8f0fb468/hymir-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "72a3cad7a054a18391fbd304ad4f94742b7aa42cff2a880f8a17434ef266c98e",
"md5": "b46d200e5eb953cbcd37c77be2c26f87",
"sha256": "13fffd6e8b3bdcd09166a250557e98d0cf212f38df099eaf2fbe09c9a7d2f922"
},
"downloads": -1,
"filename": "hymir-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "b46d200e5eb953cbcd37c77be2c26f87",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 12326,
"upload_time": "2024-04-02T14:39:47",
"upload_time_iso_8601": "2024-04-02T14:39:47.311488Z",
"url": "https://files.pythonhosted.org/packages/72/a3/cad7a054a18391fbd304ad4f94742b7aa42cff2a880f8a17434ef266c98e/hymir-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-02 14:39:47",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "hymir"
}