Files
hatchet/sdks/python/examples/cron/workflow-definition.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

31 lines
635 B
Python

from hatchet_sdk import Context, EmptyModel, Hatchet
hatchet = Hatchet(debug=True)
# ❓ Workflow Definition Cron Trigger
# Adding a cron trigger to a workflow is as simple
# as adding a `cron expression` to the `on_cron`
# prop of the workflow definition
cron_workflow = hatchet.workflow(name="CronWorkflow", on_crons=["* * * * *"])
@cron_workflow.task()
def step1(input: EmptyModel, ctx: Context) -> dict[str, str]:
return {
"time": "step1",
}
# !!
def main() -> None:
worker = hatchet.worker("test-worker", slots=1, workflows=[cron_workflow])
worker.start()
if __name__ == "__main__":
main()