nucliadb-utils 5.0.0.post833__py3-none-any.whl → 5.0.0.post838__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 +12 -5
- nucliadb_utils/aiopynecone/models.py +3 -3
- {nucliadb_utils-5.0.0.post833.dist-info → nucliadb_utils-5.0.0.post838.dist-info}/METADATA +3 -3
- {nucliadb_utils-5.0.0.post833.dist-info → nucliadb_utils-5.0.0.post838.dist-info}/RECORD +7 -7
- {nucliadb_utils-5.0.0.post833.dist-info → nucliadb_utils-5.0.0.post838.dist-info}/WHEEL +0 -0
- {nucliadb_utils-5.0.0.post833.dist-info → nucliadb_utils-5.0.0.post838.dist-info}/top_level.txt +0 -0
- {nucliadb_utils-5.0.0.post833.dist-info → nucliadb_utils-5.0.0.post838.dist-info}/zip-safe +0 -0
@@ -64,6 +64,7 @@ BASE_API_HEADERS = {
|
|
64
64
|
MEGA_BYTE = 1024 * 1024
|
65
65
|
MAX_UPSERT_PAYLOAD_SIZE = 2 * MEGA_BYTE
|
66
66
|
MAX_DELETE_BATCH_SIZE = 1000
|
67
|
+
MAX_LIST_PAGE_SIZE = 100
|
67
68
|
|
68
69
|
|
69
70
|
RETRIABLE_EXCEPTIONS = (
|
@@ -162,6 +163,9 @@ class DataPlane:
|
|
162
163
|
- `vectors`: The vectors to upsert.
|
163
164
|
- `timeout`: to control the request timeout. If not set, the default timeout is used.
|
164
165
|
"""
|
166
|
+
if len(vectors) == 0:
|
167
|
+
# Nothing to upsert.
|
168
|
+
return
|
165
169
|
headers = {"Api-Key": self.api_key}
|
166
170
|
payload = UpsertRequest(vectors=vectors)
|
167
171
|
post_kwargs: dict[str, Any] = {
|
@@ -257,7 +261,7 @@ class DataPlane:
|
|
257
261
|
async def list_page(
|
258
262
|
self,
|
259
263
|
id_prefix: Optional[str] = None,
|
260
|
-
limit: int =
|
264
|
+
limit: int = MAX_LIST_PAGE_SIZE,
|
261
265
|
pagination_token: Optional[str] = None,
|
262
266
|
timeout: Optional[float] = None,
|
263
267
|
) -> ListResponse:
|
@@ -270,6 +274,8 @@ class DataPlane:
|
|
270
274
|
if there are more pages to fetch.
|
271
275
|
- `timeout`: to control the request timeout. If not set, the default timeout is used.
|
272
276
|
"""
|
277
|
+
if limit > MAX_LIST_PAGE_SIZE: # pragma: no cover
|
278
|
+
raise ValueError(f"Maximum limit is {MAX_LIST_PAGE_SIZE}.")
|
273
279
|
headers = {"Api-Key": self.api_key}
|
274
280
|
params = {"limit": str(limit)}
|
275
281
|
if id_prefix is not None:
|
@@ -292,7 +298,10 @@ class DataPlane:
|
|
292
298
|
return ListResponse.model_validate(response.json())
|
293
299
|
|
294
300
|
async def list_all(
|
295
|
-
self,
|
301
|
+
self,
|
302
|
+
id_prefix: Optional[str] = None,
|
303
|
+
page_size: int = MAX_LIST_PAGE_SIZE,
|
304
|
+
page_timeout: Optional[float] = None,
|
296
305
|
) -> AsyncGenerator[str, None]:
|
297
306
|
"""
|
298
307
|
Iterate over all vector ids from the index in a paginated manner.
|
@@ -368,9 +377,7 @@ class DataPlane:
|
|
368
377
|
await self.delete(ids=batch, timeout=batch_timeout)
|
369
378
|
|
370
379
|
tasks = []
|
371
|
-
async_iterable = self.list_all(
|
372
|
-
id_prefix=id_prefix, page_size=batch_size, page_timeout=batch_timeout
|
373
|
-
)
|
380
|
+
async_iterable = self.list_all(id_prefix=id_prefix, page_timeout=batch_timeout)
|
374
381
|
async for batch in async_batchify(async_iterable, batch_size):
|
375
382
|
tasks.append(asyncio.create_task(_delete_batch(batch)))
|
376
383
|
|
@@ -49,8 +49,7 @@ def validate_index_name(value, handler, info):
|
|
49
49
|
|
50
50
|
IndexNameStr = Annotated[
|
51
51
|
str,
|
52
|
-
pydantic.StringConstraints(pattern=IndexNamePattern),
|
53
|
-
pydantic.StringConstraints(min_length=1, max_length=MAX_INDEX_NAME_LENGTH),
|
52
|
+
pydantic.StringConstraints(pattern=IndexNamePattern, min_length=1, max_length=MAX_INDEX_NAME_LENGTH),
|
54
53
|
pydantic.WrapValidator(validate_index_name),
|
55
54
|
]
|
56
55
|
|
@@ -63,7 +62,7 @@ class CreateIndexRequest(BaseModel):
|
|
63
62
|
|
64
63
|
|
65
64
|
class Vector(BaseModel):
|
66
|
-
id: str = Field(max_length=512)
|
65
|
+
id: str = Field(min_length=1, max_length=512)
|
67
66
|
values: list[float]
|
68
67
|
metadata: dict[str, Any] = {}
|
69
68
|
|
@@ -73,6 +72,7 @@ class Vector(BaseModel):
|
|
73
72
|
json_value = json.dumps(value)
|
74
73
|
if len(json_value) > MAX_METADATA_SIZE:
|
75
74
|
raise ValueError("metadata size is too large")
|
75
|
+
return value
|
76
76
|
|
77
77
|
|
78
78
|
class UpsertRequest(BaseModel):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nucliadb_utils
|
3
|
-
Version: 5.0.0.
|
3
|
+
Version: 5.0.0.post838
|
4
4
|
Home-page: https://nuclia.com
|
5
5
|
License: BSD
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
@@ -23,8 +23,8 @@ Requires-Dist: PyNaCl
|
|
23
23
|
Requires-Dist: pyjwt >=2.4.0
|
24
24
|
Requires-Dist: memorylru >=1.1.2
|
25
25
|
Requires-Dist: mrflagly
|
26
|
-
Requires-Dist: nucliadb-protos >=5.0.0.
|
27
|
-
Requires-Dist: nucliadb-telemetry >=5.0.0.
|
26
|
+
Requires-Dist: nucliadb-protos >=5.0.0.post838
|
27
|
+
Requires-Dist: nucliadb-telemetry >=5.0.0.post838
|
28
28
|
Provides-Extra: cache
|
29
29
|
Requires-Dist: redis >=4.3.4 ; extra == 'cache'
|
30
30
|
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=oz3tEODG2g3todnyvA-nW1Ou6xXDveL_tMKTDGdWXM4,15287
|
20
20
|
nucliadb_utils/aiopynecone/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
21
|
-
nucliadb_utils/aiopynecone/client.py,sha256=
|
21
|
+
nucliadb_utils/aiopynecone/client.py,sha256=jlTLOdphrLZElKW9ajVzDcebN7CSAbjNyX6tnD37eqY,18721
|
22
22
|
nucliadb_utils/aiopynecone/exceptions.py,sha256=hFhq-UEY4slqNWjObXr_LPnRf_AQ1vpcG4SF2XRFd1E,2873
|
23
|
-
nucliadb_utils/aiopynecone/models.py,sha256=
|
23
|
+
nucliadb_utils/aiopynecone/models.py,sha256=B_ihJhHZGp3ivQVUxhV49uoUnHe1PLDKxTgHNbHgSS0,2937
|
24
24
|
nucliadb_utils/audit/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
25
25
|
nucliadb_utils/audit/audit.py,sha256=dn5ZnCVQUlCcvdjzaORghbrjk9QgVGrtkfIftq30Bp8,2819
|
26
26
|
nucliadb_utils/audit/basic.py,sha256=NViey6mKbCXqRTLDBX2xNTcCg9I-2e4oB2xkekuhDvM,3392
|
@@ -64,8 +64,8 @@ nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQ
|
|
64
64
|
nucliadb_utils/tests/local.py,sha256=c3gZJJWmvOftruJkIQIwB3q_hh3uxEhqGIAVWim1Bbk,1343
|
65
65
|
nucliadb_utils/tests/nats.py,sha256=Tosonm9A9cusImyji80G4pgdXEHNVPaCLT5TbFK_ra0,7543
|
66
66
|
nucliadb_utils/tests/s3.py,sha256=YB8QqDaBXxyhHonEHmeBbRRDmvB7sTOaKBSi8KBGokg,2330
|
67
|
-
nucliadb_utils-5.0.0.
|
68
|
-
nucliadb_utils-5.0.0.
|
69
|
-
nucliadb_utils-5.0.0.
|
70
|
-
nucliadb_utils-5.0.0.
|
71
|
-
nucliadb_utils-5.0.0.
|
67
|
+
nucliadb_utils-5.0.0.post838.dist-info/METADATA,sha256=gmSTcyZplCaAvM5mu6UvxeWhR8SlgbAV_S-YdGykS2U,2073
|
68
|
+
nucliadb_utils-5.0.0.post838.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
69
|
+
nucliadb_utils-5.0.0.post838.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
70
|
+
nucliadb_utils-5.0.0.post838.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
71
|
+
nucliadb_utils-5.0.0.post838.dist-info/RECORD,,
|
File without changes
|
{nucliadb_utils-5.0.0.post833.dist-info → nucliadb_utils-5.0.0.post838.dist-info}/top_level.txt
RENAMED
File without changes
|
File without changes
|