yo look at that they RUNNING
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
from wf_core import END, RuntimeContext, Workflow, execute_workflow
|
||||
from wf_core import (
|
||||
END,
|
||||
RunState,
|
||||
RunStatus,
|
||||
RuntimeContext,
|
||||
Workflow,
|
||||
execute_workflow,
|
||||
resume_workflow,
|
||||
step_workflow,
|
||||
)
|
||||
|
||||
|
||||
workflow = Workflow.model_validate(
|
||||
@@ -197,10 +206,28 @@ registry = {
|
||||
"mark_email_skipped": mark_email_skipped,
|
||||
}
|
||||
|
||||
result = execute_workflow(
|
||||
workflow,
|
||||
{"folder_id": "demo-folder", "should_email": False},
|
||||
registry,
|
||||
workflow_input = {"folder_id": "demo-folder", "should_email": False}
|
||||
|
||||
step_run = RunState(
|
||||
workflow_name=workflow.name,
|
||||
status=RunStatus.PENDING,
|
||||
workflow_input=dict(workflow_input),
|
||||
state=dict(workflow_input),
|
||||
current_node_id=workflow.start,
|
||||
)
|
||||
|
||||
print(json.dumps(result.to_dict(), indent=2))
|
||||
workflow.validate_structure().raise_for_errors()
|
||||
|
||||
print("Step-by-step run:")
|
||||
while step_run.current_node_id != END:
|
||||
step_workflow(workflow, step_run, registry)
|
||||
print(json.dumps(step_run.to_dict(), indent=2))
|
||||
|
||||
step_run = resume_workflow(workflow, step_run, registry)
|
||||
|
||||
print("Completed stepped run:")
|
||||
print(json.dumps(step_run.to_dict(), indent=2))
|
||||
|
||||
print("One-shot run:")
|
||||
full_run = execute_workflow(workflow, workflow_input, registry)
|
||||
print(json.dumps(full_run.to_dict(), indent=2))
|
||||
|
||||
@@ -86,6 +86,10 @@ def step_workflow(
|
||||
if run.current_node_id is None or run.current_node_id == END:
|
||||
return run
|
||||
|
||||
if run.status == RunStatus.PENDING:
|
||||
run.status = RunStatus.RUNNING
|
||||
run.error = None
|
||||
|
||||
node_defs = node_defs or {node_def.name: node_def for node_def in workflow.node_defs}
|
||||
nodes_by_id = nodes_by_id or {node.id: node for node in workflow.nodes}
|
||||
edge_map = edge_map or {(edge.from_, edge.outcome): edge.to for edge in workflow.edges}
|
||||
|
||||
Reference in New Issue
Block a user