nucliadb 6.2.1.post3067__py3-none-any.whl → 6.2.1.post3072__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.
@@ -104,6 +104,14 @@ class KBShardManager:
104
104
  errors.capture_exception(exc)
105
105
  raise NodeError("Node unavailable for operation") from exc
106
106
 
107
+ for result in results:
108
+ if isinstance(result, Exception):
109
+ errors.capture_exception(result)
110
+ raise NodeError(
111
+ f"Error while applying {aw.__name__} for all shards. Other similar errors may have been shadowed.\n"
112
+ f"{type(result).__name__}: {result}"
113
+ ) from result
114
+
107
115
  return results
108
116
 
109
117
  # TODO: move to data manager
@@ -26,7 +26,6 @@ from nucliadb.common.cluster.base import AbstractIndexNode
26
26
  from nucliadb.common.cluster.exceptions import (
27
27
  AlreadyExists,
28
28
  EntitiesGroupNotFound,
29
- NodeError,
30
29
  )
31
30
  from nucliadb.common.cluster.utils import get_shard_manager
32
31
  from nucliadb.common.datamanagers.entities import (
@@ -54,7 +53,6 @@ from nucliadb_protos.nodereader_pb2 import (
54
53
  )
55
54
  from nucliadb_protos.utils_pb2 import RelationNode
56
55
  from nucliadb_protos.writer_pb2 import GetEntitiesResponse
57
- from nucliadb_telemetry import errors
58
56
 
59
57
  from .exceptions import EntityManagementException
60
58
 
@@ -226,10 +224,6 @@ class EntitiesManager:
226
224
  settings.relation_search_timeout,
227
225
  use_read_replica_nodes=self.use_read_replica_nodes,
228
226
  )
229
- for result in results:
230
- if isinstance(result, Exception):
231
- errors.capture_exception(result)
232
- raise NodeError("Error while querying relation index")
233
227
 
234
228
  entities = {}
235
229
  for result in results:
@@ -305,6 +299,7 @@ class EntitiesManager:
305
299
  shard_manager = get_shard_manager()
306
300
 
307
301
  async def query_indexed_entities_group_names(node: AbstractIndexNode, shard_id: str) -> set[str]:
302
+ """Search all relation types"""
308
303
  request = SearchRequest(
309
304
  shard=shard_id,
310
305
  result_per_page=0,
@@ -316,10 +311,11 @@ class EntitiesManager:
316
311
  response: SearchResponse = await query_shard(node, shard_id, request)
317
312
  try:
318
313
  facetresults = response.document.facets["/e"].facetresults
319
- return {facet.tag.split("/")[-1] for facet in facetresults}
320
314
  except KeyError:
321
315
  # No entities found
322
316
  return set()
317
+ else:
318
+ return {facet.tag.split("/")[-1] for facet in facetresults}
323
319
 
324
320
  results = await shard_manager.apply_for_all_shards(
325
321
  self.kbid,
@@ -327,10 +323,6 @@ class EntitiesManager:
327
323
  settings.relation_types_timeout,
328
324
  use_read_replica_nodes=self.use_read_replica_nodes,
329
325
  )
330
- for result in results:
331
- if isinstance(result, Exception):
332
- errors.capture_exception(result)
333
- raise NodeError("Error while looking for relations types")
334
326
 
335
327
  if not results:
336
328
  return set()
@@ -50,7 +50,12 @@ from nucliadb_models.search import (
50
50
  parse_rephrase_prompt,
51
51
  )
52
52
  from nucliadb_protos import audit_pb2
53
- from nucliadb_protos.nodereader_pb2 import RelationSearchResponse, SearchRequest, SearchResponse
53
+ from nucliadb_protos.nodereader_pb2 import (
54
+ EntitiesSubgraphRequest,
55
+ RelationSearchResponse,
56
+ SearchRequest,
57
+ SearchResponse,
58
+ )
54
59
  from nucliadb_protos.utils_pb2 import RelationNode
55
60
  from nucliadb_telemetry.errors import capture_exception
56
61
  from nucliadb_utils.utilities import get_audit
@@ -245,10 +250,16 @@ async def get_relations_results_from_entities(
245
250
  timeout: Optional[float] = None,
246
251
  only_with_metadata: bool = False,
247
252
  only_agentic_relations: bool = False,
253
+ deleted_entities: set[str] = set(),
248
254
  ) -> Relations:
249
255
  request = SearchRequest()
250
256
  request.relation_subgraph.entry_points.extend(entities)
251
257
  request.relation_subgraph.depth = 1
258
+
259
+ deleted = EntitiesSubgraphRequest.DeletedEntities()
260
+ deleted.node_values.extend(deleted_entities)
261
+ request.relation_subgraph.deleted_entities.append(deleted)
262
+
252
263
  results: list[SearchResponse]
253
264
  (
254
265
  results,
@@ -337,7 +337,14 @@ async def get_graph_results(
337
337
  or graph_strategy.query_entity_detection == QueryEntityDetection.PREDICT
338
338
  ):
339
339
  try:
340
- entities_to_explore = await predict.detect_entities(kbid, query)
340
+ # Purposely ignore the entity subtype. This is done so we find all entities that match
341
+ # the entity by name. e.g: in a query like "2000", predict might detect the number as
342
+ # a year entity or as a currency entity. We want graph results for both, so we ignore the
343
+ # subtype just in this case.
344
+ entities_to_explore = [
345
+ RelationNode(ntype=r.ntype, value=r.value, subtype="")
346
+ for r in await predict.detect_entities(kbid, query)
347
+ ]
341
348
  except Exception as e:
342
349
  capture_exception(e)
343
350
  logger.exception("Error in detecting entities for graph strategy")
@@ -365,19 +372,14 @@ async def get_graph_results(
365
372
  timeout=5.0,
366
373
  only_with_metadata=True,
367
374
  only_agentic_relations=graph_strategy.agentic_graph_only,
375
+ deleted_entities=explored_entities,
368
376
  )
369
377
  except Exception as e:
370
378
  capture_exception(e)
371
379
  logger.exception("Error in getting query relations for graph strategy")
372
380
  new_relations = Relations(entities={})
373
381
 
374
- # Removing the relations connected to the entities that were already explored
375
- # XXX: This could be optimized by implementing a filter in the index
376
- # so we don't have to remove them after
377
- new_subgraphs = {
378
- entity: filter_subgraph(subgraph, explored_entities)
379
- for entity, subgraph in new_relations.entities.items()
380
- }
382
+ new_subgraphs = new_relations.entities
381
383
 
382
384
  explored_entities.update(new_subgraphs.keys())
383
385
 
@@ -842,15 +844,6 @@ async def build_graph_response(
842
844
  )
843
845
 
844
846
 
845
- def filter_subgraph(subgraph: EntitySubgraph, entities_to_remove: Collection[str]) -> EntitySubgraph:
846
- """
847
- Removes the relationships with entities in `entities_to_remove` from the subgraph.
848
- """
849
- return EntitySubgraph(
850
- related_to=[rel for rel in subgraph.related_to if rel.entity not in entities_to_remove]
851
- )
852
-
853
-
854
847
  def relations_match_to_text_block_match(
855
848
  paragraph_match: RelationsParagraphMatch,
856
849
  ) -> TextBlockMatch:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb
3
- Version: 6.2.1.post3067
3
+ Version: 6.2.1.post3072
4
4
  Home-page: https://docs.nuclia.dev/docs/management/nucliadb/intro
5
5
  Author: NucliaDB Community
6
6
  Author-email: nucliadb@nuclia.com
@@ -22,10 +22,10 @@ Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Programming Language :: Python :: 3 :: Only
23
23
  Requires-Python: >=3.9, <4
24
24
  Description-Content-Type: text/markdown
25
- Requires-Dist: nucliadb-telemetry[all]>=6.2.1.post3067
26
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post3067
27
- Requires-Dist: nucliadb-protos>=6.2.1.post3067
28
- Requires-Dist: nucliadb-models>=6.2.1.post3067
25
+ Requires-Dist: nucliadb-telemetry[all]>=6.2.1.post3072
26
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post3072
27
+ Requires-Dist: nucliadb-protos>=6.2.1.post3072
28
+ Requires-Dist: nucliadb-models>=6.2.1.post3072
29
29
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
30
30
  Requires-Dist: nuclia-models>=0.24.2
31
31
  Requires-Dist: uvicorn
@@ -47,7 +47,7 @@ nucliadb/common/cluster/base.py,sha256=kklDqyvsubNX0W494ttl9f3E58lGaX6AXqAd8XX8Z
47
47
  nucliadb/common/cluster/exceptions.py,sha256=V3c_fgH00GyJ-a5CaGLhwTuhwhUNR9YAGvS5jaRuc_Y,1495
48
48
  nucliadb/common/cluster/grpc_node_dummy.py,sha256=L85wBnfab7Rev0CfsfUjPxQC6DiHPsETKrZAOLx9XHg,3510
49
49
  nucliadb/common/cluster/index_node.py,sha256=g38H1kiAliF3Y6et_CWYInpn_xPxf7THAFJ7RtgLNZo,3246
50
- nucliadb/common/cluster/manager.py,sha256=3UnYwVb-ZykYfLndxM7TLw7-2T_vxqoFXMu0Pzxh5-A,15327
50
+ nucliadb/common/cluster/manager.py,sha256=cj8yNIspsmdyGUq3vbyW--r-LcxAUqA4S9tocz6MsCM,15695
51
51
  nucliadb/common/cluster/rebalance.py,sha256=jSEYsPgs_Dobv3FOaKl5arBko4s8JlWkahm8LOzgNnE,9135
52
52
  nucliadb/common/cluster/rollover.py,sha256=dx6AF9ywKP10iBNlcoJgRV40921fOPpVWaCUU54hztE,25823
53
53
  nucliadb/common/cluster/settings.py,sha256=TMoym-cZsQ2soWfLAce0moSa2XncttQyhahL43LrWTo,3384
@@ -128,7 +128,7 @@ nucliadb/ingest/fields/text.py,sha256=tFvSQJAe0W7ePpp2_WDfLiE2yglR1OTU0Zht9acvOF
128
128
  nucliadb/ingest/orm/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
129
129
  nucliadb/ingest/orm/brain.py,sha256=UND5EsNUdd7XdjScYqRqg4r_xCx3l-My8alGw5M9CWg,28398
130
130
  nucliadb/ingest/orm/broker_message.py,sha256=ZEMueoGuuRKO4tHgzc0P0AM1Ls1TTYey_4UvRQf0BpY,6915
131
- nucliadb/ingest/orm/entities.py,sha256=5d6Gfo-Yz-rns_mNJeRqiGaPeWpUMgSKZnmWIGMLCKo,15537
131
+ nucliadb/ingest/orm/entities.py,sha256=sBhg8eahsWVwO34KoAJV2YRix4Uw5GINx3srJWxRC9k,15148
132
132
  nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
133
133
  nucliadb/ingest/orm/knowledgebox.py,sha256=IGOPvBR1qXqDxE5DeiOdYCLdPgjzOVVpsASJ2zYvWwQ,23651
134
134
  nucliadb/ingest/orm/metrics.py,sha256=OkwMSPKLZcKba0ZTwtTiIxwBgaLMX5ydhGieKvi2y7E,1096
@@ -210,7 +210,7 @@ nucliadb/search/search/fetch.py,sha256=XJHIFnZmXM_8Kb37lb4lg1GYG7cZ1plT-qAIb_Qzi
210
210
  nucliadb/search/search/filters.py,sha256=1MkHlJjAQqoRCj7e5cEzK2HvBxGLE17I_omsjiklbtw,6476
211
211
  nucliadb/search/search/find.py,sha256=yQbttt85wQFc4NEaj2RNGgozP7IQx_bjAOhHke3fXY0,9890
212
212
  nucliadb/search/search/find_merge.py,sha256=_R_YpHAZv5BHh3XABQ8MRd1Ci0seclGYf26yJHJ7H0I,17178
213
- nucliadb/search/search/graph_strategy.py,sha256=cFcu6nrOqHfobsbUu1pOwfBndrN4ppEvv3-4jV4_4bg,31977
213
+ nucliadb/search/search/graph_strategy.py,sha256=Egcq_zn895gTUYmyQTsXj8YaUMa3HBKhcSa1GBvgzAM,31877
214
214
  nucliadb/search/search/hydrator.py,sha256=-R37gCrGxkyaiHQalnTWHNG_FCx11Zucd7qA1vQCxuw,6985
215
215
  nucliadb/search/search/merge.py,sha256=i_PTBFRqC5iTTziOMEltxLIlmokIou5hjjgR4BnoLBE,22635
216
216
  nucliadb/search/search/metrics.py,sha256=81X-tahGW4n2CLvUzCPdNxNClmZqUWZjcVOGCUHoiUM,2872
@@ -228,7 +228,7 @@ nucliadb/search/search/chat/ask.py,sha256=K85Size6WAb-q4sCn0u1drrPnqIvqCy6YbfCxQ
228
228
  nucliadb/search/search/chat/exceptions.py,sha256=Siy4GXW2L7oPhIR86H3WHBhE9lkV4A4YaAszuGGUf54,1356
229
229
  nucliadb/search/search/chat/images.py,sha256=PA8VWxT5_HUGfW1ULhKTK46UBsVyINtWWqEM1ulzX1E,3095
230
230
  nucliadb/search/search/chat/prompt.py,sha256=r2JTiRWH3YHPdeRAG5w6gD0g0fWVxdTjYIR86qAVa7k,47106
231
- nucliadb/search/search/chat/query.py,sha256=y7W5VuKl1XiZuNsxZIcxxHcFXSG6It2W5CoftZ-ekAc,15428
231
+ nucliadb/search/search/chat/query.py,sha256=rBssR6MPSx8h2DASRMTLODaz9oGE5tNVVVeDncSrEp4,15684
232
232
  nucliadb/search/search/query_parser/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
233
233
  nucliadb/search/search/query_parser/exceptions.py,sha256=tuzl7ZyvVsRz6u0_3zMe60vx39nd3pi641prs-5nC0E,872
234
234
  nucliadb/search/search/query_parser/models.py,sha256=-VlCDXUCgOroAZw1Leqhj2VMgRv_CD2w40PXXOBLaUM,2332
@@ -329,9 +329,9 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
329
329
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
330
330
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
331
331
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
332
- nucliadb-6.2.1.post3067.dist-info/METADATA,sha256=V33nguAqDHoZDoT_3Vfc2w3HTnobJN1C_uB-tlKWGMU,4603
333
- nucliadb-6.2.1.post3067.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
334
- nucliadb-6.2.1.post3067.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
335
- nucliadb-6.2.1.post3067.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
336
- nucliadb-6.2.1.post3067.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
337
- nucliadb-6.2.1.post3067.dist-info/RECORD,,
332
+ nucliadb-6.2.1.post3072.dist-info/METADATA,sha256=Spf7lqAgt29pV4iYGRWhP-Gn1yZLgJh1uzhjqOoWSoU,4603
333
+ nucliadb-6.2.1.post3072.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
334
+ nucliadb-6.2.1.post3072.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
335
+ nucliadb-6.2.1.post3072.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
336
+ nucliadb-6.2.1.post3072.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
337
+ nucliadb-6.2.1.post3072.dist-info/RECORD,,