nucliadb 6.3.5.post4026__py3-none-any.whl → 6.3.5.post4032__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/common/cache.py CHANGED
@@ -91,6 +91,7 @@ class Cache(Generic[T], ABC):
91
91
  def __del__(self):
92
92
  # we want to clear the cache before deleting the object and set the
93
93
  # metric appropriately
94
+ # XXX: apparently, this doesn't work properly. Don't rely on it
94
95
  self.clear()
95
96
 
96
97
  @abstractmethod
@@ -164,7 +165,7 @@ def delete_resource_cache() -> None:
164
165
  cache = rcache.get()
165
166
  if cache is not None:
166
167
  rcache.set(None)
167
- del cache
168
+ cache.clear()
168
169
 
169
170
 
170
171
  def get_extracted_text_cache() -> Optional[ExtractedTextCache]:
@@ -180,4 +181,4 @@ def delete_extracted_text_cache() -> None:
180
181
  cache = etcache.get()
181
182
  if cache is not None:
182
183
  etcache.set(None)
183
- del cache
184
+ cache.clear()
@@ -21,6 +21,8 @@ import contextlib
21
21
  import logging
22
22
  from typing import Optional
23
23
 
24
+ import backoff
25
+
24
26
  from nucliadb.common.cache import (
25
27
  delete_extracted_text_cache,
26
28
  delete_resource_cache,
@@ -94,13 +96,30 @@ async def get_field_extracted_text(field: Field) -> Optional[ExtractedText]:
94
96
  return extracted_text
95
97
 
96
98
  cache.metrics.ops.inc({"type": "miss"})
97
- extracted_text = await field.get_extracted_text()
99
+ extracted_text = await field_get_extracted_text(field)
98
100
  if extracted_text is not None:
99
101
  # Only cache if we actually have extracted text
100
102
  cache.set(key, extracted_text)
101
103
  return extracted_text
102
104
 
103
105
 
106
+ @backoff.on_exception(backoff.expo, (Exception,), jitter=backoff.random_jitter, max_tries=3)
107
+ async def field_get_extracted_text(field: Field) -> Optional[ExtractedText]:
108
+ try:
109
+ return await field.get_extracted_text()
110
+ except Exception:
111
+ logger.warning(
112
+ "Error getting extracted text for field. Retrying",
113
+ exc_info=True,
114
+ extra={
115
+ "kbid": field.kbid,
116
+ "resource_id": field.resource.uuid,
117
+ "field": f"{field.type}/{field.id}",
118
+ },
119
+ )
120
+ raise
121
+
122
+
104
123
  async def get_extracted_text_from_field_id(kbid: str, field: FieldId) -> Optional[ExtractedText]:
105
124
  rid = field.rid
106
125
  orm_resource = await get_resource(kbid, rid)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.3.5.post4026
3
+ Version: 6.3.5.post4032
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License: AGPL
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Requires-Python: <4,>=3.9
22
22
  Description-Content-Type: text/markdown
23
- Requires-Dist: nucliadb-telemetry[all]>=6.3.5.post4026
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.5.post4026
25
- Requires-Dist: nucliadb-protos>=6.3.5.post4026
26
- Requires-Dist: nucliadb-models>=6.3.5.post4026
27
- Requires-Dist: nidx-protos>=6.3.5.post4026
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.5.post4032
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.5.post4032
25
+ Requires-Dist: nucliadb-protos>=6.3.5.post4032
26
+ Requires-Dist: nucliadb-models>=6.3.5.post4032
27
+ Requires-Dist: nidx-protos>=6.3.5.post4032
28
28
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
29
29
  Requires-Dist: nuclia-models>=0.24.2
30
30
  Requires-Dist: uvicorn[standard]
@@ -53,7 +53,7 @@ nucliadb/backups/settings.py,sha256=SyzsInj1BRbBI0atg5IXWbMbOZ_eVg4eSQ3IcnUhCxQ,
53
53
  nucliadb/backups/tasks.py,sha256=WkL1LgdYBHbV_A5ilyYv5p3zmXwxH68TDudytN5f7zk,4225
54
54
  nucliadb/backups/utils.py,sha256=_Vogjqcru5oqNZM-bZ0q7Ju79Bv1PD-LVFEa7Z-Q13I,1261
55
55
  nucliadb/common/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
56
- nucliadb/common/cache.py,sha256=4iZEfoXgpwTj5Yh25wnllJQWJ8TqefpVOH2y3Z6wjjE,5589
56
+ nucliadb/common/cache.py,sha256=bwkKJ3tgsDE794SIklkOrAwY8vPSvyambC0y8ziMthg,5669
57
57
  nucliadb/common/constants.py,sha256=QpigxJh_CtD85Evy0PtV5cVq6x0U_f9xfIcXz1ymkUg,869
58
58
  nucliadb/common/counters.py,sha256=8lOi3A2HeLDDlcNaS2QT1SfD3350VPBjiY3FkmHH1V8,977
59
59
  nucliadb/common/ids.py,sha256=4QjoIofes_vtKj2HsFWZf8VVIVWXxdkYtLpx1n618Us,8239
@@ -228,7 +228,7 @@ nucliadb/search/api/v1/resource/utils.py,sha256=-NjZqAQtFEXKpIh8ui5S26ItnJ5rzmmG
228
228
  nucliadb/search/requesters/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
229
229
  nucliadb/search/requesters/utils.py,sha256=cQZ4-NftiMljoWQ7-Zl7nWfr6u_FY8u_wc9kTvKQcAg,6999
230
230
  nucliadb/search/search/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
231
- nucliadb/search/search/cache.py,sha256=s5wfWq40I4HOLtsKxe3Q5vanL9-3J5T8e0G3yvQ7OKg,4817
231
+ nucliadb/search/search/cache.py,sha256=F7rT0X-bp02Qh-heNo1tRhXG3iqTkL41F1wA_HIZdoM,5404
232
232
  nucliadb/search/search/cut.py,sha256=ytY0_GY7ocNjfxTb4aosxEp4ZfhQNDP--JkhEMGD298,1153
233
233
  nucliadb/search/search/exceptions.py,sha256=klGLgAGGrXcSGix_W6418ZBMqDchAIGjN77ofkOScEI,1039
234
234
  nucliadb/search/search/fetch.py,sha256=XJHIFnZmXM_8Kb37lb4lg1GYG7cZ1plT-qAIb_QziX4,6184
@@ -361,8 +361,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
361
361
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
362
362
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
363
363
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
364
- nucliadb-6.3.5.post4026.dist-info/METADATA,sha256=pxJ_dFn3jLaLxEXtBXk93R87X5pt9NFdaWNvgBsfvag,4301
365
- nucliadb-6.3.5.post4026.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
366
- nucliadb-6.3.5.post4026.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
367
- nucliadb-6.3.5.post4026.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
368
- nucliadb-6.3.5.post4026.dist-info/RECORD,,
364
+ nucliadb-6.3.5.post4032.dist-info/METADATA,sha256=hbwiwOO_3khU7Rm8IyIFwpmCR3KwiILVV-agkTKmNgA,4301
365
+ nucliadb-6.3.5.post4032.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
366
+ nucliadb-6.3.5.post4032.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
367
+ nucliadb-6.3.5.post4032.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
368
+ nucliadb-6.3.5.post4032.dist-info/RECORD,,