Skip to content

Commit a7bde02

Browse files
Latest protos and account for no error returned on getting non existant workflow (#821)
* Latest protos Signed-off-by: Elena Kolevska <elena@kolevska.com> * Adds sleep to test Signed-off-by: Elena Kolevska <elena@kolevska.com> * Increases sleep Signed-off-by: Elena Kolevska <elena@kolevska.com> * Fix legacy demo_workflow example Signed-off-by: Albert Callarisa <albert@diagrid.io> * linter Signed-off-by: Elena Kolevska <elena@kolevska.com> * Keeps same api Signed-off-by: Elena Kolevska <elena@kolevska.com> * Fixes missing line in mechanical markdown Signed-off-by: Elena Kolevska <elena@kolevska.com> * Updates proto for 1.16.0-rc.3 Signed-off-by: Elena Kolevska <elena@kolevska.com> * Revert "Updates proto for 1.16.0-rc.3" This reverts commit 4e86b1f. Signed-off-by: Elena Kolevska <elena@kolevska.com> --------- Signed-off-by: Elena Kolevska <elena@kolevska.com> Signed-off-by: Albert Callarisa <albert@diagrid.io> Co-authored-by: Albert Callarisa <albert@diagrid.io>
1 parent e542624 commit a7bde02

File tree

8 files changed

+732
-20
lines changed

8 files changed

+732
-20
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ pip3 install -r tools/requirements.txt
143143
./tools/regen_grpcclient.sh
144144
```
145145

146+
> Note: The `grpcio-tools` version we're using doesn't support Python 3.13.
147+
146148
## Help & Feedback
147149

148150
Need help or have feedback on the SDK? Please open a GitHub issue or come chat with us in the `#python-sdk` channel of our Discord server ([click here to join](https://discord.gg/MySdVxrH)).

dapr/aio/clients/grpc/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,9 @@ async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWo
15011501

15021502
try:
15031503
resp = self._stub.GetWorkflowBeta1(req)
1504+
# not found workflows return no error, but empty status
1505+
if resp.runtime_status == '':
1506+
raise DaprInternalError('no such instance exists')
15041507
if resp.created_at is None:
15051508
resp.created_at = datetime.now
15061509
if resp.last_updated_at is None:

dapr/clients/grpc/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,9 @@ def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflow
15021502

15031503
try:
15041504
resp = self.retry_policy.run_rpc(self._stub.GetWorkflowBeta1, req)
1505+
# not found workflows return no error, but empty status
1506+
if resp.runtime_status == '':
1507+
raise DaprInternalError('no such instance exists')
15051508
if resp.created_at is None:
15061509
resp.created_at = datetime.now()
15071510
if resp.last_updated_at is None:

dapr/proto/runtime/v1/dapr_pb2.py

Lines changed: 66 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dapr/proto/runtime/v1/dapr_pb2.pyi

Lines changed: 613 additions & 0 deletions
Large diffs are not rendered by default.

dapr/proto/runtime/v1/dapr_pb2_grpc.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ def __init__(self, channel):
312312
request_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequest.SerializeToString,
313313
response_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponse.FromString,
314314
)
315+
self.ConverseAlpha2 = channel.unary_unary(
316+
'/dapr.proto.runtime.v1.Dapr/ConverseAlpha2',
317+
request_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequestAlpha2.SerializeToString,
318+
response_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponseAlpha2.FromString,
319+
)
315320

316321

317322
class DaprServicer(object):
@@ -733,6 +738,13 @@ def ConverseAlpha1(self, request, context):
733738
context.set_details('Method not implemented!')
734739
raise NotImplementedError('Method not implemented!')
735740

741+
def ConverseAlpha2(self, request, context):
742+
"""Converse with a LLM service via alpha2 api
743+
"""
744+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
745+
context.set_details('Method not implemented!')
746+
raise NotImplementedError('Method not implemented!')
747+
736748

737749
def add_DaprServicer_to_server(servicer, server):
738750
rpc_method_handlers = {
@@ -1031,6 +1043,11 @@ def add_DaprServicer_to_server(servicer, server):
10311043
request_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequest.FromString,
10321044
response_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponse.SerializeToString,
10331045
),
1046+
'ConverseAlpha2': grpc.unary_unary_rpc_method_handler(
1047+
servicer.ConverseAlpha2,
1048+
request_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequestAlpha2.FromString,
1049+
response_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponseAlpha2.SerializeToString,
1050+
),
10341051
}
10351052
generic_handler = grpc.method_handlers_generic_handler(
10361053
'dapr.proto.runtime.v1.Dapr', rpc_method_handlers)
@@ -2044,3 +2061,20 @@ def ConverseAlpha1(request,
20442061
dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponse.FromString,
20452062
options, channel_credentials,
20462063
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
2064+
2065+
@staticmethod
2066+
def ConverseAlpha2(request,
2067+
target,
2068+
options=(),
2069+
channel_credentials=None,
2070+
call_credentials=None,
2071+
insecure=False,
2072+
compression=None,
2073+
wait_for_ready=None,
2074+
timeout=None,
2075+
metadata=None):
2076+
return grpc.experimental.unary_unary(request, target, '/dapr.proto.runtime.v1.Dapr/ConverseAlpha2',
2077+
dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequestAlpha2.SerializeToString,
2078+
dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponseAlpha2.FromString,
2079+
options, channel_credentials,
2080+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

examples/demo_workflow/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ expected_stdout_lines:
5252
- "== APP == Instance Successfully Purged"
5353
- "== APP == Get response from hello_world_wf after terminate call: Terminated"
5454
- "== APP == Get response from child_wf after terminate call: Terminated"
55+
- "== APP == Instance Successfully Purged"
5556
background: true
56-
timeout_seconds: 30
57+
timeout_seconds: 50
5758
sleep: 15
5859
-->
5960

@@ -83,7 +84,7 @@ You should be able to see the following output:
8384
== APP == Get response from hello_world_wf after resume call: Running
8485
== APP == New counter value is: 111!
8586
== APP == New counter value is: 1111!
86-
== APP == Instance Successfully Purged
8787
== APP == Get response from hello_world_wf after terminate call: Terminated
8888
== APP == Get response from child_wf after terminate call: Terminated
89+
== APP == Instance Successfully Purged
8990
```

examples/demo_workflow/app.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,24 @@ def child_wf(ctx: DaprWorkflowContext):
6868
def hello_act(ctx: WorkflowActivityContext, wf_input):
6969
global counter
7070
counter += wf_input
71-
print(f'New counter value is: {counter}!', flush=True)
71+
print(f'New counter value is: {counter}!')
7272

7373

7474
def hello_retryable_act(ctx: WorkflowActivityContext):
7575
global retry_count
7676
if (retry_count % 2) == 0:
77-
print(f'Retry count value is: {retry_count}!', flush=True)
77+
print(f'Retry count value is: {retry_count}!')
7878
retry_count += 1
7979
raise ValueError('Retryable Error')
80-
print(f'Retry count value is: {retry_count}! This print statement verifies retry', flush=True)
80+
print(f'Retry count value is: {retry_count}! This print statement verifies retry')
8181
retry_count += 1
8282

8383

8484
def child_retryable_wf(ctx: DaprWorkflowContext):
8585
global child_orchestrator_string, child_orchestrator_count
8686
if not ctx.is_replaying:
8787
child_orchestrator_count += 1
88-
print(f'Appending {child_orchestrator_count} to child_orchestrator_string!', flush=True)
88+
print(f'Appending {child_orchestrator_count} to child_orchestrator_string!')
8989
child_orchestrator_string += str(child_orchestrator_count)
9090
yield ctx.call_activity(
9191
act_for_child_wf, input=child_orchestrator_count, retry_policy=retry_policy
@@ -97,7 +97,7 @@ def child_retryable_wf(ctx: DaprWorkflowContext):
9797
def act_for_child_wf(ctx: WorkflowActivityContext, inp):
9898
global child_orchestrator_string, child_act_retry_count
9999
inp_char = chr(96 + inp)
100-
print(f'Appending {inp_char} to child_orchestrator_string!', flush=True)
100+
print(f'Appending {inp_char} to child_orchestrator_string!')
101101
child_orchestrator_string += inp_char
102102
if child_act_retry_count % 2 == 0:
103103
child_act_retry_count += 1
@@ -165,6 +165,7 @@ def main():
165165
sleep(5)
166166
# Purge Test
167167
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
168+
sleep(5)
168169
try:
169170
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
170171
except DaprInternalError as err:
@@ -186,7 +187,7 @@ def main():
186187
sleep(5)
187188
# Terminate Test
188189
d.terminate_workflow(instance_id=instance_id, workflow_component=workflow_component)
189-
sleep(1)
190+
sleep(5)
190191
get_response = d.get_workflow(
191192
instance_id=instance_id, workflow_component=workflow_component
192193
)
@@ -204,6 +205,7 @@ def main():
204205

205206
# Purge Test
206207
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
208+
sleep(5)
207209
try:
208210
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
209211
except DaprInternalError as err:

0 commit comments

Comments
 (0)