Skip to content

Commit aac5058

Browse files
committed
Merge branch 'main' into filinto/agent-tool-calling
2 parents cf57edf + 147f1c4 commit aac5058

File tree

14 files changed

+87
-16
lines changed

14 files changed

+87
-16
lines changed

.github/workflows/fossa.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343
uses: actions/checkout@v4
4444

4545
- name: "Run FOSSA Scan"
46-
uses: fossas/fossa-action@v1.4.0 # Use a specific version if locking is preferred
46+
uses: fossas/fossa-action@v1.7.0 # Use a specific version if locking is preferred
4747
with:
4848
api-key: ${{ env.FOSSA_API_KEY }}
4949

5050
- name: "Run FOSSA Test"
51-
uses: fossas/fossa-action@v1.4.0 # Use a specific version if locking is preferred
51+
uses: fossas/fossa-action@v1.7.0 # Use a specific version if locking is preferred
5252
with:
5353
api-key: ${{ env.FOSSA_API_KEY }}
5454
run-tests: true

dapr/actor/runtime/_reminder_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(
3636
reminder_name: str,
3737
state: Optional[bytes],
3838
due_time: timedelta,
39-
period: timedelta,
39+
period: Optional[timedelta] = None,
4040
ttl: Optional[timedelta] = None,
4141
):
4242
"""Creates new :class:`ActorReminderData` instance.
@@ -77,7 +77,7 @@ def due_time(self) -> timedelta:
7777
return self._due_time
7878

7979
@property
80-
def period(self) -> timedelta:
80+
def period(self) -> Optional[timedelta]:
8181
"""Gets period of Actor Reminder."""
8282
return self._period
8383

dapr/actor/runtime/actor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async def register_reminder(
112112
name: str,
113113
state: bytes,
114114
due_time: timedelta,
115-
period: timedelta,
115+
period: Optional[timedelta] = None,
116116
ttl: Optional[timedelta] = None,
117117
) -> None:
118118
"""Registers actor reminder.

dapr/actor/runtime/mock_actor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def register_reminder(
8686
name: str,
8787
state: bytes,
8888
due_time: timedelta,
89-
period: timedelta,
89+
period: Optional[timedelta] = None,
9090
ttl: Optional[timedelta] = None,
9191
) -> None:
9292
"""Adds actor reminder to self._state_manager._mock_reminders.

dapr/actor/runtime/state_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def ttl_in_seconds(self) -> Optional[int]:
5656
return self._ttl_in_seconds
5757

5858
@ttl_in_seconds.setter
59-
def ttl_in_seconds(self, new_ttl_in_seconds: int) -> None:
59+
def ttl_in_seconds(self, new_ttl_in_seconds: Optional[int]) -> None:
6060
self._ttl_in_seconds = new_ttl_in_seconds
6161

6262

dapr/clients/grpc/_request.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
"""
24
Copyright 2023 The Dapr Authors
35
Licensed under the Apache License, Version 2.0 (the "License");
@@ -70,6 +72,7 @@ def get_metadata(self, as_dict: bool = False) -> Union[MetadataDict, MetadataTup
7072
return tuple_to_dict(self._metadata)
7173
return self._metadata
7274

75+
7376
class InvokeMethodRequest(DaprRequest):
7477
"""A request data representation for invoke_method API.
7578
@@ -103,10 +106,10 @@ def __init__(
103106
Raises:
104107
ValueError: data is not supported.
105108
"""
106-
super().__init__(())
109+
super(InvokeMethodRequest, self).__init__(())
107110

108111
self._content_type = content_type
109-
self._http_verb = None
112+
self._http_verb: Optional[str] = None
110113
self._http_querystring: Dict[str, str] = {}
111114

112115
self.set_data(data)
@@ -124,7 +127,7 @@ def http_verb(self) -> Optional[str]:
124127
@http_verb.setter
125128
def http_verb(self, val: Optional[str]) -> None:
126129
"""Sets HTTP method to Dapr invocation request."""
127-
if val not in self.HTTP_METHODS:
130+
if val is not None and val not in self.HTTP_METHODS:
128131
raise ValueError(f'{val} is the invalid HTTP verb.')
129132
self._http_verb = val
130133

@@ -213,6 +216,7 @@ def content_type(self, val: Optional[str]) -> None:
213216
"""Sets content type for bytes data."""
214217
self._content_type = val
215218

219+
216220
class BindingRequest(DaprRequest):
217221
"""A request data representation for invoke_binding API.
218222
@@ -224,7 +228,7 @@ class BindingRequest(DaprRequest):
224228
metadata (Dict[str, str]): the metadata sent to the binding.
225229
"""
226230

227-
def __init__(self, data: Union[str, bytes], binding_metadata: Optional[Dict[str, str]] = None):
231+
def __init__(self, data: Union[str, bytes], binding_metadata: Dict[str, str] = {}):
228232
"""Inits BindingRequest with data and metadata if given.
229233
230234
Args:
@@ -234,9 +238,9 @@ def __init__(self, data: Union[str, bytes], binding_metadata: Optional[Dict[str,
234238
Raises:
235239
ValueError: data is not bytes or str.
236240
"""
237-
super().__init__(())
241+
super(BindingRequest, self).__init__(())
238242
self.data = data # type: ignore
239-
self._binding_metadata = binding_metadata or {}
243+
self._binding_metadata = binding_metadata
240244

241245
@property
242246
def data(self) -> bytes:
@@ -257,12 +261,14 @@ def binding_metadata(self):
257261
"""Gets the metadata for output binding."""
258262
return self._binding_metadata
259263

264+
260265
class TransactionOperationType(Enum):
261266
"""Represents the type of operation for a Dapr Transaction State Api Call"""
262267

263268
upsert = 'upsert'
264269
delete = 'delete'
265270

271+
266272
class TransactionalStateOperation:
267273
"""An upsert or delete operation for a state transaction, 'upsert' by default.
268274
@@ -279,6 +285,7 @@ def __init__(
279285
data: Optional[Union[bytes, str]] = None,
280286
etag: Optional[str] = None,
281287
operation_type: TransactionOperationType = TransactionOperationType.upsert,
288+
metadata: Optional[Dict[str, str]] = None,
282289
):
283290
"""Initializes TransactionalStateOperation item from
284291
:obj:`runtime_v1.TransactionalStateOperation`.
@@ -299,6 +306,7 @@ def __init__(
299306
self._data = data # type: ignore
300307
self._etag = etag
301308
self._operation_type = operation_type
309+
self._metadata = metadata
302310

303311
@property
304312
def key(self) -> str:
@@ -320,6 +328,12 @@ def operation_type(self) -> TransactionOperationType:
320328
"""Gets etag."""
321329
return self._operation_type
322330

331+
@property
332+
def metadata(self) -> Dict[str, str]:
333+
"""Gets metadata."""
334+
return {} if self._metadata is None else self._metadata
335+
336+
323337
class EncryptRequestIterator(DaprRequest):
324338
"""An iterator for cryptography encrypt API requests.
325339
@@ -366,6 +380,7 @@ def __next__(self):
366380
self.seq += 1
367381
return request_proto
368382

383+
369384
class DecryptRequestIterator(DaprRequest):
370385
"""An iterator for cryptography decrypt API requests.
371386

dapr/clients/grpc/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ def execute_state_transaction(
939939
key=o.key,
940940
value=to_bytes(o.data) if o.data is not None else to_bytes(''),
941941
etag=common_v1.Etag(value=o.etag) if o.etag is not None else None,
942+
metadata=o.metadata,
942943
),
943944
)
944945
for o in operations

daprdocs/content/en/python-sdk-docs/python-sdk-extensions/python-fastapi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class RawEventModel(BaseModel):
4747

4848
class User(BaseModel):
4949
id: int
50-
name = 'Jane Doe'
50+
name: str
5151

5252
class CloudEventModel(BaseModel):
5353
data: User

examples/state_store/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ expected_stdout_lines:
4141
- "== APP == Cannot save bulk due to bad etags. ErrorCode=StatusCode.ABORTED"
4242
- "== APP == Got value=b'value_1' eTag=1"
4343
- "== APP == Got items with etags: [(b'value_1_updated', '2'), (b'value_2', '2')]"
44+
- "== APP == Transaction with outbox pattern executed successfully!"
45+
- "== APP == Got value after outbox pattern: b'val1'"
4446
- "== APP == Got values after transaction delete: [b'', b'']"
4547
- "== APP == Got value after delete: b''"
4648
timeout_seconds: 5
4749
-->
4850

4951
```bash
50-
dapr run -- python3 state_store.py
52+
dapr run --resources-path components/ -- python3 state_store.py
5153
```
5254
<!-- END_STEP -->
5355

@@ -68,6 +70,10 @@ The output should be as follows:
6870
6971
== APP == Got items with etags: [(b'value_1_updated', '2'), (b'value_2', '2')]
7072
73+
== APP == Transaction with outbox pattern executed successfully!
74+
75+
== APP == Got value after outbox pattern: b'val1'
76+
7177
== APP == Got values after transaction delete: [b'', b'']
7278
7379
== APP == Got value after delete: b''
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: dapr.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: pubsub
5+
spec:
6+
type: pubsub.redis
7+
version: v1
8+
metadata:
9+
- name: redisHost
10+
value: localhost:6379
11+
- name: redisPassword
12+
value: ""

0 commit comments

Comments
 (0)