From a50579d837b67cbd8650f11f4345ca1bdae6945c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Aug 2025 15:24:07 -0400 Subject: [PATCH] chore: regenerate examples (#2208) Co-authored-by: GitHub Action --- examples/python/stubs/implementation.py | 19 ++++++++++++ examples/python/stubs/stub_trigger.py | 39 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 examples/python/stubs/implementation.py create mode 100644 examples/python/stubs/stub_trigger.py diff --git a/examples/python/stubs/implementation.py b/examples/python/stubs/implementation.py new file mode 100644 index 000000000..423851738 --- /dev/null +++ b/examples/python/stubs/implementation.py @@ -0,0 +1,19 @@ +from pydantic import BaseModel + +from hatchet_sdk import Context, Hatchet + + +class TaskInput(BaseModel): + user_id: int + + +class TaskOutput(BaseModel): + ok: bool + + +hatchet = Hatchet() + + +@hatchet.task(name="externally-triggered-task", input_validator=TaskInput) +async def externally_triggered_task(input: TaskInput, ctx: Context) -> TaskOutput: + return TaskOutput(ok=True) diff --git a/examples/python/stubs/stub_trigger.py b/examples/python/stubs/stub_trigger.py new file mode 100644 index 000000000..bd43142fb --- /dev/null +++ b/examples/python/stubs/stub_trigger.py @@ -0,0 +1,39 @@ +import asyncio + +from pydantic import BaseModel + +from hatchet_sdk import Context, Hatchet + + +# > Define models +class TaskInput(BaseModel): + user_id: int + + +class TaskOutput(BaseModel): + ok: bool + + + + +async def main() -> None: + hatchet = Hatchet() + + # > Create a stub task + stub = hatchet.stubs.task( + # make sure the name and schemas exactly match the implementation + name="externally-triggered-task", + input_validator=TaskInput, + output_validator=TaskOutput, + ) + + # > Trigger the task + # input type checks properly + result = await stub.aio_run(input=TaskInput(user_id=1234)) + + # `result.ok` type checks properly + print("Is successful:", result.ok) + + +if __name__ == "__main__": + asyncio.run(main())