nucliadb-utils 5.0.0.post809__py3-none-any.whl → 5.0.0.post821__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 +10 -7
- nucliadb_utils/aiopynecone/exceptions.py +5 -4
- nucliadb_utils/aiopynecone/models.py +33 -0
- {nucliadb_utils-5.0.0.post809.dist-info → nucliadb_utils-5.0.0.post821.dist-info}/METADATA +3 -3
- {nucliadb_utils-5.0.0.post809.dist-info → nucliadb_utils-5.0.0.post821.dist-info}/RECORD +8 -8
- {nucliadb_utils-5.0.0.post809.dist-info → nucliadb_utils-5.0.0.post821.dist-info}/WHEEL +0 -0
- {nucliadb_utils-5.0.0.post809.dist-info → nucliadb_utils-5.0.0.post821.dist-info}/top_level.txt +0 -0
- {nucliadb_utils-5.0.0.post809.dist-info → nucliadb_utils-5.0.0.post821.dist-info}/zip-safe +0 -0
@@ -35,6 +35,7 @@ from nucliadb_utils.aiopynecone.exceptions import (
|
|
35
35
|
raise_for_status,
|
36
36
|
)
|
37
37
|
from nucliadb_utils.aiopynecone.models import (
|
38
|
+
CreateIndexRequest,
|
38
39
|
CreateIndexResponse,
|
39
40
|
ListResponse,
|
40
41
|
QueryResponse,
|
@@ -100,14 +101,16 @@ class ControlPlane:
|
|
100
101
|
Returns:
|
101
102
|
- The index host to be used for data plane operations.
|
102
103
|
"""
|
103
|
-
payload =
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
payload = CreateIndexRequest(
|
105
|
+
name=name,
|
106
|
+
dimension=dimension,
|
107
|
+
metric=metric,
|
108
|
+
spec={"serverless": {"cloud": "aws", "region": "us-east-1"}},
|
109
|
+
)
|
109
110
|
headers = {"Api-Key": self.api_key}
|
110
|
-
http_response = await self.http_session.post(
|
111
|
+
http_response = await self.http_session.post(
|
112
|
+
"/indexes", json=payload.model_dump(), headers=headers
|
113
|
+
)
|
111
114
|
raise_for_status("create_index", http_response)
|
112
115
|
response = CreateIndexResponse.model_validate(http_response.json())
|
113
116
|
return response.host
|
@@ -70,10 +70,11 @@ def raise_for_status(operation: str, response: httpx.Response):
|
|
70
70
|
details = None
|
71
71
|
try:
|
72
72
|
resp_json = response.json()
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
error = resp_json.get("error") or {}
|
74
|
+
code = error.get("code")
|
75
|
+
message = error.get("message")
|
76
|
+
details = error.get("details")
|
77
|
+
except Exception: # pragma: no cover
|
77
78
|
message = response.text
|
78
79
|
if response.status_code == 429:
|
79
80
|
raise PineconeRateLimitError(
|
@@ -20,14 +20,47 @@
|
|
20
20
|
import json
|
21
21
|
from typing import Any, Optional
|
22
22
|
|
23
|
+
import pydantic
|
23
24
|
from pydantic import BaseModel, Field, field_validator
|
25
|
+
from typing_extensions import Annotated
|
24
26
|
|
25
27
|
KILO_BYTE = 1024
|
26
28
|
MAX_METADATA_SIZE = 40 * KILO_BYTE
|
29
|
+
MAX_INDEX_NAME_LENGTH = 45
|
27
30
|
|
28
31
|
|
29
32
|
# Requests
|
30
33
|
|
34
|
+
IndexNamePattern = r"^[a-z0-9-]+$"
|
35
|
+
|
36
|
+
|
37
|
+
def validate_index_name(value, handler, info):
|
38
|
+
try:
|
39
|
+
return handler(value)
|
40
|
+
except pydantic.ValidationError as e:
|
41
|
+
if any(x["type"] == "string_pattern_mismatch" for x in e.errors()):
|
42
|
+
raise ValueError(
|
43
|
+
f"Invalid field_id: '{value}'. Pinecone index names must be a string with only "
|
44
|
+
"lowercase letters, numbers and dashes."
|
45
|
+
)
|
46
|
+
else:
|
47
|
+
raise e
|
48
|
+
|
49
|
+
|
50
|
+
IndexNameStr = Annotated[
|
51
|
+
str,
|
52
|
+
pydantic.StringConstraints(pattern=IndexNamePattern),
|
53
|
+
pydantic.StringConstraints(min_length=1, max_length=MAX_INDEX_NAME_LENGTH),
|
54
|
+
pydantic.WrapValidator(validate_index_name),
|
55
|
+
]
|
56
|
+
|
57
|
+
|
58
|
+
class CreateIndexRequest(BaseModel):
|
59
|
+
name: IndexNameStr
|
60
|
+
dimension: int
|
61
|
+
metric: str
|
62
|
+
spec: dict[str, Any] = {}
|
63
|
+
|
31
64
|
|
32
65
|
class Vector(BaseModel):
|
33
66
|
id: str = Field(max_length=512)
|
@@ -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.post821
|
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.post821
|
27
|
+
Requires-Dist: nucliadb-telemetry >=5.0.0.post821
|
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=
|
22
|
-
nucliadb_utils/aiopynecone/exceptions.py,sha256=
|
23
|
-
nucliadb_utils/aiopynecone/models.py,sha256=
|
21
|
+
nucliadb_utils/aiopynecone/client.py,sha256=wUQIUZHKvhMhmLVfwrOF_nMBcf9l-4mXCvlSI0l0H24,18472
|
22
|
+
nucliadb_utils/aiopynecone/exceptions.py,sha256=hFhq-UEY4slqNWjObXr_LPnRf_AQ1vpcG4SF2XRFd1E,2873
|
23
|
+
nucliadb_utils/aiopynecone/models.py,sha256=sEmifzQ6rvqIB8nbkJbh8-hrCW4j8J9lJ_xLRaTAqro,2934
|
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.post821.dist-info/METADATA,sha256=54y8hOk8DjtRFOBXlvQnqvcvOOgLvdV3LKexpyS-iMM,2073
|
68
|
+
nucliadb_utils-5.0.0.post821.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
69
|
+
nucliadb_utils-5.0.0.post821.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
70
|
+
nucliadb_utils-5.0.0.post821.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
71
|
+
nucliadb_utils-5.0.0.post821.dist-info/RECORD,,
|
File without changes
|
{nucliadb_utils-5.0.0.post809.dist-info → nucliadb_utils-5.0.0.post821.dist-info}/top_level.txt
RENAMED
File without changes
|
File without changes
|