nucliadb 6.3.4.post3769__py3-none-any.whl → 6.3.4.post3785__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.
@@ -236,8 +236,6 @@ class ResourceBrain:
236
236
  field_relations = self.brain.field_relations[field_key].relations
237
237
  for relations in metadata.metadata.relations:
238
238
  for relation in relations.relations:
239
- self.brain.relations.append(relation)
240
-
241
239
  index_relation = IndexRelation(relation=relation)
242
240
  if relation.metadata.HasField("data_augmentation_task_id"):
243
241
  index_relation.facets.append(f"/g/da/{relation.metadata.data_augmentation_task_id}")
@@ -421,7 +419,6 @@ class ResourceBrain:
421
419
  source=relationnodedocument,
422
420
  to=relationnodeuser,
423
421
  )
424
- self.brain.relations.append(relation)
425
422
  self.brain.field_relations["a/metadata"].relations.append(
426
423
  IndexRelation(relation=relation)
427
424
  )
@@ -437,12 +434,10 @@ class ResourceBrain:
437
434
  source=relationnodedocument,
438
435
  to=relation_node_label,
439
436
  )
440
- self.brain.relations.append(relation)
441
437
  self.brain.field_relations["a/metadata"].relations.append(IndexRelation(relation=relation))
442
438
 
443
439
  # relations
444
440
  for relation in user_relations.relations:
445
- self.brain.relations.append(relation)
446
441
  self.brain.field_relations["a/metadata"].relations.append(
447
442
  IndexRelation(relation=relation, facets=["/g/u"])
448
443
  )
@@ -522,7 +517,6 @@ class ResourceBrain:
522
517
  relation = Relation()
523
518
  relation.CopyFrom(base_classification_relation)
524
519
  relation.to.value = label
525
- self.brain.relations.append(relation)
526
520
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
527
521
 
528
522
  # Data Augmentation + Processor entities
@@ -550,7 +544,6 @@ class ResourceBrain:
550
544
  relation.CopyFrom(base_entity_relation)
551
545
  relation.to.value = entity_text
552
546
  relation.to.subtype = entity_label
553
- self.brain.relations.append(relation)
554
547
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
555
548
 
556
549
  # Legacy processor entities
@@ -570,7 +563,6 @@ class ResourceBrain:
570
563
  relation.CopyFrom(base_entity_relation)
571
564
  relation.to.value = entity
572
565
  relation.to.subtype = klass
573
- self.brain.relations.append(relation)
574
566
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
575
567
 
576
568
  def apply_field_labels(
@@ -627,7 +619,6 @@ class ResourceBrain:
627
619
  source=relation_node_resource,
628
620
  to=relation_node_entity,
629
621
  )
630
- self.brain.relations.append(rel)
631
622
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=rel))
632
623
  for paragraph_annotation in basic_user_fieldmetadata.paragraphs:
633
624
  for classification in paragraph_annotation.classifications:
@@ -153,9 +153,10 @@ async def _index_node_retrieval(
153
153
  search_results.shards = queried_shards
154
154
  search_results.autofilters = autofilters
155
155
 
156
+ ndb_time = metrics.elapsed("node_query") + metrics.elapsed("results_merge")
156
157
  if metrics.elapsed("node_query") > settings.slow_node_query_log_threshold:
157
158
  logger.warning(
158
- "Slow node query",
159
+ "Slow nidx query",
159
160
  extra={
160
161
  "kbid": kbid,
161
162
  "user": x_nucliadb_user,
@@ -166,7 +167,7 @@ async def _index_node_retrieval(
166
167
  "durations": metrics.steps(),
167
168
  },
168
169
  )
169
- elif search_time > settings.slow_find_log_threshold:
170
+ elif ndb_time > settings.slow_find_log_threshold:
170
171
  logger.info(
171
172
  "Slow find query",
172
173
  extra={
@@ -485,12 +485,17 @@ def _merge_relations_results(
485
485
  relations.entities[entry_point.value] = EntitySubgraph(related_to=[])
486
486
 
487
487
  for relation_response in relations_responses:
488
- for relation in relation_response.subgraph.relations:
488
+ for index_relation in relation_response.subgraph.relations:
489
+ relation = index_relation.relation
489
490
  origin = relation.source
490
491
  destination = relation.to
491
492
  relation_type = RelationTypePbMap[relation.relation] # type: ignore
492
493
  relation_label = relation.relation_label
493
494
  metadata = relation.metadata if relation.HasField("metadata") else None
495
+
496
+ if index_relation.resource_field_id is not None:
497
+ resource_id = index_relation.resource_field_id.split("/")[0]
498
+
494
499
  # If only_with_metadata is True, we check that metadata for the relation is not None
495
500
  # If only_agentic is True, we check that metadata for the relation is not None and that it has a data_augmentation_task_id
496
501
  # TODO: This is suboptimal, we should be able to filter this in the query to the index,
@@ -513,7 +518,7 @@ def _merge_relations_results(
513
518
  relation_label=relation_label,
514
519
  direction=RelationDirection.OUT,
515
520
  metadata=from_proto.relation_metadata(metadata) if metadata else None,
516
- resource_id=relation.resource_id,
521
+ resource_id=resource_id,
517
522
  )
518
523
  )
519
524
  elif destination.value in relations.entities:
@@ -526,7 +531,7 @@ def _merge_relations_results(
526
531
  relation_label=relation_label,
527
532
  direction=RelationDirection.IN,
528
533
  metadata=from_proto.relation_metadata(metadata) if metadata else None,
529
- resource_id=relation.resource_id,
534
+ resource_id=resource_id,
530
535
  )
531
536
  )
532
537
 
@@ -148,6 +148,9 @@ def _parse_path_query(expr: graph_requests.GraphPathQuery) -> nodereader_pb2.Gra
148
148
  elif isinstance(expr, graph_requests.Relation):
149
149
  _set_relation_to_pb(expr, pb.path.relation)
150
150
 
151
+ elif isinstance(expr, graph_requests.Generated):
152
+ _set_generated_to_pb(expr, pb)
153
+
151
154
  else: # pragma: nocover
152
155
  # This is a trick so mypy generates an error if this branch can be reached,
153
156
  # that is, if we are missing some ifs
@@ -174,6 +177,9 @@ def _parse_node_query(expr: graph_requests.GraphNodesQuery) -> nodereader_pb2.Gr
174
177
  _set_node_to_pb(expr, pb.path.source)
175
178
  pb.path.undirected = True
176
179
 
180
+ elif isinstance(expr, graph_requests.Generated):
181
+ _set_generated_to_pb(expr, pb)
182
+
177
183
  else: # pragma: nocover
178
184
  # This is a trick so mypy generates an error if this branch can be reached,
179
185
  # that is, if we are missing some ifs
@@ -201,6 +207,9 @@ def _parse_relation_query(
201
207
  elif isinstance(expr, graph_requests.Relation):
202
208
  _set_relation_to_pb(expr, pb.path.relation)
203
209
 
210
+ elif isinstance(expr, graph_requests.Generated):
211
+ _set_generated_to_pb(expr, pb)
212
+
204
213
  else: # pragma: nocover
205
214
  # This is a trick so mypy generates an error if this branch can be reached,
206
215
  # that is, if we are missing some ifs
@@ -235,3 +244,23 @@ def _set_relation_to_pb(relation: graph_requests.GraphRelation, pb: nodereader_p
235
244
  pb.value = relation.label
236
245
  if relation.type is not None:
237
246
  pb.relation_type = RelationTypeMap[relation.type]
247
+
248
+
249
+ def _set_generated_to_pb(generated: graph_requests.Generated, pb: nodereader_pb2.GraphQuery.PathQuery):
250
+ if generated.by == graph_requests.Generator.USER:
251
+ pb.facet.facet = "/g/u"
252
+
253
+ elif generated.by == graph_requests.Generator.PROCESSOR:
254
+ pb.bool_not.facet.facet = "/g"
255
+
256
+ elif generated.by == graph_requests.Generator.DATA_AUGMENTATION:
257
+ facet = "/g/da"
258
+ if generated.da_task is not None:
259
+ facet += f"/{generated.da_task}"
260
+
261
+ pb.facet.facet = facet
262
+
263
+ else: # pragma: nocover
264
+ # This is a trick so mypy generates an error if this branch can be reached,
265
+ # that is, if we are missing some ifs
266
+ _a: int = "a"
@@ -180,9 +180,15 @@ async def set_labelset_endpoint(request: Request, kbid: str, labelset: str, item
180
180
 
181
181
  try:
182
182
  labelsets = await datamanagers.atomic.labelset.get_all(kbid=kbid)
183
- labelset_titles = [ls.title.lower() for (k, ls) in labelsets.labelset.items() if k != labelset]
183
+ labelset_titles = {
184
+ ls.title.lower(): k for (k, ls) in labelsets.labelset.items() if k != labelset
185
+ }
184
186
  if item.title.lower() in labelset_titles:
185
- raise HTTPException(status_code=422, detail="Duplicated labelset titles are not allowed")
187
+ conflict = labelset_titles[item.title.lower()]
188
+ raise HTTPException(
189
+ status_code=422,
190
+ detail=f"Duplicated labelset titles are not allowed. Labelset {conflict} has the same title",
191
+ )
186
192
 
187
193
  await set_labelset(kbid, labelset, item)
188
194
  except KnowledgeBoxNotFound:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.3.4.post3769
3
+ Version: 6.3.4.post3785
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.4.post3769
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3769
25
- Requires-Dist: nucliadb-protos>=6.3.4.post3769
26
- Requires-Dist: nucliadb-models>=6.3.4.post3769
27
- Requires-Dist: nidx-protos>=6.3.4.post3769
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.4.post3785
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3785
25
+ Requires-Dist: nucliadb-protos>=6.3.4.post3785
26
+ Requires-Dist: nucliadb-models>=6.3.4.post3785
27
+ Requires-Dist: nidx-protos>=6.3.4.post3785
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
@@ -139,7 +139,7 @@ nucliadb/ingest/fields/generic.py,sha256=elgtqv15aJUq3zY7X_g0bli_2BpcwPArVvzhe54
139
139
  nucliadb/ingest/fields/link.py,sha256=kN_gjRUEEj5cy8K_BwPijYg3TiWhedc24apXYlTbRJs,4172
140
140
  nucliadb/ingest/fields/text.py,sha256=tFvSQJAe0W7ePpp2_WDfLiE2yglR1OTU0Zht9acvOFw,1594
141
141
  nucliadb/ingest/orm/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
142
- nucliadb/ingest/orm/brain.py,sha256=lvO6bF0usfbZ5T7bDPoVALfocvxTFrCE3YhQrz-d1q8,29831
142
+ nucliadb/ingest/orm/brain.py,sha256=A8H1J7Bo95sNzDgYr0_UNoemQhWOFEFz9UlYfs6ug-8,29407
143
143
  nucliadb/ingest/orm/broker_message.py,sha256=XWaiZgDOz94NPOPT-hqbRr5ZkpVimUw6PjUJNftfoVw,7514
144
144
  nucliadb/ingest/orm/entities.py,sha256=3_n6lKhBy2GsdmNmkh0_mvxP8md20OZsbtTNEmfJ8Hg,14888
145
145
  nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
@@ -226,13 +226,13 @@ nucliadb/search/search/cut.py,sha256=ytY0_GY7ocNjfxTb4aosxEp4ZfhQNDP--JkhEMGD298
226
226
  nucliadb/search/search/exceptions.py,sha256=klGLgAGGrXcSGix_W6418ZBMqDchAIGjN77ofkOScEI,1039
227
227
  nucliadb/search/search/fetch.py,sha256=XJHIFnZmXM_8Kb37lb4lg1GYG7cZ1plT-qAIb_QziX4,6184
228
228
  nucliadb/search/search/filters.py,sha256=1MkHlJjAQqoRCj7e5cEzK2HvBxGLE17I_omsjiklbtw,6476
229
- nucliadb/search/search/find.py,sha256=p7Odx3hjPwTsHEhQrVYsR_ufq0meMmCnQV0YihfOmlg,10237
229
+ nucliadb/search/search/find.py,sha256=pjc-i55j_p_F1H0La4qc9slZSl_gICoFzl3fy6FLYTM,10314
230
230
  nucliadb/search/search/find_merge.py,sha256=3FnzKFEnVemg6FO_6zveulbAU7klvsiPEBvLrpBBMg8,17450
231
231
  nucliadb/search/search/graph_merge.py,sha256=OiUNiXOWwrUVKqStuRcoUJwvDbDYamqIgiAy_FwPdMI,3405
232
232
  nucliadb/search/search/graph_strategy.py,sha256=gisL2GpbSIa_SucyOwEt7TWdqURyAQqxvD_-PkXQct8,32339
233
233
  nucliadb/search/search/hydrator.py,sha256=-R37gCrGxkyaiHQalnTWHNG_FCx11Zucd7qA1vQCxuw,6985
234
234
  nucliadb/search/search/ingestion_agents.py,sha256=NeJr4EEX-bvFFMGvXOOwLv8uU7NuQ-ntJnnrhnKfMzY,3174
235
- nucliadb/search/search/merge.py,sha256=aNjghwyQDuoIuddFt37_kHAUv4FDYgGtdP3dM1SBUWs,22966
235
+ nucliadb/search/search/merge.py,sha256=bPO51Kc3Ec69UuCbF5ulokd02gWZhp7zlJSuMjGDo9Y,23141
236
236
  nucliadb/search/search/metrics.py,sha256=GGGtXHLhK79_ESV277xkBVjcaMURXHCxYG0EdGamUd8,2886
237
237
  nucliadb/search/search/paragraphs.py,sha256=pNAEiYqJGGUVcEf7xf-PFMVqz0PX4Qb-WNG-_zPGN2o,7799
238
238
  nucliadb/search/search/pgcatalog.py,sha256=s_J98fsX_RuFXwpejpkGqG-tD9ELuzz4YQ6U3ew5h2g,9313
@@ -258,7 +258,7 @@ nucliadb/search/search/query_parser/old_filters.py,sha256=-zbfN-RsXoj_DRjh3Lfp-w
258
258
  nucliadb/search/search/query_parser/parsers/__init__.py,sha256=ySCNSdbesLXGZyR88919njulA6UE10_3PhqMG_Yj1o4,1034
259
259
  nucliadb/search/search/query_parser/parsers/catalog.py,sha256=XdBiTweGTQkj8m_V_i2xbwp7P5pPO8K1Tud692XKhMw,7149
260
260
  nucliadb/search/search/query_parser/parsers/find.py,sha256=q3wH_i0DGceeKckYEH3c5MqM5EvRiMCL7r-6nCAId9Q,4666
261
- nucliadb/search/search/query_parser/parsers/graph.py,sha256=SfbMV-H-oCqZraQIwD8n5Hqi9dwOlvqzh_I3aZAKatg,8369
261
+ nucliadb/search/search/query_parser/parsers/graph.py,sha256=DlYZGqywJThx12Bm0NNhE3pahst3ZoOWj7lklbFDCgk,9336
262
262
  nucliadb/standalone/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
263
263
  nucliadb/standalone/api_router.py,sha256=hgq9FXpihzgjHkwcVGfGCSwyXy67fqXTfLFHuINzIi0,5567
264
264
  nucliadb/standalone/app.py,sha256=mAApNK_iVsQgJyd-mtwCeZq5csSimwnXmlQGH9a70pE,5586
@@ -335,7 +335,7 @@ nucliadb/writer/api/v1/knowledgebox.py,sha256=MLeIuym4jPrJgfy1NTcN9CpUGwuBiqDHMc
335
335
  nucliadb/writer/api/v1/learning_config.py,sha256=CKBjqcbewkfPwGUPLDWzZSpro6XkmCaVppe5Qtpu5Go,3117
336
336
  nucliadb/writer/api/v1/resource.py,sha256=jV9HM-ID1PPYypfy4Sl4_9aSPF87v7gSJZUSzHjHcQ4,19740
337
337
  nucliadb/writer/api/v1/router.py,sha256=RjuoWLpZer6Kl2BW_wznpNo6XL3BOpdTGqXZCn3QrrQ,1034
338
- nucliadb/writer/api/v1/services.py,sha256=HLQW18AEC5zQp5azpeAtRi7ZTzQSwG6SbmkHlmjTIFA,13165
338
+ nucliadb/writer/api/v1/services.py,sha256=3AUjk-SmvqJx76v7y89DZx6oyasojPliGYeniRQjpcU,13337
339
339
  nucliadb/writer/api/v1/slug.py,sha256=xlVBDBpRi9bNulpBHZwhyftVvulfE0zFm1XZIWl-AKY,2389
340
340
  nucliadb/writer/api/v1/transaction.py,sha256=d2Vbgnkk_-FLGSTt3vfldwiJIUf0XoyD0wP1jQNz_DY,2430
341
341
  nucliadb/writer/api/v1/upload.py,sha256=hLMHXSaqEOE-vjKjhIupgdx8klJc3mVQp_oMwx5N-7o,33800
@@ -354,8 +354,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
354
354
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
355
355
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
356
356
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
357
- nucliadb-6.3.4.post3769.dist-info/METADATA,sha256=3yi784IVKCq1hDA5dt7jxVLfDJ6P8kCcGxL38k64JZ4,4291
358
- nucliadb-6.3.4.post3769.dist-info/WHEEL,sha256=L0N565qmK-3nM2eBoMNFszYJ_MTx03_tQ0CQu1bHLYo,91
359
- nucliadb-6.3.4.post3769.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
360
- nucliadb-6.3.4.post3769.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
361
- nucliadb-6.3.4.post3769.dist-info/RECORD,,
357
+ nucliadb-6.3.4.post3785.dist-info/METADATA,sha256=4HSRfhdLXMRNJ7A-J_jKPIAamg8m_D6lFFhoOOdRDQc,4291
358
+ nucliadb-6.3.4.post3785.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
359
+ nucliadb-6.3.4.post3785.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
360
+ nucliadb-6.3.4.post3785.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
361
+ nucliadb-6.3.4.post3785.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.0.1)
2
+ Generator: setuptools (78.0.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5