diff --git a/examples/python/dataclasses/trigger.py b/examples/python/dataclasses/trigger.py new file mode 100644 index 000000000..135568ce7 --- /dev/null +++ b/examples/python/dataclasses/trigger.py @@ -0,0 +1,3 @@ +from examples.dataclasses.worker import Input, say_hello + +say_hello.run(input=Input(name="Hatchet")) diff --git a/examples/python/dataclasses/worker.py b/examples/python/dataclasses/worker.py new file mode 100644 index 000000000..eeeeae8bf --- /dev/null +++ b/examples/python/dataclasses/worker.py @@ -0,0 +1,31 @@ +from dataclasses import dataclass +from typing import Literal + +from hatchet_sdk import Context, EmptyModel, Hatchet + + +@dataclass +class Input: + name: str + + +@dataclass +class Output: + message: str + + +hatchet = Hatchet(debug=True) + + +@hatchet.task(input_validator=Input) +def say_hello(input: Input, ctx: Context) -> Output: + return Output(message=f"Hello, {input.name}!") + + +def main() -> None: + worker = hatchet.worker("test-worker", workflows=[say_hello]) + worker.start() + + +if __name__ == "__main__": + main() diff --git a/examples/python/worker.py b/examples/python/worker.py index 3cd28f0b0..a8679eb34 100644 --- a/examples/python/worker.py +++ b/examples/python/worker.py @@ -21,6 +21,7 @@ from examples.concurrency_workflow_level.worker import ( ) from examples.conditions.worker import task_condition_workflow from examples.dag.worker import dag_workflow +from examples.dataclasses.worker import say_hello from examples.dedupe.worker import dedupe_child_wf, dedupe_parent_wf from examples.dependency_injection.worker import ( async_task_with_dependencies, @@ -92,6 +93,7 @@ def main() -> None: sync_task_with_dependencies, durable_async_task_with_dependencies, durable_sync_task_with_dependencies, + say_hello, ], lifespan=lifespan, )