nucliadb 6.3.4.post3686__py3-none-any.whl → 6.3.4.post3694__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.
@@ -282,7 +282,11 @@ async def restore_search_configurations(context: ApplicationContext, kbid: str,
282
282
  bucket=settings.backups_bucket,
283
283
  key=StorageKeys.SEARCH_CONFIGURATIONS.format(backup_id=backup_id),
284
284
  )
285
- as_dict: dict[str, dict[str, Any]] = json.loads(raw.getvalue())
285
+ value = raw.getvalue()
286
+ if not value:
287
+ # No search configurations to restore
288
+ return
289
+ as_dict: dict[str, Any] = json.loads(value)
286
290
  search_configurations: dict[str, SearchConfiguration] = {}
287
291
  for name, data in as_dict.items():
288
292
  config: SearchConfiguration = TypeAdapter(SearchConfiguration).validate_python(data)
@@ -30,6 +30,7 @@ from nucliadb_models.metadata import ResourceProcessingStatus
30
30
  from nucliadb_protos import utils_pb2
31
31
  from nucliadb_protos.noderesources_pb2 import IndexParagraph as BrainParagraph
32
32
  from nucliadb_protos.noderesources_pb2 import (
33
+ IndexRelation,
33
34
  ParagraphMetadata,
34
35
  Representation,
35
36
  ResourceID,
@@ -232,15 +233,22 @@ class ResourceBrain:
232
233
  full_field_id = ids.FieldId(rid=self.rid, type=field_type, key=field_name).full()
233
234
  self.brain.paragraphs_to_delete.append(full_field_id)
234
235
 
236
+ field_relations = self.brain.field_relations[field_key].relations
235
237
  for relations in metadata.metadata.relations:
236
238
  for relation in relations.relations:
237
239
  self.brain.relations.append(relation)
238
240
 
241
+ index_relation = IndexRelation(relation=relation)
242
+ if relation.metadata.HasField("data_augmentation_task_id"):
243
+ index_relation.facets.append(f"/g/da/{relation.metadata.data_augmentation_task_id}")
244
+ field_relations.append(index_relation)
245
+
239
246
  def delete_field(self, field_key: str):
240
247
  ftype, fkey = field_key.split("/")
241
248
  full_field_id = ids.FieldId(rid=self.rid, type=ftype, key=fkey).full()
242
249
  self.brain.paragraphs_to_delete.append(full_field_id)
243
250
  self.brain.sentences_to_delete.append(full_field_id)
251
+ self.brain.relation_fields_to_delete.append(field_key)
244
252
 
245
253
  def apply_field_vectors(
246
254
  self,
@@ -408,12 +416,14 @@ class ResourceBrain:
408
416
  # origin contributors
409
417
  for contrib in origin.colaborators:
410
418
  relationnodeuser = RelationNode(value=contrib, ntype=RelationNode.NodeType.USER)
411
- self.brain.relations.append(
412
- Relation(
413
- relation=Relation.COLAB,
414
- source=relationnodedocument,
415
- to=relationnodeuser,
416
- )
419
+ relation = Relation(
420
+ relation=Relation.COLAB,
421
+ source=relationnodedocument,
422
+ to=relationnodeuser,
423
+ )
424
+ self.brain.relations.append(relation)
425
+ self.brain.field_relations["a/metadata"].relations.append(
426
+ IndexRelation(relation=relation)
417
427
  )
418
428
 
419
429
  # labels
@@ -422,16 +432,22 @@ class ResourceBrain:
422
432
  value=f"{classification.labelset}/{classification.label}",
423
433
  ntype=RelationNode.NodeType.LABEL,
424
434
  )
425
- self.brain.relations.append(
426
- Relation(
427
- relation=Relation.ABOUT,
428
- source=relationnodedocument,
429
- to=relation_node_label,
430
- )
435
+ relation = Relation(
436
+ relation=Relation.ABOUT,
437
+ source=relationnodedocument,
438
+ to=relation_node_label,
431
439
  )
440
+ self.brain.relations.append(relation)
441
+ self.brain.field_relations["a/metadata"].relations.append(IndexRelation(relation=relation))
432
442
 
433
443
  # relations
434
- self.brain.relations.extend(user_relations.relations)
444
+ for relation in user_relations.relations:
445
+ self.brain.relations.append(relation)
446
+ self.brain.field_relations["a/metadata"].relations.append(
447
+ IndexRelation(relation=relation, facets=["/g/u"])
448
+ )
449
+
450
+ self.brain.relation_fields_to_delete.append("a/metadata")
435
451
 
436
452
  def _set_resource_labels(self, basic: Basic, origin: Optional[Origin]):
437
453
  if origin is not None:
@@ -507,6 +523,7 @@ class ResourceBrain:
507
523
  relation.CopyFrom(base_classification_relation)
508
524
  relation.to.value = label
509
525
  self.brain.relations.append(relation)
526
+ self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
510
527
 
511
528
  # Data Augmentation + Processor entities
512
529
  base_entity_relation = Relation(
@@ -534,6 +551,7 @@ class ResourceBrain:
534
551
  relation.to.value = entity_text
535
552
  relation.to.subtype = entity_label
536
553
  self.brain.relations.append(relation)
554
+ self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
537
555
 
538
556
  # Legacy processor entities
539
557
  # TODO: Remove once processor doesn't use this anymore and remove the positions and ner fields from the message
@@ -553,6 +571,7 @@ class ResourceBrain:
553
571
  relation.to.value = entity
554
572
  relation.to.subtype = klass
555
573
  self.brain.relations.append(relation)
574
+ self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
556
575
 
557
576
  def apply_field_labels(
558
577
  self,
@@ -609,6 +628,7 @@ class ResourceBrain:
609
628
  to=relation_node_entity,
610
629
  )
611
630
  self.brain.relations.append(rel)
631
+ self.brain.field_relations[field_key].relations.append(IndexRelation(relation=rel))
612
632
  for paragraph_annotation in basic_user_fieldmetadata.paragraphs:
613
633
  for classification in paragraph_annotation.classifications:
614
634
  if not classification.cancelled_by_user:
@@ -488,7 +488,7 @@ def _merge_relations_results(
488
488
  for relation in relation_response.subgraph.relations:
489
489
  origin = relation.source
490
490
  destination = relation.to
491
- relation_type = RelationTypePbMap[relation.relation]
491
+ relation_type = RelationTypePbMap[relation.relation] # type: ignore
492
492
  relation_label = relation.relation_label
493
493
  metadata = relation.metadata if relation.HasField("metadata") else None
494
494
  # If only_with_metadata is True, we check that metadata for the relation is not None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb
3
- Version: 6.3.4.post3686
3
+ Version: 6.3.4.post3694
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.post3686
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3686
25
- Requires-Dist: nucliadb-protos>=6.3.4.post3686
26
- Requires-Dist: nucliadb-models>=6.3.4.post3686
27
- Requires-Dist: nidx-protos>=6.3.4.post3686
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.4.post3694
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3694
25
+ Requires-Dist: nucliadb-protos>=6.3.4.post3694
26
+ Requires-Dist: nucliadb-models>=6.3.4.post3694
27
+ Requires-Dist: nidx-protos>=6.3.4.post3694
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
@@ -45,7 +45,7 @@ nucliadb/backups/const.py,sha256=AaIsBB04WerR-V6t8NoCUScxO1ojMYJzfHgdkF2qh4M,201
45
45
  nucliadb/backups/create.py,sha256=D0MEpIYu74AhbZXeybinQo8cm_A2-T9JxDGLrp5lavA,12507
46
46
  nucliadb/backups/delete.py,sha256=AAs-WP-ujejj6c1LJgiMn7Ht67N_j0a1sKQlUepHpEA,2659
47
47
  nucliadb/backups/models.py,sha256=-hITU4Mv6AxePu12toBu_fjpEv6vVGcwNVxV22O9jQA,1273
48
- nucliadb/backups/restore.py,sha256=KAly9iTXUP32mFFnW6neJm7qyNSZJ7fO5LGbC46vSAM,11416
48
+ nucliadb/backups/restore.py,sha256=Jzp4mrJon3EEl8sqr0KZ5bhlhDXwIYnRD9RsBAFyEyc,11502
49
49
  nucliadb/backups/settings.py,sha256=SyzsInj1BRbBI0atg5IXWbMbOZ_eVg4eSQ3IcnUhCxQ,1357
50
50
  nucliadb/backups/tasks.py,sha256=WkL1LgdYBHbV_A5ilyYv5p3zmXwxH68TDudytN5f7zk,4225
51
51
  nucliadb/backups/utils.py,sha256=_Vogjqcru5oqNZM-bZ0q7Ju79Bv1PD-LVFEa7Z-Q13I,1261
@@ -138,7 +138,7 @@ nucliadb/ingest/fields/generic.py,sha256=elgtqv15aJUq3zY7X_g0bli_2BpcwPArVvzhe54
138
138
  nucliadb/ingest/fields/link.py,sha256=kN_gjRUEEj5cy8K_BwPijYg3TiWhedc24apXYlTbRJs,4172
139
139
  nucliadb/ingest/fields/text.py,sha256=tFvSQJAe0W7ePpp2_WDfLiE2yglR1OTU0Zht9acvOFw,1594
140
140
  nucliadb/ingest/orm/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
141
- nucliadb/ingest/orm/brain.py,sha256=JwHRneyE2sAo6PwYJnnyUMXKiGBWXLv4JI_aemodB3U,28479
141
+ nucliadb/ingest/orm/brain.py,sha256=lvO6bF0usfbZ5T7bDPoVALfocvxTFrCE3YhQrz-d1q8,29831
142
142
  nucliadb/ingest/orm/broker_message.py,sha256=XWaiZgDOz94NPOPT-hqbRr5ZkpVimUw6PjUJNftfoVw,7514
143
143
  nucliadb/ingest/orm/entities.py,sha256=3_n6lKhBy2GsdmNmkh0_mvxP8md20OZsbtTNEmfJ8Hg,14888
144
144
  nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
@@ -231,7 +231,7 @@ nucliadb/search/search/graph_merge.py,sha256=OiUNiXOWwrUVKqStuRcoUJwvDbDYamqIgiA
231
231
  nucliadb/search/search/graph_strategy.py,sha256=gisL2GpbSIa_SucyOwEt7TWdqURyAQqxvD_-PkXQct8,32339
232
232
  nucliadb/search/search/hydrator.py,sha256=-R37gCrGxkyaiHQalnTWHNG_FCx11Zucd7qA1vQCxuw,6985
233
233
  nucliadb/search/search/ingestion_agents.py,sha256=NeJr4EEX-bvFFMGvXOOwLv8uU7NuQ-ntJnnrhnKfMzY,3174
234
- nucliadb/search/search/merge.py,sha256=aUn6f5XnwWzUFhVC6uBqHE8NKdlfgw_xcTo57rS23U8,22950
234
+ nucliadb/search/search/merge.py,sha256=aNjghwyQDuoIuddFt37_kHAUv4FDYgGtdP3dM1SBUWs,22966
235
235
  nucliadb/search/search/metrics.py,sha256=GGGtXHLhK79_ESV277xkBVjcaMURXHCxYG0EdGamUd8,2886
236
236
  nucliadb/search/search/paragraphs.py,sha256=pNAEiYqJGGUVcEf7xf-PFMVqz0PX4Qb-WNG-_zPGN2o,7799
237
237
  nucliadb/search/search/pgcatalog.py,sha256=s_J98fsX_RuFXwpejpkGqG-tD9ELuzz4YQ6U3ew5h2g,9313
@@ -353,8 +353,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
353
353
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
354
354
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
355
355
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
356
- nucliadb-6.3.4.post3686.dist-info/METADATA,sha256=cSrjjD1x_Ca774OeHXlnYuqpXYq9WX3NdCCRGvCREzc,4291
357
- nucliadb-6.3.4.post3686.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
358
- nucliadb-6.3.4.post3686.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
359
- nucliadb-6.3.4.post3686.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
360
- nucliadb-6.3.4.post3686.dist-info/RECORD,,
356
+ nucliadb-6.3.4.post3694.dist-info/METADATA,sha256=yo17tzuCOWQgea8j1Eqbz0bxeZQ92VwtVowbvZAI7jM,4291
357
+ nucliadb-6.3.4.post3694.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
358
+ nucliadb-6.3.4.post3694.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
359
+ nucliadb-6.3.4.post3694.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
360
+ nucliadb-6.3.4.post3694.dist-info/RECORD,,