Skip to content

Commit ab0c71d

Browse files
committed
Run check
1 parent e693f1f commit ab0c71d

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

child_workflows/schedule_workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import asyncio
22
import time
3+
34
from restack_ai import Restack
45

6+
57
async def main():
68

79
client = Restack()
@@ -23,4 +25,4 @@ def run_schedule_workflow():
2325
asyncio.run(main())
2426

2527
if __name__ == "__main__":
26-
run_schedule_workflow()
28+
run_schedule_workflow()

child_workflows/src/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import os
2+
3+
from dotenv import load_dotenv
24
from restack_ai import Restack
35
from restack_ai.restack import CloudConnectionOptions
4-
from dotenv import load_dotenv
6+
57
# Load environment variables from a .env file
68
load_dotenv()
79

@@ -18,4 +20,4 @@
1820
api_address=api_address
1921
)
2022
print(connection_options)
21-
client = Restack(connection_options)
23+
client = Restack(connection_options)

child_workflows/src/functions/function.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from restack_ai.function import function, log, NonRetryableError
1+
from restack_ai.function import NonRetryableError, function, log
2+
23

34
@function.defn(name="welcome")
45
async def welcome(function_input: str) -> str:

child_workflows/src/services.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import asyncio
22
import os
33
import webbrowser
4+
45
from watchfiles import run_process
5-
from src.functions.function import welcome
6+
67
from src.client import client
7-
from src.workflows.parent import ParentWorkflow
8+
from src.functions.function import welcome
89
from src.workflows.child import ChildWorkflow
10+
from src.workflows.parent import ParentWorkflow
11+
912

1013
async def main():
1114
await client.start_service(
@@ -27,4 +30,4 @@ def watch_services():
2730
run_process(watch_path, recursive=True, target=run_services)
2831

2932
if __name__ == "__main__":
30-
run_services()
33+
run_services()

child_workflows/src/workflows/child.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from datetime import timedelta
2+
23
from pydantic import BaseModel
3-
from restack_ai.workflow import NonRetryableError, workflow, import_functions, log
4+
from restack_ai.workflow import NonRetryableError, import_functions, log, workflow
5+
46
with import_functions():
57
from src.functions.function import welcome
6-
8+
79

810
class ChildInput(BaseModel):
911
name: str = "world"

child_workflows/src/workflows/parent.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from restack_ai.workflow import workflow, log, workflow_info, NonRetryableError
21
from 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

57
class ParentInput(BaseModel):
68
child: bool = True
@@ -12,15 +14,15 @@ class ParentOutput(BaseModel):
1214
class 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

Comments
 (0)