mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-29 04:39:44 -06:00
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
36 lines
676 B
Python
36 lines
676 B
Python
# > Simple
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from hatchet_sdk import Context, Hatchet
|
|
|
|
hatchet = Hatchet(debug=True)
|
|
|
|
|
|
class SimpleInput(BaseModel):
|
|
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()
|