nucliadb 6.2.1.post2972__py3-none-any.whl → 6.2.1.post2982__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.
@@ -90,6 +90,9 @@ class Settings(BaseSettings):
90
90
  nidx_searcher_address: Optional[str] = Field(
91
91
  default=None, description="NIDX gRPC searcher API address"
92
92
  )
93
+ nidx_indexer_address: Optional[str] = Field(
94
+ default=None, description="NIDX gRPC indexer API address"
95
+ )
93
96
 
94
97
 
95
98
  settings = Settings()
nucliadb/common/nidx.py CHANGED
@@ -21,7 +21,7 @@
21
21
  import os
22
22
  from typing import Optional
23
23
 
24
- from nidx_protos.nidx_pb2_grpc import NidxApiStub, NidxSearcherStub
24
+ from nidx_protos.nidx_pb2_grpc import NidxApiStub, NidxIndexerStub, NidxSearcherStub
25
25
 
26
26
  from nucliadb.common.cluster.base import AbstractIndexNode
27
27
  from nucliadb.common.cluster.settings import settings
@@ -124,16 +124,8 @@ class NidxBindingUtility(NidxUtility):
124
124
  self.binding.wait_for_sync()
125
125
 
126
126
 
127
- class NidxServiceUtility(NidxUtility):
128
- """Implements Nidx utility connecting to the network service"""
129
-
127
+ class NidxNatsIndexer:
130
128
  def __init__(self):
131
- if indexing_settings.index_nidx_subject is None:
132
- raise ValueError("INDEX_NIDX_SUBJECT needed for nidx utility")
133
-
134
- if not settings.nidx_api_address or not settings.nidx_searcher_address:
135
- raise ValueError("NIDX_API_ADDRESS and NIDX_SEARCHER_ADDRESS are required")
136
-
137
129
  self.nats_connection_manager = NatsConnectionManager(
138
130
  service_name="NidxIndexer",
139
131
  nats_servers=indexing_settings.index_jetstream_servers,
@@ -143,10 +135,6 @@ class NidxServiceUtility(NidxUtility):
143
135
 
144
136
  async def initialize(self):
145
137
  await self.nats_connection_manager.initialize()
146
- self.api_client = NidxApiStub(get_traced_grpc_channel(settings.nidx_api_address, "nidx_api"))
147
- self.searcher_client = NidxSearcherStub(
148
- get_traced_grpc_channel(settings.nidx_searcher_address, "nidx_searcher")
149
- )
150
138
 
151
139
  async def finalize(self):
152
140
  await self.nats_connection_manager.finalize()
@@ -159,15 +147,68 @@ class NidxServiceUtility(NidxUtility):
159
147
  return res.seq
160
148
 
161
149
 
162
- async def start_nidx_utility() -> NidxUtility:
150
+ class NidxGrpcIndexer:
151
+ def __init__(self, address):
152
+ self.address = address
153
+
154
+ async def initialize(self):
155
+ self.client = NidxIndexerStub(get_traced_grpc_channel(self.address, "nidx_indexer"))
156
+
157
+ async def finalize(self):
158
+ pass
159
+
160
+ async def index(self, writer: IndexMessage) -> int:
161
+ await self.client.Index(writer)
162
+ return 0
163
+
164
+
165
+ class NidxServiceUtility(NidxUtility):
166
+ """Implements Nidx utility connecting to the network service"""
167
+
168
+ def __init__(self):
169
+ if not settings.nidx_api_address or not settings.nidx_searcher_address:
170
+ raise ValueError("NIDX_API_ADDRESS and NIDX_SEARCHER_ADDRESS are required")
171
+
172
+ if indexing_settings.index_nidx_subject:
173
+ self.indexer = NidxNatsIndexer()
174
+ elif settings.nidx_indexer_address is not None:
175
+ self.indexer = NidxGrpcIndexer(settings.nidx_indexer_address)
176
+ else:
177
+ raise ValueError("NIDX_INDEXER_ADDRESS or INDEX_NIDX_SUBJECT are required")
178
+
179
+ async def initialize(self):
180
+ await self.indexer.initialize()
181
+ self.api_client = NidxApiStub(get_traced_grpc_channel(settings.nidx_api_address, "nidx_api"))
182
+ self.searcher_client = NidxSearcherStub(
183
+ get_traced_grpc_channel(settings.nidx_searcher_address, "nidx_searcher")
184
+ )
185
+
186
+ async def finalize(self):
187
+ await self.indexer.finalize()
188
+
189
+ async def index(self, writer: IndexMessage) -> int:
190
+ return await self.indexer.index(writer)
191
+
192
+
193
+ async def start_nidx_utility() -> Optional[NidxUtility]:
163
194
  nidx = get_utility(Utility.NIDX)
164
195
  if nidx:
165
196
  return nidx
166
197
 
167
198
  nidx_utility: NidxUtility
168
199
  if settings.standalone_mode:
169
- nidx_utility = NidxBindingUtility()
200
+ if (
201
+ settings.nidx_api_address is not None
202
+ and settings.nidx_searcher_address is not None
203
+ and settings.nidx_indexer_address is not None
204
+ ):
205
+ # Standalone with nidx service (via grpc). This is used in clustered standalone mode
206
+ nidx_utility = NidxServiceUtility()
207
+ else:
208
+ # Normal standalone mode with binding
209
+ nidx_utility = NidxBindingUtility()
170
210
  else:
211
+ # Component deploy with nidx service via grpc & nats (cloud)
171
212
  nidx_utility = NidxServiceUtility()
172
213
 
173
214
  await nidx_utility.initialize()
@@ -22,6 +22,7 @@ from contextlib import asynccontextmanager
22
22
 
23
23
  from fastapi import FastAPI
24
24
 
25
+ from nucliadb.common.nidx import start_nidx_utility, stop_nidx_utility
25
26
  from nucliadb.train import SERVICE_NAME
26
27
  from nucliadb.train.utils import (
27
28
  start_shard_manager,
@@ -36,6 +37,7 @@ from nucliadb_utils.utilities import start_audit_utility, stop_audit_utility
36
37
  @asynccontextmanager
37
38
  async def lifespan(app: FastAPI):
38
39
  await setup_telemetry(SERVICE_NAME)
40
+ await start_nidx_utility()
39
41
  await start_shard_manager()
40
42
  await start_train_grpc(SERVICE_NAME)
41
43
  await start_audit_utility(SERVICE_NAME)
@@ -45,4 +47,5 @@ async def lifespan(app: FastAPI):
45
47
  await stop_audit_utility()
46
48
  await stop_train_grpc()
47
49
  await stop_shard_manager()
50
+ await stop_nidx_utility()
48
51
  await clean_telemetry(SERVICE_NAME)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb
3
- Version: 6.2.1.post2972
3
+ Version: 6.2.1.post2982
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.post2972
26
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2972
27
- Requires-Dist: nucliadb-protos>=6.2.1.post2972
28
- Requires-Dist: nucliadb-models>=6.2.1.post2972
25
+ Requires-Dist: nucliadb-telemetry[all]>=6.2.1.post2982
26
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2982
27
+ Requires-Dist: nucliadb-protos>=6.2.1.post2982
28
+ Requires-Dist: nucliadb-models>=6.2.1.post2982
29
29
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
30
30
  Requires-Dist: nuclia-models>=0.24.2
31
31
  Requires-Dist: uvicorn
@@ -41,7 +41,7 @@ nucliadb/common/constants.py,sha256=QpigxJh_CtD85Evy0PtV5cVq6x0U_f9xfIcXz1ymkUg,
41
41
  nucliadb/common/counters.py,sha256=yhJEmmrglTSrDmB8OjaFLkZ__TwhTxayyQrtacnB55I,957
42
42
  nucliadb/common/ids.py,sha256=HMb213Kz9HaY4IsBwaQJFhUErntKWV-29s0UHaGcf1E,8004
43
43
  nucliadb/common/locking.py,sha256=RL0CabZVPzxHZyUjYeUyLvsJTm7W3J9o4fEgsY_ufNc,5896
44
- nucliadb/common/nidx.py,sha256=56fimZcR-__SOfbgU72GEZqPPjYhEsz5DHurAef72XE,8823
44
+ nucliadb/common/nidx.py,sha256=_LoU8D4afEtlW0c3vGUCoatDZvMr0-2l_GtIGap7VxA,10185
45
45
  nucliadb/common/cluster/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
46
46
  nucliadb/common/cluster/base.py,sha256=kklDqyvsubNX0W494ttl9f3E58lGaX6AXqAd8XX8ZHE,5522
47
47
  nucliadb/common/cluster/exceptions.py,sha256=V3c_fgH00GyJ-a5CaGLhwTuhwhUNR9YAGvS5jaRuc_Y,1495
@@ -50,7 +50,7 @@ nucliadb/common/cluster/index_node.py,sha256=g38H1kiAliF3Y6et_CWYInpn_xPxf7THAFJ
50
50
  nucliadb/common/cluster/manager.py,sha256=3UnYwVb-ZykYfLndxM7TLw7-2T_vxqoFXMu0Pzxh5-A,15327
51
51
  nucliadb/common/cluster/rebalance.py,sha256=jSEYsPgs_Dobv3FOaKl5arBko4s8JlWkahm8LOzgNnE,9135
52
52
  nucliadb/common/cluster/rollover.py,sha256=dx6AF9ywKP10iBNlcoJgRV40921fOPpVWaCUU54hztE,25823
53
- nucliadb/common/cluster/settings.py,sha256=RqIMJNyNcn5aV5PifUflkn4zDVX-Ruo36PXGP1CV1mc,3263
53
+ nucliadb/common/cluster/settings.py,sha256=TMoym-cZsQ2soWfLAce0moSa2XncttQyhahL43LrWTo,3384
54
54
  nucliadb/common/cluster/utils.py,sha256=Vu0f6026EBELe-ff3d5B0ihD0HtjSWKDCr4dy7LmKqg,5848
55
55
  nucliadb/common/cluster/standalone/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
56
56
  nucliadb/common/cluster/standalone/utils.py,sha256=af3r-x_GF7A6dwIAhZLR-r-SZQEVxsFrDKeMfUTA6G0,1908
@@ -262,7 +262,7 @@ nucliadb/tests/vectors.py,sha256=CcNKx-E8LPpyvRyljbmb-Tn_wST9Juw2CBoogWrKiTk,628
262
262
  nucliadb/train/__init__.py,sha256=NVwe5yULoHXb80itIJT8YJYEz2xbiOPQ7_OMys6XJw8,1301
263
263
  nucliadb/train/app.py,sha256=TiRttTvekLuZdIvi46E4HyuumDTkR4G4Luqq3fEdjes,2824
264
264
  nucliadb/train/generator.py,sha256=0_zqWsLUHmJZl0lXhGorO5CWSkl42-k78dqb1slZ5h0,3904
265
- nucliadb/train/lifecycle.py,sha256=dWnFuo-nYaWd6uayregmakQaZbQFdtVJReJONhYAQYI,1581
265
+ nucliadb/train/lifecycle.py,sha256=7rW2Be9cMUg7-fY9JhC5krXBB7MDOM4BpfNRRO5IAec,1713
266
266
  nucliadb/train/models.py,sha256=BmgmMjDsu_1Ih5JDAqo6whhume90q0ASJcDP9dkMQm8,1198
267
267
  nucliadb/train/nodes.py,sha256=HROQMRw2g5sJTnuBagh3B0id3iWonRJ68tg3skOme9k,5748
268
268
  nucliadb/train/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -330,9 +330,9 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
330
330
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
331
331
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
332
332
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
333
- nucliadb-6.2.1.post2972.dist-info/METADATA,sha256=YnrbW19LMC5vJsf6nRuyDwUNVBFivf8KQJnvl2xeMro,4603
334
- nucliadb-6.2.1.post2972.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
335
- nucliadb-6.2.1.post2972.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
336
- nucliadb-6.2.1.post2972.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
337
- nucliadb-6.2.1.post2972.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
338
- nucliadb-6.2.1.post2972.dist-info/RECORD,,
333
+ nucliadb-6.2.1.post2982.dist-info/METADATA,sha256=qLoSuQ7-llmCrl_qE1DPVepIwWHmXGUpVu4EIzM3JXw,4603
334
+ nucliadb-6.2.1.post2982.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
335
+ nucliadb-6.2.1.post2982.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
336
+ nucliadb-6.2.1.post2982.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
337
+ nucliadb-6.2.1.post2982.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
338
+ nucliadb-6.2.1.post2982.dist-info/RECORD,,