Files
hatchet/sdks/python/examples/on_success/worker.py
Matt Kaye 5062bf1e3e V1 SDKs and Docs (#1361)
New SDKs and docs for the v1 release.
2025-03-25 15:45:07 -07:00

40 lines
1.0 KiB
Python

from hatchet_sdk import Context, EmptyModel, Hatchet
hatchet = Hatchet(debug=True)
on_success_workflow = hatchet.workflow(name="OnSuccessWorkflow")
@on_success_workflow.task()
def first_task(input: EmptyModel, ctx: Context) -> None:
print("First task completed successfully")
@on_success_workflow.task(parents=[first_task])
def second_task(input: EmptyModel, ctx: Context) -> None:
print("Second task completed successfully")
@on_success_workflow.task(parents=[first_task, second_task])
def third_task(input: EmptyModel, ctx: Context) -> None:
print("Third task completed successfully")
@on_success_workflow.task()
def fourth_task(input: EmptyModel, ctx: Context) -> None:
print("Fourth task completed successfully")
@on_success_workflow.on_success_task()
def on_success_task(input: EmptyModel, ctx: Context) -> None:
print("On success task completed successfully")
def main() -> None:
worker = hatchet.worker("on-success-worker", workflows=[on_success_workflow])
worker.start()
if __name__ == "__main__":
main()