mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-01 14:19:54 -06:00
* hotfix: add repository for npm publish * chore: generate protos * feat: trigger workflow * fix: remove tenant id from schedule workflow * fix: logging * feat: run returns workflow_run_id * feat: listen for run events * feat: listener calls handler * chore: address review comment
29 lines
647 B
Python
29 lines
647 B
Python
from hatchet_sdk import Hatchet
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
hatchet = Hatchet(debug=True)
|
|
|
|
|
|
@hatchet.workflow(on_events=["user:create"])
|
|
class ManualTriggerWorkflow:
|
|
@hatchet.step()
|
|
def step1(self, context):
|
|
print("executed step1")
|
|
return {"step1": "data1"}
|
|
|
|
@hatchet.step(parents=["step1"], timeout='4s')
|
|
def step2(self, context):
|
|
print("started step2")
|
|
context.sleep(1)
|
|
print("finished step2")
|
|
return {"step2": "data2"}
|
|
|
|
|
|
workflow = ManualTriggerWorkflow()
|
|
worker = hatchet.worker('test-worker', max_threads=4)
|
|
worker.register_workflow(workflow)
|
|
|
|
worker.start()
|