@@ -22,9 +22,9 @@ def execute_workflow(
2222 # [START workflows_api_quickstart]
2323 import time
2424
25- from google .cloud import workflows_v1beta
26- from google .cloud .workflows import executions_v1beta
27- from google .cloud .workflows .executions_v1beta .types import executions
25+ from google .cloud import workflows_v1
26+ from google .cloud .workflows import executions_v1
27+ from google .cloud .workflows .executions_v1 .types import executions
2828
2929 # TODO(developer): Uncomment these lines and replace with your values.
3030 # project = 'my-project-id'
@@ -35,8 +35,8 @@ def execute_workflow(
3535 raise Exception ('GOOGLE_CLOUD_PROJECT env var is required.' )
3636
3737 # Set up API clients.
38- execution_client = executions_v1beta .ExecutionsClient ()
39- workflows_client = workflows_v1beta .WorkflowsClient ()
38+ execution_client = executions_v1 .ExecutionsClient ()
39+ workflows_client = workflows_v1 .WorkflowsClient ()
4040
4141 # Construct the fully qualified location path.
4242 parent = workflows_client .workflow_path (project , location , workflow )
@@ -50,18 +50,20 @@ def execute_workflow(
5050 backoff_delay = 1 # Start wait with delay of 1 second
5151 print ('Poll every second for result...' )
5252 while (not execution_finished ):
53- execution = execution_client .get_execution (request = {"name" : response .name })
53+ execution = execution_client .get_execution (
54+ request = {"name" : response .name })
5455 execution_finished = execution .state != executions .Execution .State .ACTIVE
5556
5657 # If we haven't seen the result yet, wait a second.
5758 if not execution_finished :
5859 print ('- Waiting for results...' )
5960 time .sleep (backoff_delay )
60- backoff_delay *= 2 # Double the delay to provide exponential backoff.
61+ # Double the delay to provide exponential backoff.
62+ backoff_delay *= 2
6163 else :
6264 print (f'Execution finished with state: { execution .state .name } ' )
63- print (execution .result )
64- return execution . result
65+ print (f'Execution results: { execution .result } ' )
66+ return execution
6567 # [END workflows_api_quickstart]
6668
6769
0 commit comments