mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-30 21:29:44 -06:00
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
30 lines
628 B
Python
30 lines
628 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()
|