nucliadb 6.6.1.post4700__py3-none-any.whl → 6.6.1.post4708__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/ingest/orm/resource.py +24 -1
- nucliadb/writer/api/v1/field.py +7 -1
- nucliadb/writer/api/v1/resource.py +20 -3
- {nucliadb-6.6.1.post4700.dist-info → nucliadb-6.6.1.post4708.dist-info}/METADATA +6 -6
- {nucliadb-6.6.1.post4700.dist-info → nucliadb-6.6.1.post4708.dist-info}/RECORD +8 -8
- {nucliadb-6.6.1.post4700.dist-info → nucliadb-6.6.1.post4708.dist-info}/WHEEL +0 -0
- {nucliadb-6.6.1.post4700.dist-info → nucliadb-6.6.1.post4708.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.6.1.post4700.dist-info → nucliadb-6.6.1.post4708.dist-info}/top_level.txt +0 -0
nucliadb/ingest/orm/resource.py
CHANGED
@@ -146,6 +146,15 @@ class Resource:
|
|
146
146
|
if basic_in_payload.HasField("metadata") and basic_in_payload.metadata.useful:
|
147
147
|
current_basic.metadata.status = basic_in_payload.metadata.status
|
148
148
|
|
149
|
+
async def title_marked_for_reset(self) -> bool:
|
150
|
+
basic = await self.get_basic()
|
151
|
+
return basic is not None and basic.reset_title
|
152
|
+
|
153
|
+
async def unmark_title_for_reset(self):
|
154
|
+
basic = await self.get_basic()
|
155
|
+
if basic:
|
156
|
+
basic.reset_title = False
|
157
|
+
|
149
158
|
@processor_observer.wrap({"type": "set_basic"})
|
150
159
|
async def set_basic(
|
151
160
|
self,
|
@@ -620,10 +629,20 @@ class Resource:
|
|
620
629
|
assert self.basic is not None
|
621
630
|
if not link_extracted_data.title:
|
622
631
|
return
|
623
|
-
if not (
|
632
|
+
if not (
|
633
|
+
self.basic.title.startswith("http")
|
634
|
+
or self.basic.title == ""
|
635
|
+
or self.basic.title == self.uuid
|
636
|
+
or await self.title_marked_for_reset()
|
637
|
+
):
|
624
638
|
return
|
639
|
+
logger.info(
|
640
|
+
"Updating resource title from link extracted data",
|
641
|
+
extra={"kbid": self.kb.kbid, "field": link_extracted_data.field, "rid": self.uuid},
|
642
|
+
)
|
625
643
|
title = link_extracted_data.title
|
626
644
|
await self.update_resource_title(title)
|
645
|
+
await self.unmark_title_for_reset()
|
627
646
|
self.modified = True
|
628
647
|
|
629
648
|
async def update_resource_title(self, computed_title: str) -> None:
|
@@ -690,6 +709,9 @@ class Resource:
|
|
690
709
|
if current_title in filenames:
|
691
710
|
# If the title is equal to any of the file filenames, we should update it
|
692
711
|
return True
|
712
|
+
if await self.title_marked_for_reset():
|
713
|
+
# If the title is marked for reset, we should update it
|
714
|
+
return True
|
693
715
|
return False
|
694
716
|
|
695
717
|
async def maybe_update_resource_title_from_file_extracted_data(self, message: BrokerMessage):
|
@@ -708,6 +730,7 @@ class Resource:
|
|
708
730
|
extra={"kbid": self.kb.kbid, "field": fid.full(), "new_title": fed.title},
|
709
731
|
)
|
710
732
|
await self.update_resource_title(fed.title)
|
733
|
+
await self.unmark_title_for_reset()
|
711
734
|
# Break after the first file with a title is found
|
712
735
|
break
|
713
736
|
|
nucliadb/writer/api/v1/field.py
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
from inspect import iscoroutinefunction
|
21
21
|
from typing import TYPE_CHECKING, Annotated, Callable, Optional, Type, Union
|
22
22
|
|
23
|
-
from fastapi import HTTPException, Response
|
23
|
+
from fastapi import HTTPException, Query, Response
|
24
24
|
from fastapi_versioning import version
|
25
25
|
from starlette.requests import Request
|
26
26
|
|
@@ -541,6 +541,10 @@ async def reprocess_file_field(
|
|
541
541
|
field_id: FieldIdString,
|
542
542
|
x_nucliadb_user: Annotated[str, X_NUCLIADB_USER] = "",
|
543
543
|
x_file_password: Annotated[Optional[str], X_FILE_PASSWORD] = None,
|
544
|
+
reset_title: bool = Query(
|
545
|
+
default=False,
|
546
|
+
description="Reset the title of the resource so that the file or link computed titles are set after processing.",
|
547
|
+
),
|
544
548
|
) -> ResourceUpdated:
|
545
549
|
await maybe_back_pressure(kbid, resource_uuid=rid)
|
546
550
|
|
@@ -590,6 +594,8 @@ async def reprocess_file_field(
|
|
590
594
|
writer.kbid = kbid
|
591
595
|
writer.uuid = rid
|
592
596
|
writer.source = BrokerMessage.MessageSource.WRITER
|
597
|
+
if reset_title:
|
598
|
+
writer.basic.reset_title = True
|
593
599
|
writer.basic.metadata.useful = True
|
594
600
|
writer.basic.metadata.status = Metadata.Status.PENDING
|
595
601
|
writer.field_statuses.append(
|
@@ -105,7 +105,6 @@ async def create_resource(
|
|
105
105
|
status_code=422,
|
106
106
|
detail="Cannot hide a resource: the KB does not have hidden resources enabled",
|
107
107
|
)
|
108
|
-
|
109
108
|
await maybe_back_pressure(kbid)
|
110
109
|
|
111
110
|
partitioning = get_partitioning()
|
@@ -394,9 +393,15 @@ async def reprocess_resource_rslug_prefix(
|
|
394
393
|
kbid: str,
|
395
394
|
rslug: str,
|
396
395
|
x_nucliadb_user: Annotated[str, X_NUCLIADB_USER] = "",
|
396
|
+
reset_title: bool = Query(
|
397
|
+
default=False,
|
398
|
+
description="Reset the title of the resource so that the file or link computed titles are set after processing.",
|
399
|
+
),
|
397
400
|
):
|
398
401
|
rid = await get_rid_from_slug_or_raise_error(kbid, rslug)
|
399
|
-
return await _reprocess_resource(
|
402
|
+
return await _reprocess_resource(
|
403
|
+
request, kbid, rid, x_nucliadb_user=x_nucliadb_user, reset_title=reset_title
|
404
|
+
)
|
400
405
|
|
401
406
|
|
402
407
|
@api.post(
|
@@ -413,8 +418,14 @@ async def reprocess_resource_rid_prefix(
|
|
413
418
|
kbid: str,
|
414
419
|
rid: str,
|
415
420
|
x_nucliadb_user: Annotated[str, X_NUCLIADB_USER] = "",
|
421
|
+
reset_title: bool = Query(
|
422
|
+
default=False,
|
423
|
+
description="Reset the title of the resource so that the file or link computed titles are set after processing.",
|
424
|
+
),
|
416
425
|
):
|
417
|
-
return await _reprocess_resource(
|
426
|
+
return await _reprocess_resource(
|
427
|
+
request, kbid, rid, x_nucliadb_user=x_nucliadb_user, reset_title=reset_title
|
428
|
+
)
|
418
429
|
|
419
430
|
|
420
431
|
async def _reprocess_resource(
|
@@ -422,6 +433,10 @@ async def _reprocess_resource(
|
|
422
433
|
kbid: str,
|
423
434
|
rid: str,
|
424
435
|
x_nucliadb_user: str,
|
436
|
+
reset_title: bool = Query(
|
437
|
+
default=False,
|
438
|
+
description="Reset the title of the resource so that the file or link computed titles are set after processing.",
|
439
|
+
),
|
425
440
|
):
|
426
441
|
await validate_rid_exists_or_raise_error(kbid, rid)
|
427
442
|
await maybe_back_pressure(kbid, resource_uuid=rid)
|
@@ -464,6 +479,8 @@ async def _reprocess_resource(
|
|
464
479
|
writer.kbid = kbid
|
465
480
|
writer.uuid = rid
|
466
481
|
writer.source = BrokerMessage.MessageSource.WRITER
|
482
|
+
if reset_title:
|
483
|
+
writer.basic.reset_title = True
|
467
484
|
writer.basic.metadata.useful = True
|
468
485
|
writer.basic.metadata.status = Metadata.Status.PENDING
|
469
486
|
await transaction.commit(writer, partition, wait=False)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.6.1.
|
3
|
+
Version: 6.6.1.post4708
|
4
4
|
Summary: NucliaDB
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
@@ -19,11 +19,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
20
20
|
Requires-Python: <4,>=3.9
|
21
21
|
Description-Content-Type: text/markdown
|
22
|
-
Requires-Dist: nucliadb-telemetry[all]>=6.6.1.
|
23
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.6.1.
|
24
|
-
Requires-Dist: nucliadb-protos>=6.6.1.
|
25
|
-
Requires-Dist: nucliadb-models>=6.6.1.
|
26
|
-
Requires-Dist: nidx-protos>=6.6.1.
|
22
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.6.1.post4708
|
23
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.6.1.post4708
|
24
|
+
Requires-Dist: nucliadb-protos>=6.6.1.post4708
|
25
|
+
Requires-Dist: nucliadb-models>=6.6.1.post4708
|
26
|
+
Requires-Dist: nidx-protos>=6.6.1.post4708
|
27
27
|
Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
|
28
28
|
Requires-Dist: nuclia-models>=0.43.0
|
29
29
|
Requires-Dist: uvicorn[standard]
|
@@ -163,7 +163,7 @@ nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmB
|
|
163
163
|
nucliadb/ingest/orm/index_message.py,sha256=DWMTHJoVamUbK8opKl5csDvxfgz7c2j7phG1Ut4yIxk,15724
|
164
164
|
nucliadb/ingest/orm/knowledgebox.py,sha256=_rkeTMIXMhR64gbYtZpFHoUHghV2DTJ2lUBqZsoqC_4,23898
|
165
165
|
nucliadb/ingest/orm/metrics.py,sha256=OiuggTh-n3kZHA2G73NEUdIlh8c3yFrbusI88DK-Mko,1273
|
166
|
-
nucliadb/ingest/orm/resource.py,sha256=
|
166
|
+
nucliadb/ingest/orm/resource.py,sha256=G3efCiOnaIW0pdPtB28PkKgaOEE-7A5PnugBu3f9-OQ,38589
|
167
167
|
nucliadb/ingest/orm/utils.py,sha256=fCQRuyecgqhaY7mcBG93oaXMkzkKb9BFjOcy4-ZiSNw,2693
|
168
168
|
nucliadb/ingest/orm/processor/__init__.py,sha256=Aqd9wCNTvggkMkCY3WvoI8spdr94Jnqk-0iq9XpLs18,922
|
169
169
|
nucliadb/ingest/orm/processor/auditing.py,sha256=TeYhXGJRyQ7ROytbb2u8R0fIh_FYi3HgTu3S1ribY3U,4623
|
@@ -352,10 +352,10 @@ nucliadb/writer/api/constants.py,sha256=qWEDjFUycrEZnSJyLnNK4PQNodU2oVmkO4NycaEZ
|
|
352
352
|
nucliadb/writer/api/utils.py,sha256=wIQHlU8RQiIGVLI72suvyVIKlCU44Unh0Ae0IiN6Qwo,1313
|
353
353
|
nucliadb/writer/api/v1/__init__.py,sha256=akI9A_jloNLb0dU4T5zjfdyvmSAiDeIdjAlzNx74FlU,1128
|
354
354
|
nucliadb/writer/api/v1/export_import.py,sha256=v0sU55TtRSqDzwkDgcwv2uSaqKCuQTtGcMpYoHQYBQA,8192
|
355
|
-
nucliadb/writer/api/v1/field.py,sha256=
|
355
|
+
nucliadb/writer/api/v1/field.py,sha256=rF_x6fVczZKa4xBrHChUVau-70uFJT7srQpOLuqG2ic,18755
|
356
356
|
nucliadb/writer/api/v1/knowledgebox.py,sha256=PHEYDFa-sN5JrI8-EiVVg5FDOsRuCLT43kyAB4xt-xA,9530
|
357
357
|
nucliadb/writer/api/v1/learning_config.py,sha256=CKBjqcbewkfPwGUPLDWzZSpro6XkmCaVppe5Qtpu5Go,3117
|
358
|
-
nucliadb/writer/api/v1/resource.py,sha256=
|
358
|
+
nucliadb/writer/api/v1/resource.py,sha256=gr4VtYOtnIAL5zsDQsBDzeOOWWh6wN7PUh1XgUsQ9N4,20436
|
359
359
|
nucliadb/writer/api/v1/router.py,sha256=RjuoWLpZer6Kl2BW_wznpNo6XL3BOpdTGqXZCn3QrrQ,1034
|
360
360
|
nucliadb/writer/api/v1/services.py,sha256=3AUjk-SmvqJx76v7y89DZx6oyasojPliGYeniRQjpcU,13337
|
361
361
|
nucliadb/writer/api/v1/slug.py,sha256=xlVBDBpRi9bNulpBHZwhyftVvulfE0zFm1XZIWl-AKY,2389
|
@@ -376,8 +376,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
376
376
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
377
377
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
378
378
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
379
|
-
nucliadb-6.6.1.
|
380
|
-
nucliadb-6.6.1.
|
381
|
-
nucliadb-6.6.1.
|
382
|
-
nucliadb-6.6.1.
|
383
|
-
nucliadb-6.6.1.
|
379
|
+
nucliadb-6.6.1.post4708.dist-info/METADATA,sha256=5ExGb5nsHOVIevztP91xdMRXg7XyF1I1uAJE8NB0OhU,4158
|
380
|
+
nucliadb-6.6.1.post4708.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
381
|
+
nucliadb-6.6.1.post4708.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
382
|
+
nucliadb-6.6.1.post4708.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
383
|
+
nucliadb-6.6.1.post4708.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|