nucliadb-utils 5.0.1.post1141__py3-none-any.whl → 5.0.1.post1154__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.
@@ -32,6 +32,7 @@ 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 (
@@ -93,9 +94,11 @@ MAX_LIST_PAGE_SIZE = 100
93
94
 
94
95
  RETRIABLE_EXCEPTIONS = (
95
96
  PineconeRateLimitError,
97
+ RetriablePineconeAPIError,
96
98
  httpx.ConnectError,
97
99
  httpx.NetworkError,
98
100
  httpx.WriteTimeout,
101
+ httpx.ReadTimeout,
99
102
  )
100
103
 
101
104
 
@@ -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 PineconeRateLimitError(PineconeAPIError):
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=512)
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nucliadb_utils
3
- Version: 5.0.1.post1141
3
+ Version: 5.0.1.post1154
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.post1141
28
- Requires-Dist: nucliadb-telemetry>=5.0.1.post1141
27
+ Requires-Dist: nucliadb-protos>=5.0.1.post1154
28
+ Requires-Dist: nucliadb-telemetry>=5.0.1.post1154
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=3DGJuHXO9Vm83atMLD4fd2FTz8SAr8RvPCGU_bXH9Ho,22333
22
- nucliadb_utils/aiopynecone/exceptions.py,sha256=yfUXIADRuhPb2rNynoFRlpQ6QINm1EkmvT_BbZ7dv8I,3536
23
- nucliadb_utils/aiopynecone/models.py,sha256=ketK2IYLWiwFZ76rnJmwfcuopFJrCAtCUszdTSurm_Q,3236
21
+ nucliadb_utils/aiopynecone/client.py,sha256=k1qh6XW1qPqV31INR-yDPSGAQ-85U2xr08vxhs3vOvM,22418
22
+ nucliadb_utils/aiopynecone/exceptions.py,sha256=fUErx3ceKQK1MUbOnYcZhIzpNe8UVAptZE9JIRDLXDE,4000
23
+ nucliadb_utils/aiopynecone/models.py,sha256=PM8Cp1o7xzyqjI5uHIm6Dv8gC4y3NyILBxhyOuO8kPI,3280
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.post1141.dist-info/METADATA,sha256=K-62J0W9ahmctvyty7ELeoJ39F39lwtkZje7odWeREg,2071
68
- nucliadb_utils-5.0.1.post1141.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
69
- nucliadb_utils-5.0.1.post1141.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
- nucliadb_utils-5.0.1.post1141.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
- nucliadb_utils-5.0.1.post1141.dist-info/RECORD,,
67
+ nucliadb_utils-5.0.1.post1154.dist-info/METADATA,sha256=QzZqaLGYAMAQqPd3D0g_y8GgwEl-FBGvyTlFpLU5S6g,2071
68
+ nucliadb_utils-5.0.1.post1154.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
69
+ nucliadb_utils-5.0.1.post1154.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
+ nucliadb_utils-5.0.1.post1154.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
+ nucliadb_utils-5.0.1.post1154.dist-info/RECORD,,