Skip to content

Commit 6b093c2

Browse files
committed
workflows, remove deprecated functions
Signed-off-by: Fabian Martinez <[email protected]>
1 parent 6e90e84 commit 6b093c2

File tree

7 files changed

+55
-46
lines changed

7 files changed

+55
-46
lines changed

dapr/aio/clients/grpc/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ async def start_workflow(
14081408
send_raw_bytes: bool = False,
14091409
) -> StartWorkflowResponse:
14101410
"""Starts a workflow.
1411+
Deprecated: use dapr-ext-workflow instead
14111412
14121413
Args:
14131414
workflow_component (str): the name of the workflow component
@@ -1469,6 +1470,7 @@ async def start_workflow(
14691470

14701471
async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflowResponse:
14711472
"""Gets information on a workflow.
1473+
Deprecated: use dapr-ext-workflow instead
14721474
14731475
Args:
14741476
instance_id (str): the ID of the workflow instance,
@@ -1510,6 +1512,7 @@ async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWo
15101512

15111513
async def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
15121514
"""Terminates a workflow.
1515+
Deprecated: use dapr-ext-workflow instead
15131516
15141517
Args:
15151518
instance_id (str): the ID of the workflow instance, e.g.
@@ -1547,6 +1550,7 @@ async def raise_workflow_event(
15471550
send_raw_bytes: bool = False,
15481551
) -> DaprResponse:
15491552
"""Raises an event on a workflow.
1553+
Deprecated: use dapr-ext-workflow instead
15501554
15511555
Args:
15521556
instance_id (str): the ID of the workflow instance,
@@ -1610,6 +1614,7 @@ async def raise_workflow_event(
16101614

16111615
async def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
16121616
"""Pause a workflow.
1617+
Deprecated: use dapr-ext-workflow instead
16131618
16141619
Args:
16151620
instance_id (str): the ID of the workflow instance,
@@ -1642,6 +1647,7 @@ async def pause_workflow(self, instance_id: str, workflow_component: str) -> Dap
16421647

16431648
async def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
16441649
"""Resumes a workflow.
1650+
Deprecated: use dapr-ext-workflow instead
16451651
16461652
Args:
16471653
instance_id (str): the ID of the workflow instance,
@@ -1673,6 +1679,7 @@ async def resume_workflow(self, instance_id: str, workflow_component: str) -> Da
16731679

16741680
async def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
16751681
"""Purges a workflow.
1682+
Deprecated: use dapr-ext-workflow instead
16761683
16771684
Args:
16781685
instance_id (str): the ID of the workflow instance,

dapr/clients/grpc/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ def start_workflow(
14091409
send_raw_bytes: bool = False,
14101410
) -> StartWorkflowResponse:
14111411
"""Starts a workflow.
1412+
Deprecated: use dapr-ext-workflow instead
14121413
14131414
Args:
14141415
workflow_component (str): the name of the workflow component
@@ -1466,6 +1467,7 @@ def start_workflow(
14661467

14671468
def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflowResponse:
14681469
"""Gets information on a workflow.
1470+
Deprecated: use dapr-ext-workflow instead
14691471
14701472
Args:
14711473
instance_id (str): the ID of the workflow instance,
@@ -1507,6 +1509,7 @@ def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflow
15071509

15081510
def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
15091511
"""Terminates a workflow.
1512+
Deprecated: use dapr-ext-workflow instead
15101513
15111514
Args:
15121515
instance_id (str): the ID of the workflow instance, e.g.
@@ -1545,6 +1548,7 @@ def raise_workflow_event(
15451548
send_raw_bytes: bool = False,
15461549
) -> DaprResponse:
15471550
"""Raises an event on a workflow.
1551+
Deprecated: use dapr-ext-workflow instead
15481552
15491553
Args:
15501554
instance_id (str): the ID of the workflow instance,
@@ -1609,6 +1613,7 @@ def raise_workflow_event(
16091613

16101614
def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
16111615
"""Pause a workflow.
1616+
Deprecated: use dapr-ext-workflow instead
16121617
16131618
Args:
16141619
instance_id (str): the ID of the workflow instance,
@@ -1641,6 +1646,7 @@ def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprRespo
16411646

16421647
def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
16431648
"""Resumes a workflow.
1649+
Deprecated: use dapr-ext-workflow instead
16441650
16451651
Args:
16461652
instance_id (str): the ID of the workflow instance,
@@ -1672,6 +1678,7 @@ def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResp
16721678

16731679
def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
16741680
"""Purges a workflow.
1681+
Deprecated: use dapr-ext-workflow instead
16751682
16761683
Args:
16771684
instance_id (str): the ID of the workflow instance,

examples/demo_workflow/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
This document describes how to register a workflow and activities inside it and start running it.
44
It demonstrates the following APIs:
5-
- **start_workflow**: Start an instance of a workflow
6-
- **get_workflow**: Get information on a single workflow
5+
- **schedule_new_workflow**: Start an instance of a workflow
6+
- **get_workflow_state**: Get information on a single workflow
77
- **terminate_workflow**: Terminate or stop a particular instance of a workflow
8-
- **raise_event**: Raise an event on a workflow
8+
- **raise_workflow_event**: Raise an event on a workflow
99
- **pause_workflow**: Pauses or suspends a workflow instance that can later be resumed
1010
- **resume_workflow**: Resumes a paused workflow instance
1111
- **purge_workflow**: Removes all metadata related to a specific workflow instance from the state store

examples/demo_workflow/app.py

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from datetime import timedelta
1414
from time import sleep
1515
from dapr.ext.workflow import (
16+
DaprWorkflowClient,
1617
WorkflowRuntime,
1718
DaprWorkflowContext,
1819
WorkflowActivityContext,
@@ -106,7 +107,7 @@ def act_for_child_wf(ctx: WorkflowActivityContext, inp):
106107

107108

108109
def main():
109-
with DaprClient() as d:
110+
with DaprWorkflowClient() as wfc:
110111
workflow_runtime = WorkflowRuntime()
111112
workflow_runtime.register_workflow(hello_world_wf)
112113
workflow_runtime.register_workflow(child_retryable_wf)
@@ -119,14 +120,11 @@ def main():
119120
sleep(2)
120121

121122
print('==========Start Counter Increase as per Input:==========')
122-
start_resp = d.start_workflow(
123+
instance_id = wfc.schedule_new_workflow(
123124
instance_id=instance_id,
124-
workflow_component=workflow_component,
125-
workflow_name=workflow_name,
126-
input=input_data,
127-
workflow_options=workflow_options,
128-
)
129-
print(f'start_resp {start_resp.instance_id}')
125+
workflow=hello_world_wf,
126+
input=input_data)
127+
print(f'start_resp {instance_id}')
130128

131129
# Sleep for a while to let the workflow run
132130
sleep(12)
@@ -135,75 +133,70 @@ def main():
135133
assert child_orchestrator_string == '1aa2bb3cc'
136134

137135
# Pause Test
138-
d.pause_workflow(instance_id=instance_id, workflow_component=workflow_component)
139-
get_response = d.get_workflow(
140-
instance_id=instance_id, workflow_component=workflow_component
141-
)
136+
wfc.pause_workflow(instance_id=instance_id)
137+
get_response = wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
142138
print(f'Get response from {workflow_name} after pause call: {get_response.runtime_status}')
143139

144140
# Resume Test
145-
d.resume_workflow(instance_id=instance_id, workflow_component=workflow_component)
146-
get_response = d.get_workflow(
147-
instance_id=instance_id, workflow_component=workflow_component
148-
)
141+
wfc.resume_workflow(instance_id=instance_id)
142+
get_response = wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
149143
print(f'Get response from {workflow_name} after resume call: {get_response.runtime_status}')
150144

151145
sleep(1)
152146
# Raise event
153-
d.raise_workflow_event(
154-
instance_id=child_instance_id,
155-
workflow_component=workflow_component,
147+
wfc.raise_workflow_event(
148+
instance_id=instance_id,
156149
event_name=event_name,
157-
event_data=event_data,
150+
data=event_data,
158151
)
159152

160153
sleep(5)
161154
# Purge Test
162-
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
155+
# // TODO IMPLEMENT PURGE
156+
# d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
163157
try:
164-
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
165-
except DaprInternalError as err:
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}')
166162
if non_existent_id_error in err._message:
167163
print('Instance Successfully Purged')
168164

169165
# Kick off another workflow for termination purposes
170166
# This will also test using the same instance ID on a new workflow after
171167
# the old instance was purged
172-
start_resp = d.start_workflow(
168+
instance_id = wfc.schedule_new_workflow(
173169
instance_id=instance_id,
174-
workflow_component=workflow_component,
175-
workflow_name=workflow_name,
176-
input=input_data,
177-
workflow_options=workflow_options,
170+
workflow=hello_world_wf,
171+
input=input_data
178172
)
179-
print(f'start_resp {start_resp.instance_id}')
173+
print(f'start_resp {instance_id}')
180174

181175
sleep(5)
182176
# Terminate Test
183-
d.terminate_workflow(instance_id=instance_id, workflow_component=workflow_component)
177+
wfc.terminate_workflow(instance_id=instance_id)
184178
sleep(1)
185-
get_response = d.get_workflow(
186-
instance_id=instance_id, workflow_component=workflow_component
187-
)
179+
get_response = wfc.get_workflow_state(instance_id=instance_id, fetch_payloads=True)
188180
print(
189181
f'Get response from {workflow_name} '
190182
f'after terminate call: {get_response.runtime_status}'
191183
)
192-
child_get_response = d.get_workflow(
193-
instance_id=child_instance_id, workflow_component=workflow_component
184+
child_get_response = wfc.get_workflow_state(
185+
instance_id=child_instance_id, fetch_payloads=True
194186
)
195187
print(
196188
f'Get response from {child_workflow_name} '
197189
f'after terminate call: {child_get_response.runtime_status}'
198190
)
199191

200192
# Purge Test
201-
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
202-
try:
203-
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
204-
except DaprInternalError as err:
205-
if non_existent_id_error in err._message:
206-
print('Instance Successfully Purged')
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')
207200

208201
workflow_runtime.shutdown()
209202

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dapr-ext-workflow-dev>=0.0.1rc1.dev
1+
dapr-ext-workflow-dev>=0.4.1rc1.dev

ext/dapr-ext-workflow/tests/test_workflow_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ def test_client_functions(self):
119119

120120
actual_resume_result = wfClient.resume_workflow(instance_id=mockInstanceId)
121121
assert actual_resume_result == mock_resume_result
122+
123+
# TODO add purge support

tests/clients/test_dapr_grpc_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ def test_unlock_input_validation(self):
864864
# Tests for workflow
865865
#
866866

867-
def test_workflow(self):
867+
def test_workflow_deprecated(self):
868868
dapr = DaprGrpcClient(f'{self.scheme}localhost:{self.grpc_port}')
869869
# Sane parameters
870870
workflow_name = 'test_workflow'

0 commit comments

Comments
 (0)