nucliadb-utils 5.0.1.post1147__py3-none-any.whl → 5.0.1.post1161__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.
- nucliadb_utils/aiopynecone/client.py +16 -0
- nucliadb_utils/aiopynecone/exceptions.py +20 -3
- nucliadb_utils/aiopynecone/models.py +16 -1
- {nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/METADATA +3 -3
- {nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/RECORD +8 -8
- {nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/WHEEL +0 -0
- {nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/top_level.txt +0 -0
- {nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/zip-safe +0 -0
@@ -32,11 +32,13 @@ from nucliadb_telemetry.metrics import INF, Histogram, Observer
|
|
32
32
|
from nucliadb_utils.aiopynecone.exceptions import (
|
33
33
|
PineconeAPIError,
|
34
34
|
PineconeRateLimitError,
|
35
|
+
RetriablePineconeAPIError,
|
35
36
|
raise_for_status,
|
36
37
|
)
|
37
38
|
from nucliadb_utils.aiopynecone.models import (
|
38
39
|
CreateIndexRequest,
|
39
40
|
CreateIndexResponse,
|
41
|
+
IndexDescription,
|
40
42
|
IndexStats,
|
41
43
|
ListResponse,
|
42
44
|
QueryResponse,
|
@@ -93,9 +95,11 @@ MAX_LIST_PAGE_SIZE = 100
|
|
93
95
|
|
94
96
|
RETRIABLE_EXCEPTIONS = (
|
95
97
|
PineconeRateLimitError,
|
98
|
+
RetriablePineconeAPIError,
|
96
99
|
httpx.ConnectError,
|
97
100
|
httpx.NetworkError,
|
98
101
|
httpx.WriteTimeout,
|
102
|
+
httpx.ReadTimeout,
|
99
103
|
)
|
100
104
|
|
101
105
|
|
@@ -156,6 +160,18 @@ class ControlPlane:
|
|
156
160
|
return
|
157
161
|
raise_for_status("delete_index", response)
|
158
162
|
|
163
|
+
@pinecone_observer.wrap({"type": "describe_index"})
|
164
|
+
async def describe_index(self, name: str) -> IndexDescription:
|
165
|
+
"""
|
166
|
+
Describe an index in Pinecone.
|
167
|
+
Params:
|
168
|
+
- `name`: The name of the index to describe.
|
169
|
+
"""
|
170
|
+
headers = {"Api-Key": self.api_key}
|
171
|
+
response = await self.http_session.get(f"/indexes/{name}", headers=headers)
|
172
|
+
raise_for_status("describe_index", response)
|
173
|
+
return IndexDescription.model_validate(response.json())
|
174
|
+
|
159
175
|
|
160
176
|
class DataPlane:
|
161
177
|
"""
|
@@ -24,7 +24,7 @@ import httpx
|
|
24
24
|
|
25
25
|
from nucliadb_telemetry.metrics import Counter
|
26
26
|
|
27
|
-
pinecone_errors_counter = Counter("pinecone_errors", labels={"type": ""})
|
27
|
+
pinecone_errors_counter = Counter("pinecone_errors", labels={"type": "", "status_code": ""})
|
28
28
|
|
29
29
|
|
30
30
|
class PineconeAPIError(Exception):
|
@@ -52,7 +52,15 @@ class PineconeAPIError(Exception):
|
|
52
52
|
super().__init__(exc_message)
|
53
53
|
|
54
54
|
|
55
|
-
class
|
55
|
+
class RetriablePineconeAPIError(PineconeAPIError):
|
56
|
+
"""
|
57
|
+
Raised when the client can retry the operation.
|
58
|
+
"""
|
59
|
+
|
60
|
+
pass
|
61
|
+
|
62
|
+
|
63
|
+
class PineconeRateLimitError(RetriablePineconeAPIError):
|
56
64
|
"""
|
57
65
|
Raised when the client has exceeded the rate limit to be able to backoff and retry.
|
58
66
|
"""
|
@@ -80,7 +88,7 @@ def raise_for_status(operation: str, response: httpx.Response):
|
|
80
88
|
try:
|
81
89
|
response.raise_for_status()
|
82
90
|
except httpx.HTTPStatusError:
|
83
|
-
pinecone_errors_counter.inc(labels={"type": operation})
|
91
|
+
pinecone_errors_counter.inc(labels={"type": operation, "status_code": str(response.status_code)})
|
84
92
|
code = None
|
85
93
|
message = None
|
86
94
|
details = None
|
@@ -106,6 +114,15 @@ def raise_for_status(operation: str, response: httpx.Response):
|
|
106
114
|
message=message,
|
107
115
|
details=details,
|
108
116
|
)
|
117
|
+
|
118
|
+
if str(response.status_code).startswith("5"):
|
119
|
+
raise RetriablePineconeAPIError(
|
120
|
+
http_status_code=response.status_code,
|
121
|
+
code=code,
|
122
|
+
message=message,
|
123
|
+
details=details,
|
124
|
+
)
|
125
|
+
|
109
126
|
raise PineconeAPIError(
|
110
127
|
http_status_code=response.status_code,
|
111
128
|
code=code,
|
@@ -29,6 +29,7 @@ from nucliadb_utils.aiopynecone.exceptions import MetadataTooLargeError
|
|
29
29
|
KILO_BYTE = 1024
|
30
30
|
MAX_METADATA_SIZE = 40 * KILO_BYTE
|
31
31
|
MAX_INDEX_NAME_LENGTH = 45
|
32
|
+
MAX_VECTOR_ID_LENGTH = 512
|
32
33
|
|
33
34
|
|
34
35
|
# Requests
|
@@ -64,7 +65,7 @@ class CreateIndexRequest(BaseModel):
|
|
64
65
|
|
65
66
|
|
66
67
|
class Vector(BaseModel):
|
67
|
-
id: str = Field(min_length=1, max_length=
|
68
|
+
id: str = Field(min_length=1, max_length=MAX_VECTOR_ID_LENGTH)
|
68
69
|
values: list[float]
|
69
70
|
metadata: dict[str, Any] = {}
|
70
71
|
|
@@ -122,3 +123,17 @@ class IndexStats(BaseModel):
|
|
122
123
|
dimension: int
|
123
124
|
namespaces: dict[str, IndexNamespaceStats] = {}
|
124
125
|
totalVectorCount: int
|
126
|
+
|
127
|
+
|
128
|
+
class IndexStatus(BaseModel):
|
129
|
+
ready: bool
|
130
|
+
state: str
|
131
|
+
|
132
|
+
|
133
|
+
class IndexDescription(BaseModel):
|
134
|
+
dimension: int
|
135
|
+
host: str
|
136
|
+
metric: str
|
137
|
+
name: str
|
138
|
+
spec: dict[str, Any]
|
139
|
+
status: IndexStatus
|
{nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nucliadb_utils
|
3
|
-
Version: 5.0.1.
|
3
|
+
Version: 5.0.1.post1161
|
4
4
|
Home-page: https://nuclia.com
|
5
5
|
License: BSD
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
@@ -24,8 +24,8 @@ Requires-Dist: PyNaCl
|
|
24
24
|
Requires-Dist: pyjwt>=2.4.0
|
25
25
|
Requires-Dist: memorylru>=1.1.2
|
26
26
|
Requires-Dist: mrflagly>=0.2.9
|
27
|
-
Requires-Dist: nucliadb-protos>=5.0.1.
|
28
|
-
Requires-Dist: nucliadb-telemetry>=5.0.1.
|
27
|
+
Requires-Dist: nucliadb-protos>=5.0.1.post1161
|
28
|
+
Requires-Dist: nucliadb-telemetry>=5.0.1.post1161
|
29
29
|
Provides-Extra: cache
|
30
30
|
Requires-Dist: redis>=4.3.4; extra == "cache"
|
31
31
|
Requires-Dist: orjson>=3.6.7; extra == "cache"
|
@@ -18,9 +18,9 @@ nucliadb_utils/store.py,sha256=kQ35HemE0v4_Qg6xVqNIJi8vSFAYQtwI3rDtMsNy62Y,890
|
|
18
18
|
nucliadb_utils/transaction.py,sha256=mwcI3aIHAvU5KOGqd_Uz_d1XQzXhk_-NWY8NqU1lfb0,7307
|
19
19
|
nucliadb_utils/utilities.py,sha256=idajCm_4Sojh7b3HTkP0fTfG2Mb6PIB9xtMmcfB7Nl0,15758
|
20
20
|
nucliadb_utils/aiopynecone/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
21
|
-
nucliadb_utils/aiopynecone/client.py,sha256=
|
22
|
-
nucliadb_utils/aiopynecone/exceptions.py,sha256=
|
23
|
-
nucliadb_utils/aiopynecone/models.py,sha256=
|
21
|
+
nucliadb_utils/aiopynecone/client.py,sha256=MPyHnDXwhukJr7U3CJh7BpsekfSuOkyM4g5b9LLtzc8,22941
|
22
|
+
nucliadb_utils/aiopynecone/exceptions.py,sha256=fUErx3ceKQK1MUbOnYcZhIzpNe8UVAptZE9JIRDLXDE,4000
|
23
|
+
nucliadb_utils/aiopynecone/models.py,sha256=XkNIZx4bxdbVo9zYVn8IRp70q4DWUMWN79ybGloFj2Q,3492
|
24
24
|
nucliadb_utils/audit/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
25
25
|
nucliadb_utils/audit/audit.py,sha256=0RoJxK_SesKD9cbNMqCtpT4ylznFxEcHsetyh1eRlEk,3023
|
26
26
|
nucliadb_utils/audit/basic.py,sha256=g-790vVvua6OrUkHGBjvgz2TaZt21dWoZw3XiYptt_E,3634
|
@@ -64,8 +64,8 @@ nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQ
|
|
64
64
|
nucliadb_utils/tests/local.py,sha256=7nuP8EFUAiA8ZH50R1iPV9EUXBySQxOanVm3Zht_e0g,1835
|
65
65
|
nucliadb_utils/tests/nats.py,sha256=xqpww4jZjTKY9oPGlJdDJG67L3FIBQsa9qDHxILR8r8,7687
|
66
66
|
nucliadb_utils/tests/s3.py,sha256=IdMxK_cNdSHLvO1u8BwsKFzD87Hk1MVPDZ57zx6h-rA,3656
|
67
|
-
nucliadb_utils-5.0.1.
|
68
|
-
nucliadb_utils-5.0.1.
|
69
|
-
nucliadb_utils-5.0.1.
|
70
|
-
nucliadb_utils-5.0.1.
|
71
|
-
nucliadb_utils-5.0.1.
|
67
|
+
nucliadb_utils-5.0.1.post1161.dist-info/METADATA,sha256=mXTMDPpBvfKcHYY4DAKKsiPsP0slBW3JuwSulGzGDww,2071
|
68
|
+
nucliadb_utils-5.0.1.post1161.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
69
|
+
nucliadb_utils-5.0.1.post1161.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
70
|
+
nucliadb_utils-5.0.1.post1161.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
71
|
+
nucliadb_utils-5.0.1.post1161.dist-info/RECORD,,
|
File without changes
|
{nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/top_level.txt
RENAMED
File without changes
|
{nucliadb_utils-5.0.1.post1147.dist-info → nucliadb_utils-5.0.1.post1161.dist-info}/zip-safe
RENAMED
File without changes
|