Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ pip3 install -r tools/requirements.txt
./tools/regen_grpcclient.sh
```

> Note: The `grpcio-tools` version we're using doesn't support Python 3.13.

## Help & Feedback

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)).
Expand Down
3 changes: 3 additions & 0 deletions dapr/aio/clients/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,9 @@ async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWo

try:
resp = self._stub.GetWorkflowBeta1(req)
# not found workflows return no error, but empty status
if resp.runtime_status == '':
raise DaprInternalError('no such instance exists')
if resp.created_at is None:
resp.created_at = datetime.now
if resp.last_updated_at is None:
Expand Down
3 changes: 3 additions & 0 deletions dapr/clients/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,9 @@ def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflow

try:
resp = self.retry_policy.run_rpc(self._stub.GetWorkflowBeta1, req)
# not found workflows return no error, but empty status
if resp.runtime_status == '':
raise DaprInternalError('no such instance exists')
if resp.created_at is None:
resp.created_at = datetime.now()
if resp.last_updated_at is None:
Expand Down
78 changes: 66 additions & 12 deletions dapr/proto/runtime/v1/dapr_pb2.py

Large diffs are not rendered by default.

613 changes: 613 additions & 0 deletions dapr/proto/runtime/v1/dapr_pb2.pyi

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions dapr/proto/runtime/v1/dapr_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ def __init__(self, channel):
request_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequest.SerializeToString,
response_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponse.FromString,
)
self.ConverseAlpha2 = channel.unary_unary(
'/dapr.proto.runtime.v1.Dapr/ConverseAlpha2',
request_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequestAlpha2.SerializeToString,
response_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponseAlpha2.FromString,
)


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

def ConverseAlpha2(self, request, context):
"""Converse with a LLM service via alpha2 api
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_DaprServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand Down Expand Up @@ -1031,6 +1043,11 @@ def add_DaprServicer_to_server(servicer, server):
request_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequest.FromString,
response_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponse.SerializeToString,
),
'ConverseAlpha2': grpc.unary_unary_rpc_method_handler(
servicer.ConverseAlpha2,
request_deserializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequestAlpha2.FromString,
response_serializer=dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponseAlpha2.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'dapr.proto.runtime.v1.Dapr', rpc_method_handlers)
Expand Down Expand Up @@ -2044,3 +2061,20 @@ def ConverseAlpha1(request,
dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def ConverseAlpha2(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/dapr.proto.runtime.v1.Dapr/ConverseAlpha2',
dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationRequestAlpha2.SerializeToString,
dapr_dot_proto_dot_runtime_dot_v1_dot_dapr__pb2.ConversationResponseAlpha2.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
5 changes: 3 additions & 2 deletions examples/demo_workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ expected_stdout_lines:
- "== APP == Instance Successfully Purged"
- "== APP == Get response from hello_world_wf after terminate call: Terminated"
- "== APP == Get response from child_wf after terminate call: Terminated"
- "== APP == Instance Successfully Purged"
background: true
timeout_seconds: 30
timeout_seconds: 50
sleep: 15
-->

Expand Down Expand Up @@ -83,7 +84,7 @@ You should be able to see the following output:
== APP == Get response from hello_world_wf after resume call: Running
== APP == New counter value is: 111!
== APP == New counter value is: 1111!
== APP == Instance Successfully Purged
== APP == Get response from hello_world_wf after terminate call: Terminated
== APP == Get response from child_wf after terminate call: Terminated
== APP == Instance Successfully Purged
```
14 changes: 8 additions & 6 deletions examples/demo_workflow/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ def child_wf(ctx: DaprWorkflowContext):
def hello_act(ctx: WorkflowActivityContext, wf_input):
global counter
counter += wf_input
print(f'New counter value is: {counter}!', flush=True)
print(f'New counter value is: {counter}!')


def hello_retryable_act(ctx: WorkflowActivityContext):
global retry_count
if (retry_count % 2) == 0:
print(f'Retry count value is: {retry_count}!', flush=True)
print(f'Retry count value is: {retry_count}!')
retry_count += 1
raise ValueError('Retryable Error')
print(f'Retry count value is: {retry_count}! This print statement verifies retry', flush=True)
print(f'Retry count value is: {retry_count}! This print statement verifies retry')
retry_count += 1


def child_retryable_wf(ctx: DaprWorkflowContext):
global child_orchestrator_string, child_orchestrator_count
if not ctx.is_replaying:
child_orchestrator_count += 1
print(f'Appending {child_orchestrator_count} to child_orchestrator_string!', flush=True)
print(f'Appending {child_orchestrator_count} to child_orchestrator_string!')
child_orchestrator_string += str(child_orchestrator_count)
yield ctx.call_activity(
act_for_child_wf, input=child_orchestrator_count, retry_policy=retry_policy
Expand All @@ -97,7 +97,7 @@ def child_retryable_wf(ctx: DaprWorkflowContext):
def act_for_child_wf(ctx: WorkflowActivityContext, inp):
global child_orchestrator_string, child_act_retry_count
inp_char = chr(96 + inp)
print(f'Appending {inp_char} to child_orchestrator_string!', flush=True)
print(f'Appending {inp_char} to child_orchestrator_string!')
child_orchestrator_string += inp_char
if child_act_retry_count % 2 == 0:
child_act_retry_count += 1
Expand Down Expand Up @@ -165,6 +165,7 @@ def main():
sleep(5)
# Purge Test
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
sleep(5)
try:
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
except DaprInternalError as err:
Expand All @@ -186,7 +187,7 @@ def main():
sleep(5)
# Terminate Test
d.terminate_workflow(instance_id=instance_id, workflow_component=workflow_component)
sleep(1)
sleep(5)
get_response = d.get_workflow(
instance_id=instance_id, workflow_component=workflow_component
)
Expand All @@ -204,6 +205,7 @@ def main():

# Purge Test
d.purge_workflow(instance_id=instance_id, workflow_component=workflow_component)
sleep(5)
try:
d.get_workflow(instance_id=instance_id, workflow_component=workflow_component)
except DaprInternalError as err:
Expand Down