nucliadb 6.9.0.post5126__py3-none-any.whl → 6.9.0.post5134__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.

Potentially problematic release.


This version of nucliadb might be problematic. Click here for more details.

nucliadb/common/nidx.py CHANGED
@@ -216,7 +216,7 @@ class NidxServiceUtility(NidxUtility):
216
216
  return await self.indexer.index(writer)
217
217
 
218
218
 
219
- async def start_nidx_utility(service_name: str = "nucliadb.nidx") -> Optional[NidxUtility]:
219
+ async def start_nidx_utility(service_name: str = "nucliadb.nidx") -> NidxUtility:
220
220
  nidx = get_utility(Utility.NIDX)
221
221
  if nidx:
222
222
  return nidx
@@ -22,21 +22,18 @@ import sys
22
22
  from functools import partial
23
23
  from typing import Awaitable, Callable, Optional
24
24
 
25
- from nucliadb.common.back_pressure.materializer import BackPressureMaterializer
26
- from nucliadb.common.back_pressure.settings import settings as back_pressure_settings
27
25
  from nucliadb.common.maindb.utils import setup_driver
28
26
  from nucliadb.ingest import SERVICE_NAME, logger
29
27
  from nucliadb.ingest.consumer.consumer import IngestConsumer
30
28
  from nucliadb.ingest.consumer.pull import PullV2Worker
31
29
  from nucliadb.ingest.settings import settings
32
30
  from nucliadb_utils.exceptions import ConfigurationError
33
- from nucliadb_utils.settings import indexing_settings, transaction_settings
31
+ from nucliadb_utils.settings import transaction_settings
34
32
  from nucliadb_utils.utilities import (
35
33
  get_audit,
36
34
  get_nats_manager,
37
35
  get_pubsub,
38
36
  get_storage,
39
- start_nats_manager,
40
37
  )
41
38
 
42
39
  from .auditing import IndexAuditHandler, ResourceWritesAuditHandler
@@ -57,27 +54,6 @@ async def _exit_tasks(tasks: list[asyncio.Task]) -> None:
57
54
  await asyncio.gather(*tasks, return_exceptions=True)
58
55
 
59
56
 
60
- async def start_back_pressure() -> BackPressureMaterializer:
61
- logger.info("Starting back pressure materializer")
62
- nats_manager = await start_nats_manager(
63
- SERVICE_NAME,
64
- indexing_settings.index_jetstream_servers,
65
- indexing_settings.index_jetstream_auth,
66
- )
67
- back_pressure = BackPressureMaterializer(
68
- nats_manager,
69
- indexing_check_interval=back_pressure_settings.indexing_check_interval,
70
- ingest_check_interval=back_pressure_settings.ingest_check_interval,
71
- )
72
- await back_pressure.start()
73
- return back_pressure
74
-
75
-
76
- async def stop_back_pressure(materializer: BackPressureMaterializer) -> None:
77
- await materializer.stop()
78
- await materializer.nats_manager.finalize()
79
-
80
-
81
57
  async def start_ingest_consumers(
82
58
  service_name: Optional[str] = None,
83
59
  ) -> Callable[[], Awaitable[None]]:
@@ -44,12 +44,20 @@ from nucliadb_utils.authentication import requires, requires_one
44
44
  )
45
45
  @requires(NucliaDBRoles.MANAGER)
46
46
  @version(1)
47
- async def get_kbs(request: Request, prefix: str = "") -> KnowledgeBoxList:
47
+ async def get_kbs(
48
+ request: Request,
49
+ prefix: str = "",
50
+ x_nucliadb_account: str = Header(default="", include_in_schema=False),
51
+ ) -> KnowledgeBoxList:
48
52
  driver = get_driver()
49
53
  async with driver.ro_transaction() as txn:
50
54
  response = KnowledgeBoxList()
51
55
  async for kbid, slug in datamanagers.kb.get_kbs(txn, prefix=prefix):
52
- response.kbs.append(KnowledgeBoxObjSummary(slug=slug or None, uuid=kbid))
56
+ response.kbs.append(
57
+ KnowledgeBoxObjSummary(
58
+ slug=user_kb_slug(slug, account_id=x_nucliadb_account) or None, uuid=kbid
59
+ )
60
+ )
53
61
  return response
54
62
 
55
63
 
@@ -62,7 +70,9 @@ async def get_kbs(request: Request, prefix: str = "") -> KnowledgeBoxList:
62
70
  )
63
71
  @requires_one([NucliaDBRoles.MANAGER, NucliaDBRoles.READER])
64
72
  @version(1)
65
- async def get_kb(request: Request, kbid: str) -> KnowledgeBoxObj:
73
+ async def get_kb(
74
+ request: Request, kbid: str, x_nucliadb_account: str = Header(default="", include_in_schema=False)
75
+ ) -> KnowledgeBoxObj:
66
76
  driver = get_driver()
67
77
  async with driver.ro_transaction() as txn:
68
78
  kb_config = await datamanagers.kb.get_config(txn, kbid=kbid)
@@ -71,7 +81,7 @@ async def get_kb(request: Request, kbid: str) -> KnowledgeBoxObj:
71
81
 
72
82
  return KnowledgeBoxObj(
73
83
  uuid=kbid,
74
- slug=kb_config.slug,
84
+ slug=user_kb_slug(kb_config.slug, account_id=x_nucliadb_account),
75
85
  config=from_proto.knowledgebox_config(kb_config),
76
86
  )
77
87
 
@@ -104,6 +114,18 @@ async def get_kb_by_slug(
104
114
 
105
115
  return KnowledgeBoxObj(
106
116
  uuid=kbid,
107
- slug=kb_config.slug,
117
+ slug=user_kb_slug(kb_config.slug, account_id=x_nucliadb_account),
108
118
  config=from_proto.knowledgebox_config(kb_config),
109
119
  )
120
+
121
+
122
+ def user_kb_slug(stored_slug: str, account_id: str) -> str:
123
+ if account_id != "":
124
+ # On cloud deployments, backend prepends the account id to the user-defined slug.
125
+ # This is required to make kb slugs reused across different accounts using the same nucliadb.
126
+ # We strip it so the user does not see it.
127
+ return stored_slug.split(f"{account_id}:")[-1]
128
+ else:
129
+ # On on-prem deployments, the account_id is set to "" by default and we don't need to strip
130
+ # anything as the backend is not invovled in the kb creation process.
131
+ return stored_slug
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.9.0.post5126
3
+ Version: 6.9.0.post5134
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.9.0.post5126
23
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.9.0.post5126
24
- Requires-Dist: nucliadb-protos>=6.9.0.post5126
25
- Requires-Dist: nucliadb-models>=6.9.0.post5126
26
- Requires-Dist: nidx-protos>=6.9.0.post5126
22
+ Requires-Dist: nucliadb-telemetry[all]>=6.9.0.post5134
23
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.9.0.post5134
24
+ Requires-Dist: nucliadb-protos>=6.9.0.post5134
25
+ Requires-Dist: nucliadb-models>=6.9.0.post5134
26
+ Requires-Dist: nidx-protos>=6.9.0.post5134
27
27
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
28
28
  Requires-Dist: nuclia-models>=0.50.0
29
29
  Requires-Dist: uvicorn[standard]
@@ -69,7 +69,7 @@ nucliadb/common/exceptions.py,sha256=_PJk_NfAhZBFBvmgAfvsJKZ9KuRt5Y1cNsH3-cXE07w
69
69
  nucliadb/common/filter_expression.py,sha256=-6buKY1SCVYpkrG_60Ui3ebSDWnXeF_xVmBCrNipoII,6569
70
70
  nucliadb/common/ids.py,sha256=M4bcl6gmBhVeD3XhRMv40YsbY83bOgSHInQ2ol33Mjc,8829
71
71
  nucliadb/common/locking.py,sha256=eZG47mI1OPnKbxSd95qa6jDXBhUoxVBIuSjxoEuBRWE,5894
72
- nucliadb/common/nidx.py,sha256=BcvNIwCbgrZbCDy3DYULTcuYqrHHRf1_2o2jETYEhHo,10099
72
+ nucliadb/common/nidx.py,sha256=W0NkbYfhXgyP9f0QCdAZDv4P-S99QuVrt6ft3B8CZM8,10089
73
73
  nucliadb/common/vector_index_config.py,sha256=DQrlraTWE5uUn68l9s10d3wobNeVtbP-ANEQmUfSWyo,1553
74
74
  nucliadb/common/back_pressure/__init__.py,sha256=paAcAZcfGRTyURF9lnn3vX0vcwakTEVswG_xcdGBH-U,928
75
75
  nucliadb/common/back_pressure/cache.py,sha256=ANvXglWzI5naAD6N4E_fNi17qS6KNyAhjLeh6WlZZ84,2931
@@ -149,7 +149,7 @@ nucliadb/ingest/consumer/consumer.py,sha256=1OetpJXp6glaAe4kKqUA_L46BS-ZyEccTkwt
149
149
  nucliadb/ingest/consumer/materializer.py,sha256=tgD_rDI2twQzcz8kKNiW_L4YIth16IGh9mUfD5wiSD4,3858
150
150
  nucliadb/ingest/consumer/metrics.py,sha256=ji1l_4cKiHJthQd8YNem1ft4iMbw9KThmVvJmLcv3Xg,1075
151
151
  nucliadb/ingest/consumer/pull.py,sha256=Ki_aHi72W83yD03lPt6Yz2l_uCeu62fd4upEMcOZcm4,9201
152
- nucliadb/ingest/consumer/service.py,sha256=8AD41mMN7EUeUtk4ZNy14zfvxzwmVjIX6Mwe05-bomA,6543
152
+ nucliadb/ingest/consumer/service.py,sha256=mjiEJFO9t8nsQBdbWfGyyGajaW012-6mAwMARBkedgU,5600
153
153
  nucliadb/ingest/consumer/shard_creator.py,sha256=UKIk0yaS_jC_nGQqymn9NGJWzwZEqhIr0gznJYorlAE,4348
154
154
  nucliadb/ingest/consumer/utils.py,sha256=jpX8D4lKzuPCpArQLZeX_Zczq3pfen_zAf8sPJfOEZU,2642
155
155
  nucliadb/ingest/fields/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
@@ -205,7 +205,7 @@ nucliadb/reader/api/models.py,sha256=UHhOPmh8xcHhDjFm8_-8t66yEggXdxRBoY0xV-hI9to
205
205
  nucliadb/reader/api/v1/__init__.py,sha256=ieP8lsCCwG66Jupv8II5MSTj6nh3eCtLcF4utH9JOcU,1102
206
206
  nucliadb/reader/api/v1/download.py,sha256=F48YM3BPwuHwDgYk0jjRHHJHh732QUb4nCAS5xyNqzg,10819
207
207
  nucliadb/reader/api/v1/export_import.py,sha256=x4VBNDFjnlY1nIt5kdq0eZTB_DeRzGzT8T7uB7wUhNU,6448
208
- nucliadb/reader/api/v1/knowledgebox.py,sha256=POvDz6TE8PDE7HqmN0ty8LZfvhxoWrzRxlKXqHbJEHA,4007
208
+ nucliadb/reader/api/v1/knowledgebox.py,sha256=lmKDGbpDC30XTH1yhDWwrHdV8-uc5KGfI73zlmxImGA,4973
209
209
  nucliadb/reader/api/v1/learning_config.py,sha256=wL4k9ZFK0BX17ocq1tUmbh-atLrw-Xag7Ly8wgD1xrQ,6812
210
210
  nucliadb/reader/api/v1/resource.py,sha256=WTBIEywfHfy4sIffnVm9s__3--JpHi9hprVpK0Ddd04,14164
211
211
  nucliadb/reader/api/v1/router.py,sha256=eyNmEGSP9zHkCIG5XlAXl6sukq950B7gFT3X2peMtIE,1011
@@ -384,8 +384,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
384
384
  nucliadb/writer/tus/s3.py,sha256=vu1BGg4VqJ_x2P1u2BxqPKlSfw5orT_a3R-Ln5oPUpU,8483
385
385
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
386
386
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
387
- nucliadb-6.9.0.post5126.dist-info/METADATA,sha256=_PkOcKJ6T9WTuTb7bYw0N-_9ftkg4XhoTlbdN6O9M5M,4158
388
- nucliadb-6.9.0.post5126.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
389
- nucliadb-6.9.0.post5126.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
390
- nucliadb-6.9.0.post5126.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
391
- nucliadb-6.9.0.post5126.dist-info/RECORD,,
387
+ nucliadb-6.9.0.post5134.dist-info/METADATA,sha256=u9m0m3yydjFA5OGD0VtqvgO5JfIrB0KPtp6PzV2iajU,4158
388
+ nucliadb-6.9.0.post5134.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
389
+ nucliadb-6.9.0.post5134.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
390
+ nucliadb-6.9.0.post5134.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
391
+ nucliadb-6.9.0.post5134.dist-info/RECORD,,