Files
hatchet/sdks/python/examples/child/worker.py
Gabe Ruttner 339f505612 Docs: run and wait, child run in run and wait, run no wait, bulk (#1472)
* run and wait

* run no wait

* bulk

* release: 1.1.1

* lint

* lint?

* lint

* lint?

* discord link

* separate examples

* lint

* prettier

* move new examples

* lint

* python...

* fix: python examples

* rm toolchain

---------

Co-authored-by: mrkaye97 <mrkaye97@gmail.com>
2025-04-02 12:20:19 -07:00

36 lines
699 B
Python

# ❓ Simple
from pydantic import BaseModel
from hatchet_sdk import Context, EmptyModel, Hatchet
hatchet = Hatchet(debug=True)
class SimpleInput(EmptyModel):
message: str
class SimpleOutput(BaseModel):
transformed_message: str
child_task = hatchet.workflow(name="SimpleWorkflow", input_validator=SimpleInput)
@child_task.task(name="step1")
def step1(input: SimpleInput, ctx: Context) -> SimpleOutput:
print("executed step1: ", input.message)
return SimpleOutput(transformed_message=input.message.upper())
def main() -> None:
worker = hatchet.worker("test-worker", slots=1, workflows=[child_task])
worker.start()
# ‼️
if __name__ == "__main__":
main()