microsoft-agents-storage-cosmos 0.7.0__py3-none-any.whl → 0.7.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microsoft_agents/storage/cosmos/cosmos_db_storage.py +24 -25
- microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +9 -5
- {microsoft_agents_storage_cosmos-0.7.0.dist-info → microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info}/METADATA +3 -22
- microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info/RECORD +11 -0
- microsoft_agents_storage_cosmos-0.7.0.dist-info/RECORD +0 -11
- {microsoft_agents_storage_cosmos-0.7.0.dist-info → microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info}/WHEEL +0 -0
- {microsoft_agents_storage_cosmos-0.7.0.dist-info → microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info}/licenses/LICENSE +0 -0
- {microsoft_agents_storage_cosmos-0.7.0.dist-info → microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info}/top_level.txt +0 -0
|
@@ -61,7 +61,7 @@ class CosmosDBStorage(AsyncStorageBase):
|
|
|
61
61
|
)
|
|
62
62
|
)
|
|
63
63
|
return CosmosClient(
|
|
64
|
-
|
|
64
|
+
account_url=self._config.url, credential=self._config.credential
|
|
65
65
|
)
|
|
66
66
|
|
|
67
67
|
connection_policy = self._config.cosmos_client_options.get(
|
|
@@ -139,30 +139,32 @@ class CosmosDBStorage(AsyncStorageBase):
|
|
|
139
139
|
"kind": documents.PartitionKind.Hash,
|
|
140
140
|
}
|
|
141
141
|
try:
|
|
142
|
-
kwargs = {}
|
|
143
|
-
if self._config.container_throughput:
|
|
144
|
-
kwargs["offer_throughput"] = self._config.container_throughput
|
|
145
142
|
self._container = await self._database.create_container(
|
|
146
|
-
self._config.container_id,
|
|
143
|
+
self._config.container_id,
|
|
144
|
+
partition_key,
|
|
145
|
+
offer_throughput=self._config.container_throughput,
|
|
147
146
|
)
|
|
148
|
-
except
|
|
149
|
-
|
|
150
|
-
self.
|
|
151
|
-
|
|
152
|
-
properties = await self._container.read()
|
|
153
|
-
# if "partitionKey" not in properties:
|
|
154
|
-
# self._compatability_mode_partition_key = True
|
|
155
|
-
# else:
|
|
156
|
-
# containers created had no partition key, so the default was "/_partitionKey"
|
|
157
|
-
paths = properties["partitionKey"]["paths"]
|
|
158
|
-
if "/_partitionKey" in paths:
|
|
159
|
-
self._compatability_mode_partition_key = True
|
|
160
|
-
elif "/id" not in paths:
|
|
161
|
-
raise Exception(
|
|
162
|
-
storage_errors.InvalidConfiguration.format(
|
|
163
|
-
f"Custom Partition Key Paths are not supported. {self._config.container_id} has a custom Partition Key Path of {paths[0]}."
|
|
164
|
-
)
|
|
147
|
+
except cosmos_exceptions.CosmosHttpResponseError as err:
|
|
148
|
+
if err.status_code == http_constants.StatusCodes.CONFLICT:
|
|
149
|
+
self._container = self._database.get_container_client(
|
|
150
|
+
self._config.container_id
|
|
165
151
|
)
|
|
152
|
+
properties = await self._container.read()
|
|
153
|
+
# if "partitionKey" not in properties:
|
|
154
|
+
# self._compatability_mode_partition_key = True
|
|
155
|
+
# else:
|
|
156
|
+
# containers created had no partition key, so the default was "/_partitionKey"
|
|
157
|
+
paths = properties["partitionKey"]["paths"]
|
|
158
|
+
if "/_partitionKey" in paths:
|
|
159
|
+
self._compatability_mode_partition_key = True
|
|
160
|
+
elif "/id" not in paths:
|
|
161
|
+
raise Exception(
|
|
162
|
+
storage_errors.InvalidConfiguration.format(
|
|
163
|
+
f"Custom Partition Key Paths are not supported. {self._config.container_id} has a custom Partition Key Path of {paths[0]}."
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
else:
|
|
167
|
+
raise err
|
|
166
168
|
|
|
167
169
|
async def initialize(self) -> None:
|
|
168
170
|
if not self._container:
|
|
@@ -180,6 +182,3 @@ class CosmosDBStorage(AsyncStorageBase):
|
|
|
180
182
|
|
|
181
183
|
def _get_partition_key(self, key: str):
|
|
182
184
|
return NonePartitionKeyValue if self._compatability_mode_partition_key else key
|
|
183
|
-
|
|
184
|
-
async def _close(self) -> None:
|
|
185
|
-
await self._client.close()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from typing import Union
|
|
3
3
|
|
|
4
|
-
from azure.core.
|
|
4
|
+
from azure.core.credentials import TokenCredential
|
|
5
5
|
from microsoft_agents.storage.cosmos.errors import storage_errors
|
|
6
6
|
|
|
7
7
|
from .key_ops import sanitize_key
|
|
@@ -17,11 +17,11 @@ class CosmosDBStorageConfig:
|
|
|
17
17
|
database_id: str = "",
|
|
18
18
|
container_id: str = "",
|
|
19
19
|
cosmos_client_options: dict = None,
|
|
20
|
-
container_throughput: int
|
|
20
|
+
container_throughput: int = 0,
|
|
21
21
|
key_suffix: str = "",
|
|
22
22
|
compatibility_mode: bool = False,
|
|
23
23
|
url: str = "",
|
|
24
|
-
credential: Union[
|
|
24
|
+
credential: Union[TokenCredential, None] = None,
|
|
25
25
|
**kwargs,
|
|
26
26
|
):
|
|
27
27
|
"""Create the Config object.
|
|
@@ -55,14 +55,14 @@ class CosmosDBStorageConfig:
|
|
|
55
55
|
"cosmos_client_options", {}
|
|
56
56
|
)
|
|
57
57
|
self.container_throughput: int = container_throughput or kwargs.get(
|
|
58
|
-
"container_throughput"
|
|
58
|
+
"container_throughput", 400
|
|
59
59
|
)
|
|
60
60
|
self.key_suffix: str = key_suffix or kwargs.get("key_suffix", "")
|
|
61
61
|
self.compatibility_mode: bool = compatibility_mode or kwargs.get(
|
|
62
62
|
"compatibility_mode", False
|
|
63
63
|
)
|
|
64
64
|
self.url = url or kwargs.get("url", "")
|
|
65
|
-
self.credential: Union[
|
|
65
|
+
self.credential: Union[TokenCredential, None] = credential
|
|
66
66
|
|
|
67
67
|
@staticmethod
|
|
68
68
|
def validate_cosmos_db_config(config: "CosmosDBStorageConfig") -> None:
|
|
@@ -71,6 +71,10 @@ class CosmosDBStorageConfig:
|
|
|
71
71
|
This is used prior to the creation of the CosmosDBStorage object."""
|
|
72
72
|
if not config:
|
|
73
73
|
raise ValueError(str(storage_errors.CosmosDbConfigRequired))
|
|
74
|
+
if not config.cosmos_db_endpoint:
|
|
75
|
+
raise ValueError(str(storage_errors.CosmosDbEndpointRequired))
|
|
76
|
+
if not config.auth_key:
|
|
77
|
+
raise ValueError(str(storage_errors.CosmosDbAuthKeyRequired))
|
|
74
78
|
if not config.database_id:
|
|
75
79
|
raise ValueError(str(storage_errors.CosmosDbDatabaseIdRequired))
|
|
76
80
|
if not config.container_id:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-storage-cosmos
|
|
3
|
-
Version: 0.7.0
|
|
3
|
+
Version: 0.7.0.dev1
|
|
4
4
|
Summary: A Cosmos DB storage library for Microsoft Agents
|
|
5
5
|
Author: Microsoft Corporation
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,10 +15,9 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: microsoft-agents-hosting-core==0.7.0
|
|
18
|
+
Requires-Dist: microsoft-agents-hosting-core==0.7.0.dev1
|
|
19
19
|
Requires-Dist: azure-core
|
|
20
20
|
Requires-Dist: azure-cosmos
|
|
21
|
-
Requires-Dist: azure-identity
|
|
22
21
|
Dynamic: license-file
|
|
23
22
|
Dynamic: requires-dist
|
|
24
23
|
|
|
@@ -40,29 +39,11 @@ This library is part of the **Microsoft 365 Agents SDK for Python** - a comprehe
|
|
|
40
39
|
<th style="width:20%">Date</th>
|
|
41
40
|
<th style="width:60%">Release Notes</th>
|
|
42
41
|
</tr>
|
|
43
|
-
<tr>
|
|
44
|
-
<td>0.6.1</td>
|
|
45
|
-
<td>2025-12-01</td>
|
|
46
|
-
<td>
|
|
47
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
48
|
-
0.6.1 Release Notes
|
|
49
|
-
</a>
|
|
50
|
-
</td>
|
|
51
|
-
</tr>
|
|
52
|
-
<tr>
|
|
53
|
-
<td>0.6.0</td>
|
|
54
|
-
<td>2025-11-18</td>
|
|
55
|
-
<td>
|
|
56
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
57
|
-
0.6.0 Release Notes
|
|
58
|
-
</a>
|
|
59
|
-
</td>
|
|
60
|
-
</tr>
|
|
61
42
|
<tr>
|
|
62
43
|
<td>0.5.0</td>
|
|
63
44
|
<td>2025-10-22</td>
|
|
64
45
|
<td>
|
|
65
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md
|
|
46
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md">
|
|
66
47
|
0.5.0 Release Notes
|
|
67
48
|
</a>
|
|
68
49
|
</td>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
microsoft_agents/storage/cosmos/__init__.py,sha256=2JVNhbohUB-Pm8LmgagHQH3vlEgljpUzbfPhdOS-rCQ,174
|
|
2
|
+
microsoft_agents/storage/cosmos/cosmos_db_storage.py,sha256=TLvvVKmRqKWrXsy9ddOjXPbPjPvLFXW6oB3KE9cuIC4,6753
|
|
3
|
+
microsoft_agents/storage/cosmos/cosmos_db_storage_config.py,sha256=ji--EihsTE9FiGyUpeaw0or1iMN8-Z6O-gUd0fMcfx0,4210
|
|
4
|
+
microsoft_agents/storage/cosmos/key_ops.py,sha256=2wnSdSpKzwoCvw4giNn68pBDOa1Gc1jyvEhk2tc_gPQ,1747
|
|
5
|
+
microsoft_agents/storage/cosmos/errors/__init__.py,sha256=3J6VOVCyB2NxCrodoLeVxLAtHMmsrZKKbz4LfUHfk-0,409
|
|
6
|
+
microsoft_agents/storage/cosmos/errors/error_resources.py,sha256=7mXt0Dj1LOGt2fg9h2iV5ZGPu480DMeFEGSN2uue4A0,2386
|
|
7
|
+
microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
|
|
8
|
+
microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info/METADATA,sha256=0TxCCAgfY-Ndmc2NunPYVjwcinKSDn4U27ilPkhBaL8,7784
|
|
9
|
+
microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
|
|
11
|
+
microsoft_agents_storage_cosmos-0.7.0.dev1.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
microsoft_agents/storage/cosmos/__init__.py,sha256=2JVNhbohUB-Pm8LmgagHQH3vlEgljpUzbfPhdOS-rCQ,174
|
|
2
|
-
microsoft_agents/storage/cosmos/cosmos_db_storage.py,sha256=7AivID9eWk2XB_Ar7J3__T7fETqNiGqqUfdL6xWjo0w,6680
|
|
3
|
-
microsoft_agents/storage/cosmos/cosmos_db_storage_config.py,sha256=Qyt01_zXWLL6Ho8WBmWep9C0nqed8LrRC0YjUBC5PR8,4013
|
|
4
|
-
microsoft_agents/storage/cosmos/key_ops.py,sha256=2wnSdSpKzwoCvw4giNn68pBDOa1Gc1jyvEhk2tc_gPQ,1747
|
|
5
|
-
microsoft_agents/storage/cosmos/errors/__init__.py,sha256=3J6VOVCyB2NxCrodoLeVxLAtHMmsrZKKbz4LfUHfk-0,409
|
|
6
|
-
microsoft_agents/storage/cosmos/errors/error_resources.py,sha256=7mXt0Dj1LOGt2fg9h2iV5ZGPu480DMeFEGSN2uue4A0,2386
|
|
7
|
-
microsoft_agents_storage_cosmos-0.7.0.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
|
|
8
|
-
microsoft_agents_storage_cosmos-0.7.0.dist-info/METADATA,sha256=xll37oMmS4tEbhFS7FqCBEpC3K_WTn1ph3zNZ-EQQL0,8381
|
|
9
|
-
microsoft_agents_storage_cosmos-0.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
microsoft_agents_storage_cosmos-0.7.0.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
|
|
11
|
-
microsoft_agents_storage_cosmos-0.7.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|