1- from restack_ai .workflow import workflow , log , workflow_info , NonRetryableError
21from pydantic import BaseModel
3- from .child import ChildWorkflow , ChildInput
2+ from restack_ai .workflow import NonRetryableError , log , workflow , workflow_info
3+
4+ from .child import ChildInput , ChildWorkflow
5+
46
57class ParentInput (BaseModel ):
68 child : bool = True
@@ -12,15 +14,15 @@ class ParentOutput(BaseModel):
1214class ParentWorkflow :
1315 @workflow .run
1416 async def run (self , workflow_input : ParentInput ) -> ParentOutput :
15-
17+
1618 log .info ("ParentWorkflow started" , workflow_input = workflow_input )
1719 if workflow_input .child :
1820 # use the parent run id to create child workflow ids
1921 parent_workflow_id = workflow_info ().workflow_id
2022
2123 log .info ("Start ChildWorkflow and dont wait for result" )
2224 # result = await workflow.child_start(ChildWorkflow, input=ChildInput(name="world"), workflow_id=f"{parent_workflow_id}-child-start")
23-
25+
2426 log .info ("Start ChildWorkflow and wait for result" )
2527 try :
2628 result = await workflow .child_execute (
@@ -34,7 +36,7 @@ async def run(self, workflow_input: ParentInput) -> ParentOutput:
3436 else :
3537 log .info ("ChildWorkflow completed" , result = result )
3638 return ParentOutput (result = "ParentWorkflow completed" )
37-
39+
3840 else :
3941 log .info ("ParentWorkflow without starting or executing child workflow" )
4042 return ParentOutput (result = "ParentWorkflow completed" )
0 commit comments