File tree Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ BEARER_TOKEN=<your-bearer-token>
4
4
# Restack Cloud (Optional)
5
5
6
6
# RESTACK_ENGINE_ID=<your-engine-id>
7
- # RESTACK_ENGINE_API_KEY=<your-engine-api-key>
8
7
# RESTACK_ENGINE_ADDRESS=<your-engine-address>
9
- # RESTACK_CLOUD_TOKEN=<your-cloud-token>
8
+ # RESTACK_ENGINE_API_KEY=<your-engine-api-key>
9
+ # RESTACK_ENGINE_API_ADDRESS=<your-engine-api-address>
Original file line number Diff line number Diff line change 11
11
async def main ():
12
12
await client .start_service (
13
13
workflows = [ParentWorkflow , ChildWorkflow ],
14
- functions = [welcome ],
15
- options = ServiceOptions (
16
- endpoints = True
17
- ),
14
+ functions = [welcome ]
18
15
)
19
16
20
17
def run_services ():
Original file line number Diff line number Diff line change 8
8
class ChildInput (BaseModel ):
9
9
name : str = "world"
10
10
11
+ class ChildOutput (BaseModel ):
12
+ result : str
13
+
11
14
@workflow .defn ()
12
15
class ChildWorkflow :
13
16
@workflow .run
14
- async def run (self , input : ChildInput ):
17
+ async def run (self , input : ChildInput ) -> ChildOutput :
15
18
log .info ("ChildWorkflow started" )
16
19
result = await workflow .step (welcome , input = input .name , start_to_close_timeout = timedelta (seconds = 120 ))
17
20
log .info ("ChildWorkflow completed" , result = result )
18
- return result
21
+ return ChildOutput ( result = result )
Original file line number Diff line number Diff line change 5
5
class ParentInput (BaseModel ):
6
6
child : bool = True
7
7
8
+ class ParentOutput (BaseModel ):
9
+ result : str
10
+
8
11
@workflow .defn ()
9
12
class ParentWorkflow :
10
13
@workflow .run
11
- async def run (self , input : ParentInput ):
14
+ async def run (self , input : ParentInput ) -> ParentOutput :
12
15
if input .child :
13
16
# use the parent run id to create child workflow ids
14
17
parent_workflow_id = workflow_info ().workflow_id
@@ -19,8 +22,8 @@ async def run(self, input: ParentInput):
19
22
log .info ("Start ChildWorkflow and wait for result" )
20
23
result = await workflow .child_execute (ChildWorkflow , input = ChildInput (name = "world" ), workflow_id = f"{ parent_workflow_id } -child-execute" )
21
24
log .info ("ChildWorkflow completed" , result = result )
22
- return "ParentWorkflow completed"
25
+ return ParentOutput ( result = "ParentWorkflow completed" )
23
26
24
27
else :
25
28
log .info ("ParentWorkflow without starting or executing child workflow" )
26
- return "ParentWorkflow completed"
29
+ return ParentOutput ( result = "ParentWorkflow completed" )
You can’t perform that action at this time.
0 commit comments