nucliadb 6.2.1.post2882__py3-none-any.whl → 6.2.1.post2885__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.
@@ -31,12 +31,12 @@ from nucliadb.common.maindb.utils import setup_driver
31
31
  from nucliadb.ingest import SERVICE_NAME, logger
32
32
  from nucliadb.ingest.orm.broker_message import generate_broker_message
33
33
  from nucliadb.ingest.orm.entities import EntitiesManager
34
- from nucliadb.ingest.orm.exceptions import KnowledgeBoxConflict, VectorSetConflict
34
+ from nucliadb.ingest.orm.exceptions import KnowledgeBoxConflict
35
35
  from nucliadb.ingest.orm.knowledgebox import KnowledgeBox as KnowledgeBoxORM
36
36
  from nucliadb.ingest.orm.processor import Processor, sequence_manager
37
37
  from nucliadb.ingest.orm.resource import Resource as ResourceORM
38
38
  from nucliadb.ingest.settings import settings
39
- from nucliadb_protos import nodewriter_pb2, writer_pb2, writer_pb2_grpc
39
+ from nucliadb_protos import writer_pb2, writer_pb2_grpc
40
40
  from nucliadb_protos.knowledgebox_pb2 import (
41
41
  DeleteKnowledgeBoxResponse,
42
42
  KnowledgeBoxID,
@@ -44,13 +44,10 @@ from nucliadb_protos.knowledgebox_pb2 import (
44
44
  KnowledgeBoxUpdate,
45
45
  SemanticModelMetadata,
46
46
  UpdateKnowledgeBoxResponse,
47
- VectorSetConfig,
48
47
  )
49
48
  from nucliadb_protos.writer_pb2 import (
50
49
  BrokerMessage,
51
50
  DelEntitiesRequest,
52
- DelVectorSetRequest,
53
- DelVectorSetResponse,
54
51
  GetEntitiesGroupRequest,
55
52
  GetEntitiesGroupResponse,
56
53
  GetEntitiesRequest,
@@ -63,8 +60,6 @@ from nucliadb_protos.writer_pb2 import (
63
60
  ListMembersResponse,
64
61
  NewEntitiesGroupRequest,
65
62
  NewEntitiesGroupResponse,
66
- NewVectorSetRequest,
67
- NewVectorSetResponse,
68
63
  OpStatusWriter,
69
64
  SetEntitiesRequest,
70
65
  UpdateEntitiesGroupRequest,
@@ -472,56 +467,3 @@ class WriterServicer(writer_pb2_grpc.WriterServicer):
472
467
  errors.capture_exception(e)
473
468
  logger.error("Error in ingest gRPC servicer", exc_info=True)
474
469
  raise
475
-
476
- async def NewVectorSet( # type: ignore
477
- self, request: NewVectorSetRequest, context=None
478
- ) -> NewVectorSetResponse:
479
- config = VectorSetConfig(
480
- vectorset_id=request.vectorset_id,
481
- vectorset_index_config=nodewriter_pb2.VectorIndexConfig(
482
- similarity=request.similarity,
483
- normalize_vectors=request.normalize_vectors,
484
- vector_type=request.vector_type,
485
- vector_dimension=request.vector_dimension,
486
- ),
487
- matryoshka_dimensions=request.matryoshka_dimensions,
488
- storage_key_kind=VectorSetConfig.StorageKeyKind.VECTORSET_PREFIX,
489
- )
490
- response = NewVectorSetResponse()
491
- try:
492
- async with self.driver.transaction() as txn:
493
- kbobj = KnowledgeBoxORM(txn, self.storage, request.kbid)
494
- await kbobj.create_vectorset(config)
495
- await txn.commit()
496
- except VectorSetConflict as exc:
497
- response.status = NewVectorSetResponse.Status.ERROR
498
- response.details = str(exc)
499
- except Exception as exc:
500
- errors.capture_exception(exc)
501
- logger.error("Error in ingest gRPC while creating a vectorset", exc_info=True)
502
- response.status = NewVectorSetResponse.Status.ERROR
503
- response.details = str(exc)
504
- else:
505
- response.status = NewVectorSetResponse.Status.OK
506
- return response
507
-
508
- async def DelVectorSet( # type: ignore
509
- self, request: DelVectorSetRequest, context=None
510
- ) -> DelVectorSetResponse:
511
- response = DelVectorSetResponse()
512
- try:
513
- async with self.driver.transaction() as txn:
514
- kbobj = KnowledgeBoxORM(txn, self.storage, request.kbid)
515
- await kbobj.delete_vectorset(request.vectorset_id)
516
- await txn.commit()
517
- except VectorSetConflict as exc:
518
- response.status = DelVectorSetResponse.Status.ERROR
519
- response.details = str(exc)
520
- except Exception as exc:
521
- errors.capture_exception(exc)
522
- logger.error("Error in ingest gRPC while deleting a vectorset", exc_info=True)
523
- response.status = DelVectorSetResponse.Status.ERROR
524
- response.details = str(exc)
525
- else:
526
- response.status = DelVectorSetResponse.Status.OK
527
- return response
@@ -24,4 +24,5 @@ from . import learning_config # noqa
24
24
  from . import resource # noqa
25
25
  from . import services # noqa
26
26
  from . import upload # noqa
27
+ from . import vectorsets # noqa
27
28
  from .router import api # noqa
@@ -20,7 +20,7 @@
20
20
  import asyncio
21
21
  from functools import partial
22
22
 
23
- from fastapi import HTTPException, Response
23
+ from fastapi import HTTPException
24
24
  from fastapi_versioning import version
25
25
  from starlette.requests import Request
26
26
 
@@ -32,7 +32,7 @@ from nucliadb.common.external_index_providers.exceptions import (
32
32
  from nucliadb.common.maindb.utils import get_driver
33
33
  from nucliadb.ingest.orm.exceptions import KnowledgeBoxConflict
34
34
  from nucliadb.ingest.orm.knowledgebox import KnowledgeBox
35
- from nucliadb.writer import logger, vectorsets
35
+ from nucliadb.writer import logger
36
36
  from nucliadb.writer.api.utils import only_for_onprem
37
37
  from nucliadb.writer.api.v1.router import KB_PREFIX, KBS_PREFIX, api
38
38
  from nucliadb.writer.utilities import get_processing
@@ -248,47 +248,3 @@ def to_pinecone_serverless_cloud_pb(
248
248
  PineconeServerlessCloud.AZURE_EASTUS2: knowledgebox_pb2.PineconeServerlessCloud.AZURE_EASTUS2,
249
249
  PineconeServerlessCloud.GCP_US_CENTRAL1: knowledgebox_pb2.PineconeServerlessCloud.GCP_US_CENTRAL1,
250
250
  }[serverless]
251
-
252
-
253
- @api.post(
254
- f"/{KB_PREFIX}/{{kbid}}/vectorsets/{{vectorset_id}}",
255
- status_code=200,
256
- summary="Add a vectorset to Knowledge Box",
257
- tags=["Knowledge Boxes"],
258
- # TODO: remove when the feature is mature
259
- include_in_schema=False,
260
- )
261
- @requires(NucliaDBRoles.MANAGER)
262
- @version(1)
263
- async def add_vectorset(request: Request, kbid: str, vectorset_id: str) -> Response:
264
- try:
265
- await vectorsets.add(kbid, vectorset_id)
266
- except learning_proxy.ProxiedLearningConfigError as err:
267
- return Response(
268
- status_code=err.status_code,
269
- content=err.content,
270
- media_type=err.content_type,
271
- )
272
- return Response(status_code=200)
273
-
274
-
275
- @api.delete(
276
- f"/{KB_PREFIX}/{{kbid}}/vectorsets/{{vectorset_id}}",
277
- status_code=200,
278
- summary="Delete vectorset from Knowledge Box",
279
- tags=["Knowledge Boxes"],
280
- # TODO: remove when the feature is mature
281
- include_in_schema=False,
282
- )
283
- @requires(NucliaDBRoles.MANAGER)
284
- @version(1)
285
- async def delete_vectorset(request: Request, kbid: str, vectorset_id: str) -> Response:
286
- try:
287
- await vectorsets.delete(kbid, vectorset_id)
288
- except learning_proxy.ProxiedLearningConfigError as err:
289
- return Response(
290
- status_code=err.status_code,
291
- content=err.content,
292
- media_type=err.content_type,
293
- )
294
- return Response(status_code=200)
@@ -0,0 +1,79 @@
1
+ # Copyright (C) 2021 Bosutech XXI S.L.
2
+ #
3
+ # nucliadb is offered under the AGPL v3.0 and as commercial software.
4
+ # For commercial licensing, contact us at info@nuclia.com.
5
+ #
6
+ # AGPL:
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Affero General Public License as
9
+ # published by the Free Software Foundation, either version 3 of the
10
+ # License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Affero General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Affero General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ from fastapi import Response
22
+ from fastapi_versioning import version
23
+ from starlette.requests import Request
24
+
25
+ from nucliadb import learning_proxy
26
+ from nucliadb.ingest.orm.exceptions import VectorSetConflict
27
+ from nucliadb.models.responses import HTTPConflict
28
+ from nucliadb.writer import vectorsets
29
+ from nucliadb.writer.api.v1.router import KB_PREFIX, api
30
+ from nucliadb_models.resource import (
31
+ NucliaDBRoles,
32
+ )
33
+ from nucliadb_utils.authentication import requires
34
+
35
+
36
+ @api.post(
37
+ f"/{KB_PREFIX}/{{kbid}}/vectorsets/{{vectorset_id}}",
38
+ status_code=200,
39
+ summary="Add a vectorset to Knowledge Box",
40
+ tags=["Knowledge Boxes"],
41
+ # TODO: remove when the feature is mature
42
+ include_in_schema=False,
43
+ )
44
+ @requires(NucliaDBRoles.MANAGER)
45
+ @version(1)
46
+ async def add_vectorset(request: Request, kbid: str, vectorset_id: str) -> Response:
47
+ try:
48
+ await vectorsets.add(kbid, vectorset_id)
49
+ except learning_proxy.ProxiedLearningConfigError as err:
50
+ return Response(
51
+ status_code=err.status_code,
52
+ content=err.content,
53
+ media_type=err.content_type,
54
+ )
55
+ return Response(status_code=200)
56
+
57
+
58
+ @api.delete(
59
+ f"/{KB_PREFIX}/{{kbid}}/vectorsets/{{vectorset_id}}",
60
+ status_code=200,
61
+ summary="Delete vectorset from Knowledge Box",
62
+ tags=["Knowledge Boxes"],
63
+ # TODO: remove when the feature is mature
64
+ include_in_schema=False,
65
+ )
66
+ @requires(NucliaDBRoles.MANAGER)
67
+ @version(1)
68
+ async def delete_vectorset(request: Request, kbid: str, vectorset_id: str) -> Response:
69
+ try:
70
+ await vectorsets.delete(kbid, vectorset_id)
71
+ except VectorSetConflict as exc:
72
+ return HTTPConflict(detail=str(exc))
73
+ except learning_proxy.ProxiedLearningConfigError as err:
74
+ return Response(
75
+ status_code=err.status_code,
76
+ content=err.content,
77
+ media_type=err.content_type,
78
+ )
79
+ return Response(status_code=200)
@@ -59,9 +59,10 @@ async def add(kbid: str, vectorset_id: str) -> None:
59
59
  assert lconfig is not None
60
60
 
61
61
  # Then, add the vectorset to the index if it's not already there
62
+ storage = await get_storage()
63
+ vectorset_config = get_vectorset_config(lconfig, vectorset_id)
62
64
  async with datamanagers.with_rw_transaction() as txn:
63
- kbobj = KnowledgeBox(txn, await get_storage(), kbid)
64
- vectorset_config = get_vectorset_config(lconfig, vectorset_id)
65
+ kbobj = KnowledgeBox(txn, storage, kbid)
65
66
  try:
66
67
  await kbobj.create_vectorset(vectorset_config)
67
68
  await txn.commit()
@@ -77,11 +78,17 @@ async def delete(kbid: str, vectorset_id: str) -> None:
77
78
  if vectorset_id in semantic_models:
78
79
  semantic_models.remove(vectorset_id)
79
80
  await learning_proxy.update_configuration(kbid, {"semantic_models": semantic_models})
81
+
82
+ storage = await get_storage()
80
83
  try:
81
84
  async with datamanagers.with_rw_transaction() as txn:
82
- kbobj = KnowledgeBox(txn, await get_storage(), kbid)
85
+ kbobj = KnowledgeBox(txn, storage, kbid)
83
86
  await kbobj.delete_vectorset(vectorset_id=vectorset_id)
84
87
  await txn.commit()
88
+
89
+ except VectorSetConflict:
90
+ # caller should handle this error
91
+ raise
85
92
  except Exception as ex:
86
93
  errors.capture_exception(ex)
87
94
  logger.exception(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb
3
- Version: 6.2.1.post2882
3
+ Version: 6.2.1.post2885
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.post2882
26
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2882
27
- Requires-Dist: nucliadb-protos>=6.2.1.post2882
28
- Requires-Dist: nucliadb-models>=6.2.1.post2882
25
+ Requires-Dist: nucliadb-telemetry[all]>=6.2.1.post2885
26
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2885
27
+ Requires-Dist: nucliadb-protos>=6.2.1.post2885
28
+ Requires-Dist: nucliadb-models>=6.2.1.post2885
29
29
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
30
30
  Requires-Dist: nucliadb-node-binding>=2.26.0
31
31
  Requires-Dist: nuclia-models>=0.24.2
@@ -152,7 +152,7 @@ nucliadb/ingest/orm/processor/processor.py,sha256=2FxAetUvtHvg6l-24xYrmBdsyqc0RU
152
152
  nucliadb/ingest/orm/processor/sequence_manager.py,sha256=uqEphtI1Ir_yk9jRl2gPf7BlzzXWovbARY5MNZSBI_8,1704
153
153
  nucliadb/ingest/service/__init__.py,sha256=MME_G_ERxzJR6JW_hfE2qcfXpmpH1kdG-S0a-M0qRm8,2043
154
154
  nucliadb/ingest/service/exceptions.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
155
- nucliadb/ingest/service/writer.py,sha256=aBLLpPUJLlIf-VjAczBCUrcb-zMxRZOFHXkA0QE1pgw,22952
155
+ nucliadb/ingest/service/writer.py,sha256=IJOuSmetWq0oajtJiq5KmFvZMaYX5LGJa6pa9eGBtHY,20406
156
156
  nucliadb/middleware/__init__.py,sha256=A8NBlBuEkunCFMKpR9gnfNELsVn0Plc55BIQMbWDM8Q,2202
157
157
  nucliadb/migrator/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
158
158
  nucliadb/migrator/command.py,sha256=dKbJ1tAmP6X4lMVRSSlz351euaqs2wBPpOczLjATUes,2089
@@ -310,14 +310,14 @@ nucliadb/writer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
310
310
  nucliadb/writer/run.py,sha256=euVZ_rtHDXs-O1kB-Pt1Id8eft9CYVpWH3zJzEoEqls,1448
311
311
  nucliadb/writer/settings.py,sha256=32Umt2SqeIL8PW4_C6hkuq01QT1YmcROiWpmoy1D5Wk,3286
312
312
  nucliadb/writer/utilities.py,sha256=AZ5qEny1Xm0IDsFtH13oJa2usvJZK8f0FdgF1LrnLCw,1036
313
- nucliadb/writer/vectorsets.py,sha256=ocUTieBzStbNRgKX32wzrNJIuSaS9NjntMYbpzbBbQ4,5520
313
+ nucliadb/writer/vectorsets.py,sha256=18XJvsyi0-tePQWig8dl5qaNPaufEZb0-uD22IAOTa0,5648
314
314
  nucliadb/writer/api/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
315
315
  nucliadb/writer/api/constants.py,sha256=qWEDjFUycrEZnSJyLnNK4PQNodU2oVmkO4NycaEZtio,1738
316
316
  nucliadb/writer/api/utils.py,sha256=wIQHlU8RQiIGVLI72suvyVIKlCU44Unh0Ae0IiN6Qwo,1313
317
- nucliadb/writer/api/v1/__init__.py,sha256=FVn7N9VJ6bsEoy4TRnkclr4Umd5hECiwPXVqRnJ8BME,1095
317
+ nucliadb/writer/api/v1/__init__.py,sha256=akI9A_jloNLb0dU4T5zjfdyvmSAiDeIdjAlzNx74FlU,1128
318
318
  nucliadb/writer/api/v1/export_import.py,sha256=6_gn0-emCjmK6bCUX5kgMvG0qkZr4HlfGmBXhhngsxo,8243
319
319
  nucliadb/writer/api/v1/field.py,sha256=OsWOYA0WQ6onE5Rkl20QIEdtrSi7Jgnu62fUt90Ziy8,17503
320
- nucliadb/writer/api/v1/knowledgebox.py,sha256=Mr1vJSWOtiraDdtoTqQ1V2rSirMdojL4wN0Q3cOiX4k,10929
320
+ nucliadb/writer/api/v1/knowledgebox.py,sha256=MLeIuym4jPrJgfy1NTcN9CpUGwuBiqDHMcx0hY9DR7g,9530
321
321
  nucliadb/writer/api/v1/learning_config.py,sha256=GaYaagjBrVG9ZxrWQyVQfqGMQV3tAJjqJ5CStaKhktU,2058
322
322
  nucliadb/writer/api/v1/resource.py,sha256=A8fAHlN5XFsg6XFYKhfWJS8czgNH6yXr-PsnUqz2WUE,18757
323
323
  nucliadb/writer/api/v1/router.py,sha256=RjuoWLpZer6Kl2BW_wznpNo6XL3BOpdTGqXZCn3QrrQ,1034
@@ -325,6 +325,7 @@ nucliadb/writer/api/v1/services.py,sha256=U8OGxhA1tdt-wxw2uDAjFpwFXFEXSDTfBe1iV5
325
325
  nucliadb/writer/api/v1/slug.py,sha256=xlVBDBpRi9bNulpBHZwhyftVvulfE0zFm1XZIWl-AKY,2389
326
326
  nucliadb/writer/api/v1/transaction.py,sha256=d2Vbgnkk_-FLGSTt3vfldwiJIUf0XoyD0wP1jQNz_DY,2430
327
327
  nucliadb/writer/api/v1/upload.py,sha256=wSSQ8cBgjkxuo9EU-buxXVunI6HIBWhTBLlDmyZJ3Ck,32909
328
+ nucliadb/writer/api/v1/vectorsets.py,sha256=zj-GBnG_H-aIRVq-9WNT9OVryeYeqdFL1YUUfebC-Ag,2758
328
329
  nucliadb/writer/resource/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
329
330
  nucliadb/writer/resource/audit.py,sha256=FvxMZPzrNHtd31HgpZEvxzwAkbxJTZRhPLqRYYJi3tA,1426
330
331
  nucliadb/writer/resource/basic.py,sha256=l9zD-Qiq4eUkHezMf0w1Ksx2izKYLYuNoMIlXcNxxpM,11163
@@ -339,9 +340,9 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
339
340
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
340
341
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
341
342
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
342
- nucliadb-6.2.1.post2882.dist-info/METADATA,sha256=BB5F9fAJJ9T68B2AhfC9Zkzda13dFCHw_87tl0GL6d0,4689
343
- nucliadb-6.2.1.post2882.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
344
- nucliadb-6.2.1.post2882.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
345
- nucliadb-6.2.1.post2882.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
346
- nucliadb-6.2.1.post2882.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
347
- nucliadb-6.2.1.post2882.dist-info/RECORD,,
343
+ nucliadb-6.2.1.post2885.dist-info/METADATA,sha256=GQkGCLD0Wvjp0o1l4iz3hWx83lpoyu8O4MIPxIQkep0,4689
344
+ nucliadb-6.2.1.post2885.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
345
+ nucliadb-6.2.1.post2885.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
346
+ nucliadb-6.2.1.post2885.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
347
+ nucliadb-6.2.1.post2885.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
348
+ nucliadb-6.2.1.post2885.dist-info/RECORD,,