mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-21 09:19:32 -05:00
chore: cleanup example (#184)
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
from hatchet_sdk import Hatchet
|
||||
from dotenv import load_dotenv
|
||||
import json
|
||||
|
||||
class StepRunEventType:
|
||||
STEP_RUN_EVENT_TYPE_STARTED = 'STEP_RUN_EVENT_TYPE_STARTED'
|
||||
STEP_RUN_EVENT_TYPE_COMPLETED = 'STEP_RUN_EVENT_TYPE_COMPLETED'
|
||||
STEP_RUN_EVENT_TYPE_FAILED = 'STEP_RUN_EVENT_TYPE_FAILED'
|
||||
STEP_RUN_EVENT_TYPE_CANCELLED = 'STEP_RUN_EVENT_TYPE_CANCELLED'
|
||||
STEP_RUN_EVENT_TYPE_TIMED_OUT = 'STEP_RUN_EVENT_TYPE_TIMED_OUT'
|
||||
|
||||
load_dotenv()
|
||||
|
||||
hatchet = Hatchet().client
|
||||
|
||||
workflowRunId = hatchet.admin.run_workflow("ManualTriggerWorkflow", {
|
||||
"test": "test"
|
||||
})
|
||||
|
||||
listener = hatchet.listener.stream(workflowRunId)
|
||||
|
||||
for event in listener:
|
||||
# TODO FIXME step run is not exported easily from the hatchet_sdk and event type and event.step is not defined on
|
||||
# the event object, so fix this before merging...
|
||||
|
||||
# if event.step == 'step2' and event.type == StepRunEventType.STEP_RUN_EVENT_TYPE_COMPLETED:
|
||||
# listener.abort()
|
||||
|
||||
if event.type == StepRunEventType.STEP_RUN_EVENT_TYPE_COMPLETED:
|
||||
print('Step completed: ' + json.dumps(event.payload))
|
||||
|
||||
print('Workflow finished')
|
||||
@@ -12,5 +12,3 @@ workflowRunId = client.admin.run_workflow("ManualTriggerWorkflow", {
|
||||
|
||||
client.listener.on(workflowRunId, lambda event: print(
|
||||
'EVENT: ' + event.type + ' ' + json.dumps(event.payload)))
|
||||
|
||||
# TODO - need to hangup the listener if the workflow is completed
|
||||
|
||||
Reference in New Issue
Block a user