Skip to content
File

Blob: src/workerd/server/tests/python/workflow-entrypoint/workflow-old.py

python38 lines
1# Copyright (c) 2025 Cloudflare, Inc.
2# Licensed under the Apache 2.0 license found in the LICENSE file or at:
3# https://opensource.org/licenses/Apache-2.0
4 
5from workers import WorkflowEntrypoint
6 
7 
8class PythonWorkflowDepends(WorkflowEntrypoint):
9 # Tests backward compatibility: legacy depends parameter with positional args
10 # and ctx support in step callbacks.
11 async def run(self, event, step):
12 @step.do("step_1")
13 async def step_1():
14 # tests backwards compat with workflows that don't have ctx in the step callback
15 print("Executing step 1")
16 return "foo"
17 
18 @step.do("step_2")
19 async def step_2(ctx):
20 if ctx is not None:
21 assert ctx["attempt"] == "1"
22 print("Executing step 2")
23 return "bar"
24 
25 @step.do("step_3", depends=[step_1, step_2], concurrent=True)
26 async def step_3(result1=(), ctx=None, result2=()):
27 if ctx is not None:
28 assert ctx["attempt"] == "1"
29 assert result1 == "foo"
30 assert result2 == "bar"
31 return result1 + result2
32 
33 return await step_3()
34 
35 
36async def test(ctrl, env, ctx):
37 pass