nucliadb 6.3.4.post3698__py3-none-any.whl → 6.3.4.post3700__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.
@@ -233,7 +233,7 @@ class Resource:
233
233
  # Some basic fields are computed off field metadata.
234
234
  # This means we need to recompute upon field deletions.
235
235
  if deleted_fields is not None and len(deleted_fields) > 0:
236
- remove_field_classifications(self.basic, deleted_fields=deleted_fields)
236
+ delete_basic_computedmetadata_classifications(self.basic, deleted_fields=deleted_fields)
237
237
 
238
238
  await datamanagers.resources.set_basic(
239
239
  self.txn, kbid=self.kb.kbid, rid=self.uuid, basic=self.basic
@@ -848,7 +848,7 @@ class Resource:
848
848
 
849
849
  maybe_update_basic_thumbnail(self.basic, field_metadata.metadata.metadata.thumbnail)
850
850
 
851
- add_field_classifications(self.basic, field_metadata)
851
+ update_basic_computedmetadata_classifications(self.basic, field_metadata)
852
852
  self.modified = True
853
853
 
854
854
  async def _apply_extracted_vectors(
@@ -1000,37 +1000,57 @@ async def get_file_page_positions(field: File) -> FilePagePositions:
1000
1000
  return positions
1001
1001
 
1002
1002
 
1003
- def remove_field_classifications(basic: PBBasic, deleted_fields: list[FieldID]):
1003
+ def delete_basic_computedmetadata_classifications(basic: PBBasic, deleted_fields: list[FieldID]) -> bool:
1004
1004
  """
1005
- Clean classifications of fields that have been deleted
1005
+ We keep a copy of field classifications computed by the processing engine at the basic object
1006
+ so that users can easily access them without having to load the field metadata from the storage.
1007
+
1008
+ This funcion removes the field classifications for the fields that have been deleted.
1009
+ Returns whether the basic was modified.
1006
1010
  """
1007
- field_classifications = [
1011
+ if len(deleted_fields) == 0:
1012
+ # Nothing to delete
1013
+ return False
1014
+ new_field_classifications = [
1008
1015
  fc for fc in basic.computedmetadata.field_classifications if fc.field not in deleted_fields
1009
1016
  ]
1017
+ if len(new_field_classifications) == len(basic.computedmetadata.field_classifications):
1018
+ # No changes
1019
+ return False
1020
+
1010
1021
  basic.computedmetadata.ClearField("field_classifications")
1011
- basic.computedmetadata.field_classifications.extend(field_classifications)
1022
+ basic.computedmetadata.field_classifications.extend(new_field_classifications)
1023
+ return True
1012
1024
 
1013
1025
 
1014
- def add_field_classifications(basic: PBBasic, fcmw: FieldComputedMetadataWrapper) -> bool:
1026
+ def update_basic_computedmetadata_classifications(
1027
+ basic: PBBasic, fcmw: FieldComputedMetadataWrapper
1028
+ ) -> bool:
1015
1029
  """
1016
- Returns whether some new field classifications were added
1030
+ We keep a copy of field classifications computed by the processing engine at the basic object
1031
+ so that users can easily access them without having to load the field metadata from the storage.
1032
+
1033
+ This function updates the basic object with the new field computed metadata.
1034
+ Returns whether the basic was modified.
1017
1035
  """
1018
- if len(fcmw.metadata.metadata.classifications) == 0 and all(
1019
- len(split.classifications) == 0 for split in fcmw.metadata.split_metadata.values()
1020
- ):
1021
- return False
1036
+ some_deleted = delete_basic_computedmetadata_classifications(basic, [fcmw.field])
1022
1037
 
1023
- remove_field_classifications(basic, [fcmw.field])
1024
1038
  fcfs = FieldClassifications()
1025
1039
  fcfs.field.CopyFrom(fcmw.field)
1026
- fcfs.classifications.extend(fcmw.metadata.metadata.classifications)
1040
+
1041
+ some_added = False
1042
+ if len(fcmw.metadata.metadata.classifications) > 0:
1043
+ some_added = True
1044
+ fcfs.classifications.extend(fcmw.metadata.metadata.classifications)
1027
1045
 
1028
1046
  for split_id, split in fcmw.metadata.split_metadata.items():
1029
1047
  if split_id not in fcmw.metadata.deleted_splits:
1030
- fcfs.classifications.extend(split.classifications)
1031
-
1032
- basic.computedmetadata.field_classifications.append(fcfs)
1033
- return True
1048
+ if len(split.classifications) > 0:
1049
+ some_added = True
1050
+ fcfs.classifications.extend(split.classifications)
1051
+ if some_added:
1052
+ basic.computedmetadata.field_classifications.append(fcfs)
1053
+ return some_added or some_deleted
1034
1054
 
1035
1055
 
1036
1056
  def maybe_update_basic_summary(basic: PBBasic, summary_text: str) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb
3
- Version: 6.3.4.post3698
3
+ Version: 6.3.4.post3700
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.post3698
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3698
25
- Requires-Dist: nucliadb-protos>=6.3.4.post3698
26
- Requires-Dist: nucliadb-models>=6.3.4.post3698
27
- Requires-Dist: nidx-protos>=6.3.4.post3698
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.4.post3700
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3700
25
+ Requires-Dist: nucliadb-protos>=6.3.4.post3700
26
+ Requires-Dist: nucliadb-models>=6.3.4.post3700
27
+ Requires-Dist: nidx-protos>=6.3.4.post3700
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
@@ -144,7 +144,7 @@ nucliadb/ingest/orm/entities.py,sha256=3_n6lKhBy2GsdmNmkh0_mvxP8md20OZsbtTNEmfJ8
144
144
  nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
145
145
  nucliadb/ingest/orm/knowledgebox.py,sha256=IGOPvBR1qXqDxE5DeiOdYCLdPgjzOVVpsASJ2zYvWwQ,23651
146
146
  nucliadb/ingest/orm/metrics.py,sha256=OkwMSPKLZcKba0ZTwtTiIxwBgaLMX5ydhGieKvi2y7E,1096
147
- nucliadb/ingest/orm/resource.py,sha256=tukAbD32HrRbVa_Ppo9H2YaYQyq659BzOQ45643sp7E,44964
147
+ nucliadb/ingest/orm/resource.py,sha256=oFD7APhmG1A72h7DTKumZWQRpIDM0o_FytP1P-CcNq0,45918
148
148
  nucliadb/ingest/orm/utils.py,sha256=vCe_9UxHu26JDFGLwQ0wH-XyzJIpQCTK-Ow9dtZR5Vg,2716
149
149
  nucliadb/ingest/orm/processor/__init__.py,sha256=Aqd9wCNTvggkMkCY3WvoI8spdr94Jnqk-0iq9XpLs18,922
150
150
  nucliadb/ingest/orm/processor/auditing.py,sha256=TeYhXGJRyQ7ROytbb2u8R0fIh_FYi3HgTu3S1ribY3U,4623
@@ -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.post3698.dist-info/METADATA,sha256=eId6hciRE0AtrTvOycJk5qjNygXc6kuyn-qX5nSO5eU,4291
357
- nucliadb-6.3.4.post3698.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
358
- nucliadb-6.3.4.post3698.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
359
- nucliadb-6.3.4.post3698.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
360
- nucliadb-6.3.4.post3698.dist-info/RECORD,,
356
+ nucliadb-6.3.4.post3700.dist-info/METADATA,sha256=5dBYe9gcvL1YHh_TpryJ925J1XvCRcFM5CpCDoolblA,4291
357
+ nucliadb-6.3.4.post3700.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
358
+ nucliadb-6.3.4.post3700.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
359
+ nucliadb-6.3.4.post3700.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
360
+ nucliadb-6.3.4.post3700.dist-info/RECORD,,