Skip to content

Commit 32e4735

Browse files
committed
revert changes to example
Signed-off-by: Fabian Martinez <[email protected]>
1 parent 6b093c2 commit 32e4735

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

examples/demo_workflow/app.py

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from datetime import timedelta
1414
from time import sleep
1515
from dapr.ext.workflow import (
16-
DaprWorkflowClient,
1716
WorkflowRuntime,
1817
DaprWorkflowContext,
1918
WorkflowActivityContext,
@@ -107,7 +106,10 @@ def act_for_child_wf(ctx: WorkflowActivityContext, inp):
107106

108107

109108
def main():
110-
with DaprWorkflowClient() as wfc:
109+
# DEPRECATION NOTICE!
110+
# The workflow methods in the DaprClient are deprecated, instead use the client provided in dapr-ext-workflow
111+
# You can use the examples in https://github.com/dapr/python-sdk/tree/main/examples/workflow
112+
with DaprClient() as d:
111113
workflow_runtime = WorkflowRuntime()
112114
workflow_runtime.register_workflow(hello_world_wf)
113115
workflow_runtime.register_workflow(child_retryable_wf)
@@ -120,11 +122,14 @@ def main():
120122
sleep(2)
121123

122124
print('==========Start Counter Increase as per Input:==========')
123-
instance_id = wfc.schedule_new_workflow(
125+
start_resp = d.start_workflow(
124126
instance_id=instance_id,
125-
workflow=hello_world_wf,
126-
input=input_data)
127-
print(f'start_resp {instance_id}')
127+
workflow_component=workflow_component,
128+
workflow_name=workflow_name,
129+
input=input_data,
130+
workflow_options=workflow_options,
131+
)
132+
print(f'start_resp {start_resp.instance_id}')
128133

129134
# Sleep for a while to let the workflow run
130135
sleep(12)
@@ -133,73 +138,78 @@ def main():
133138
assert child_orchestrator_string == '1aa2bb3cc'
134139

135140
# Pause Test
136-
wfc.pause_workflow(instance_id=instance_id)
137-
get_response = wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
141+
d.pause_workflow(instance_id=instance_id, workflow_component=workflow_component)
142+
get_response = d.get_workflow(
143+
instance_id=instance_id, workflow_component=workflow_component
144+
)
138145
print(f'Get response from {workflow_name} after pause call: {get_response.runtime_status}')
139146

140147
# Resume Test
141-
wfc.resume_workflow(instance_id=instance_id)
142-
get_response = wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
148+
d.resume_workflow(instance_id=instance_id, workflow_component=workflow_component)
149+
get_response = d.get_workflow(
150+
instance_id=instance_id, workflow_component=workflow_component
151+
)
143152
print(f'Get response from {workflow_name} after resume call: {get_response.runtime_status}')
144153

145154
sleep(1)
146155
# Raise event
147-
wfc.raise_workflow_event(
148-
instance_id=instance_id,
156+
d.raise_workflow_event(
157+
instance_id=child_instance_id,
158+
workflow_component=workflow_component,
149159
event_name=event_name,
150-
data=event_data,
160+
event_data=event_data,
151161
)
152162

153163
sleep(5)
154164
# Purge Test
155-
# // TODO IMPLEMENT PURGE
156-
# d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
165+
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
157166
try:
158-
wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
159-
except Exception as err:
160-
# TODO temporary print
161-
print(f'got error {err}')
167+
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
168+
except DaprInternalError as err:
162169
if non_existent_id_error in err._message:
163170
print('Instance Successfully Purged')
164171

165172
# Kick off another workflow for termination purposes
166173
# This will also test using the same instance ID on a new workflow after
167174
# the old instance was purged
168-
instance_id = wfc.schedule_new_workflow(
175+
start_resp = d.start_workflow(
169176
instance_id=instance_id,
170-
workflow=hello_world_wf,
171-
input=input_data
177+
workflow_component=workflow_component,
178+
workflow_name=workflow_name,
179+
input=input_data,
180+
workflow_options=workflow_options,
172181
)
173-
print(f'start_resp {instance_id}')
182+
print(f'start_resp {start_resp.instance_id}')
174183

175184
sleep(5)
176185
# Terminate Test
177-
wfc.terminate_workflow(instance_id=instance_id)
186+
d.terminate_workflow(instance_id=instance_id, workflow_component=workflow_component)
178187
sleep(1)
179-
get_response = wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
188+
get_response = d.get_workflow(
189+
instance_id=instance_id, workflow_component=workflow_component
190+
)
180191
print(
181192
f'Get response from {workflow_name} '
182193
f'after terminate call: {get_response.runtime_status}'
183194
)
184-
child_get_response = wfc.get_workflow_state(
185-
instance_id=child_instance_id, fetch_payloads=True
195+
child_get_response = d.get_workflow(
196+
instance_id=child_instance_id, workflow_component=workflow_component
186197
)
187198
print(
188199
f'Get response from {child_workflow_name} '
189200
f'after terminate call: {child_get_response.runtime_status}'
190201
)
191202

192203
# Purge Test
193-
# TODO IMPLEMENT PURGE
194-
# d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
195-
# try:
196-
# d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
197-
# except DaprInternalError as err:
198-
# if non_existent_id_error in err._message:
199-
# print('Instance Successfully Purged')
204+
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
205+
try:
206+
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
207+
except DaprInternalError as err:
208+
if non_existent_id_error in err._message:
209+
print('Instance Successfully Purged')
200210

201211
workflow_runtime.shutdown()
202212

203213

204214
if __name__ == '__main__':
205-
main()
215+
main()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dapr-ext-workflow-dev>=0.4.1rc1.dev
1+
dapr-ext-workflow-dev>=0.0.1rc1.dev

0 commit comments

Comments
 (0)