nucliadb 6.3.7.post4081__py3-none-any.whl → 6.3.7.post4091__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/common/context/__init__.py +90 -25
- nucliadb/common/context/fastapi.py +4 -2
- nucliadb/train/app.py +0 -3
- nucliadb/train/lifecycle.py +16 -11
- {nucliadb-6.3.7.post4081.dist-info → nucliadb-6.3.7.post4091.dist-info}/METADATA +6 -6
- {nucliadb-6.3.7.post4081.dist-info → nucliadb-6.3.7.post4091.dist-info}/RECORD +9 -9
- {nucliadb-6.3.7.post4081.dist-info → nucliadb-6.3.7.post4091.dist-info}/WHEEL +0 -0
- {nucliadb-6.3.7.post4081.dist-info → nucliadb-6.3.7.post4091.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.3.7.post4081.dist-info → nucliadb-6.3.7.post4091.dist-info}/top_level.txt +0 -0
@@ -18,17 +18,19 @@
|
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
20
|
import asyncio
|
21
|
+
from typing import Optional
|
21
22
|
|
22
23
|
from nucliadb.common.cluster.manager import KBShardManager
|
23
24
|
from nucliadb.common.cluster.settings import in_standalone_mode
|
24
25
|
from nucliadb.common.cluster.utils import setup_cluster, teardown_cluster
|
25
26
|
from nucliadb.common.maindb.driver import Driver
|
26
27
|
from nucliadb.common.maindb.utils import setup_driver, teardown_driver
|
27
|
-
from nucliadb.common.nidx import start_nidx_utility, stop_nidx_utility
|
28
|
+
from nucliadb.common.nidx import NidxUtility, start_nidx_utility, stop_nidx_utility
|
28
29
|
from nucliadb_utils.nats import NatsConnectionManager
|
29
30
|
from nucliadb_utils.partition import PartitionUtility
|
30
31
|
from nucliadb_utils.settings import indexing_settings
|
31
32
|
from nucliadb_utils.storages.storage import Storage
|
33
|
+
from nucliadb_utils.transaction import TransactionUtility
|
32
34
|
from nucliadb_utils.utilities import (
|
33
35
|
get_storage,
|
34
36
|
start_nats_manager,
|
@@ -42,16 +44,34 @@ from nucliadb_utils.utilities import (
|
|
42
44
|
|
43
45
|
|
44
46
|
class ApplicationContext:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
def __init__(
|
48
|
+
self,
|
49
|
+
service_name: str = "service",
|
50
|
+
kv_driver: bool = True,
|
51
|
+
blob_storage: bool = True,
|
52
|
+
shard_manager: bool = True,
|
53
|
+
partitioning: bool = True,
|
54
|
+
nats_manager: bool = True,
|
55
|
+
transaction: bool = True,
|
56
|
+
nidx: bool = True,
|
57
|
+
) -> None:
|
52
58
|
self.service_name = service_name
|
53
59
|
self._initialized: bool = False
|
54
60
|
self._lock = asyncio.Lock()
|
61
|
+
self._kv_driver: Optional[Driver] = None
|
62
|
+
self._blob_storage: Optional[Storage] = None
|
63
|
+
self._shard_manager: Optional[KBShardManager] = None
|
64
|
+
self._partitioning: Optional[PartitionUtility] = None
|
65
|
+
self._nats_manager: Optional[NatsConnectionManager] = None
|
66
|
+
self._transaction: Optional[TransactionUtility] = None
|
67
|
+
self._nidx: Optional[NidxUtility] = None
|
68
|
+
self.enabled_kv_driver = kv_driver
|
69
|
+
self.enabled_blob_storage = blob_storage
|
70
|
+
self.enabled_shard_manager = shard_manager
|
71
|
+
self.enabled_partitioning = partitioning
|
72
|
+
self.enabled_nats_manager = nats_manager
|
73
|
+
self.enabled_transaction = transaction
|
74
|
+
self.enabled_nidx = nidx
|
55
75
|
|
56
76
|
async def initialize(self) -> None:
|
57
77
|
if self._initialized:
|
@@ -63,30 +83,75 @@ class ApplicationContext:
|
|
63
83
|
self._initialized = True
|
64
84
|
|
65
85
|
async def _initialize(self):
|
66
|
-
self.
|
67
|
-
|
68
|
-
self.
|
69
|
-
|
70
|
-
if
|
71
|
-
self.
|
86
|
+
if self.enabled_kv_driver:
|
87
|
+
self._kv_driver = await setup_driver()
|
88
|
+
if self.enabled_blob_storage:
|
89
|
+
self._blob_storage = await get_storage()
|
90
|
+
if self.enabled_shard_manager:
|
91
|
+
self._shard_manager = await setup_cluster()
|
92
|
+
if self.enabled_partitioning:
|
93
|
+
self._partitioning = start_partitioning_utility()
|
94
|
+
if not in_standalone_mode() and self.enabled_nats_manager:
|
95
|
+
self._nats_manager = await start_nats_manager(
|
72
96
|
self.service_name,
|
73
97
|
indexing_settings.index_jetstream_servers,
|
74
98
|
indexing_settings.index_jetstream_auth,
|
75
99
|
)
|
76
|
-
|
77
|
-
|
100
|
+
if self.enabled_transaction:
|
101
|
+
self._transaction = await start_transaction_utility(self.service_name)
|
102
|
+
if self.enabled_nidx:
|
103
|
+
self._nidx = await start_nidx_utility()
|
104
|
+
|
105
|
+
@property
|
106
|
+
def kv_driver(self) -> Driver:
|
107
|
+
assert self._kv_driver is not None, "Driver not initialized"
|
108
|
+
return self._kv_driver
|
109
|
+
|
110
|
+
@property
|
111
|
+
def shard_manager(self) -> KBShardManager:
|
112
|
+
assert self._shard_manager is not None, "Shard manager not initialized"
|
113
|
+
return self._shard_manager
|
114
|
+
|
115
|
+
@property
|
116
|
+
def blob_storage(self) -> Storage:
|
117
|
+
assert self._blob_storage is not None, "Blob storage not initialized"
|
118
|
+
return self._blob_storage
|
119
|
+
|
120
|
+
@property
|
121
|
+
def partitioning(self) -> PartitionUtility:
|
122
|
+
assert self._partitioning is not None, "Partitioning not initialized"
|
123
|
+
return self._partitioning
|
124
|
+
|
125
|
+
@property
|
126
|
+
def nats_manager(self) -> NatsConnectionManager:
|
127
|
+
assert self._nats_manager is not None, "NATS manager not initialized"
|
128
|
+
return self._nats_manager
|
129
|
+
|
130
|
+
@property
|
131
|
+
def transaction(self) -> TransactionUtility:
|
132
|
+
assert self._transaction is not None, "Transaction utility not initialized"
|
133
|
+
return self._transaction
|
134
|
+
|
135
|
+
@property
|
136
|
+
def nidx(self) -> NidxUtility:
|
137
|
+
assert self._nidx is not None, "Nidx utility not initialized"
|
138
|
+
return self._nidx
|
78
139
|
|
79
140
|
async def finalize(self) -> None:
|
80
141
|
if not self._initialized:
|
81
142
|
return
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
143
|
+
if self.enabled_nidx:
|
144
|
+
await stop_nidx_utility()
|
145
|
+
if self.enabled_transaction:
|
146
|
+
await stop_transaction_utility()
|
147
|
+
if not in_standalone_mode() and self.enabled_nats_manager:
|
86
148
|
await stop_nats_manager()
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
149
|
+
if self.enabled_partitioning:
|
150
|
+
stop_partitioning_utility()
|
151
|
+
if self.enabled_shard_manager:
|
152
|
+
await teardown_cluster()
|
153
|
+
if self.enabled_blob_storage:
|
154
|
+
await teardown_storage()
|
155
|
+
if self.enabled_kv_driver:
|
156
|
+
await teardown_driver()
|
92
157
|
self._initialized = False
|
@@ -19,6 +19,7 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
from contextlib import asynccontextmanager
|
22
|
+
from typing import Optional
|
22
23
|
|
23
24
|
from fastapi import FastAPI
|
24
25
|
from starlette.routing import Mount
|
@@ -27,8 +28,9 @@ from nucliadb.common.context import ApplicationContext
|
|
27
28
|
|
28
29
|
|
29
30
|
@asynccontextmanager
|
30
|
-
async def inject_app_context(app: FastAPI):
|
31
|
-
context
|
31
|
+
async def inject_app_context(app: FastAPI, context: Optional[ApplicationContext] = None):
|
32
|
+
if context is None:
|
33
|
+
context = ApplicationContext()
|
32
34
|
|
33
35
|
app.state.context = context
|
34
36
|
|
nucliadb/train/app.py
CHANGED
@@ -33,18 +33,15 @@ from nucliadb_telemetry.fastapi.utils import (
|
|
33
33
|
client_disconnect_handler,
|
34
34
|
global_exception_handler,
|
35
35
|
)
|
36
|
-
from nucliadb_utils.audit.stream import AuditMiddleware
|
37
36
|
from nucliadb_utils.authentication import NucliaCloudAuthenticationBackend
|
38
37
|
from nucliadb_utils.fastapi.openapi import extend_openapi
|
39
38
|
from nucliadb_utils.fastapi.versioning import VersionedFastAPI
|
40
39
|
from nucliadb_utils.settings import running_settings
|
41
|
-
from nucliadb_utils.utilities import get_audit
|
42
40
|
|
43
41
|
middleware = []
|
44
42
|
middleware.extend(
|
45
43
|
[
|
46
44
|
Middleware(AuthenticationMiddleware, backend=NucliaCloudAuthenticationBackend()),
|
47
|
-
Middleware(AuditMiddleware, audit_utility_getter=get_audit),
|
48
45
|
]
|
49
46
|
)
|
50
47
|
|
nucliadb/train/lifecycle.py
CHANGED
@@ -22,32 +22,37 @@ from contextlib import asynccontextmanager
|
|
22
22
|
|
23
23
|
from fastapi import FastAPI
|
24
24
|
|
25
|
+
from nucliadb.common.context import ApplicationContext
|
25
26
|
from nucliadb.common.context.fastapi import inject_app_context
|
26
|
-
from nucliadb.common.nidx import start_nidx_utility, stop_nidx_utility
|
27
27
|
from nucliadb.train import SERVICE_NAME
|
28
28
|
from nucliadb.train.utils import (
|
29
|
-
start_shard_manager,
|
29
|
+
start_shard_manager as start_train_shard_manager,
|
30
|
+
)
|
31
|
+
from nucliadb.train.utils import (
|
30
32
|
start_train_grpc,
|
31
|
-
stop_shard_manager,
|
32
33
|
stop_train_grpc,
|
33
34
|
)
|
35
|
+
from nucliadb.train.utils import (
|
36
|
+
stop_shard_manager as stop_train_shard_manager,
|
37
|
+
)
|
34
38
|
from nucliadb_telemetry.utils import clean_telemetry, setup_telemetry
|
35
|
-
from nucliadb_utils.utilities import start_audit_utility, stop_audit_utility
|
36
39
|
|
37
40
|
|
38
41
|
@asynccontextmanager
|
39
42
|
async def lifespan(app: FastAPI):
|
40
43
|
await setup_telemetry(SERVICE_NAME)
|
41
|
-
await
|
42
|
-
await start_shard_manager()
|
44
|
+
await start_train_shard_manager()
|
43
45
|
await start_train_grpc(SERVICE_NAME)
|
44
|
-
await start_audit_utility(SERVICE_NAME)
|
45
46
|
try:
|
46
|
-
|
47
|
+
context = ApplicationContext(
|
48
|
+
service_name="train",
|
49
|
+
partitioning=False,
|
50
|
+
nats_manager=False,
|
51
|
+
transaction=False,
|
52
|
+
)
|
53
|
+
async with inject_app_context(app, context):
|
47
54
|
yield
|
48
55
|
finally:
|
49
|
-
await stop_audit_utility()
|
50
56
|
await stop_train_grpc()
|
51
|
-
await
|
52
|
-
await stop_nidx_utility()
|
57
|
+
await stop_train_shard_manager()
|
53
58
|
await clean_telemetry(SERVICE_NAME)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.3.7.
|
3
|
+
Version: 6.3.7.post4091
|
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.7.
|
24
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.7.
|
25
|
-
Requires-Dist: nucliadb-protos>=6.3.7.
|
26
|
-
Requires-Dist: nucliadb-models>=6.3.7.
|
27
|
-
Requires-Dist: nidx-protos>=6.3.7.
|
23
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.3.7.post4091
|
24
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.7.post4091
|
25
|
+
Requires-Dist: nucliadb-protos>=6.3.7.post4091
|
26
|
+
Requires-Dist: nucliadb-models>=6.3.7.post4091
|
27
|
+
Requires-Dist: nidx-protos>=6.3.7.post4091
|
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[standard]
|
@@ -70,8 +70,8 @@ nucliadb/common/cluster/settings.py,sha256=JPwV_0U_i618Tn66GWUq6qCKNjy4TWkGEGld9
|
|
70
70
|
nucliadb/common/cluster/utils.py,sha256=K0BZ75m12Tbi7KS1Tr3LqXJSPhJzUHkBMo4j8W8nQpA,4639
|
71
71
|
nucliadb/common/cluster/standalone/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
72
72
|
nucliadb/common/cluster/standalone/utils.py,sha256=af3r-x_GF7A6dwIAhZLR-r-SZQEVxsFrDKeMfUTA6G0,1908
|
73
|
-
nucliadb/common/context/__init__.py,sha256=
|
74
|
-
nucliadb/common/context/fastapi.py,sha256=
|
73
|
+
nucliadb/common/context/__init__.py,sha256=C3SsVpwyqHj2PPAUgtf0GVmq9KVQi3q5dJCsMIs9fpY,5999
|
74
|
+
nucliadb/common/context/fastapi.py,sha256=mH_8n5t7quNSPivNM2JS5EQf2sTVJsdzXW6LaY7EHAA,1629
|
75
75
|
nucliadb/common/datamanagers/__init__.py,sha256=jksw4pXyXb05SG3EN-BPBrhc1u1Ge_m21PYqD7NYQEs,2118
|
76
76
|
nucliadb/common/datamanagers/atomic.py,sha256=WihdtBWQIAuElZQjh1xQ--q5dJowwlkovqsW-OB_t2k,3230
|
77
77
|
nucliadb/common/datamanagers/cluster.py,sha256=iU0b7AESm1Yi8Wp3pIKgqixZGNMjeBrxSpvEKsaZKgY,1831
|
@@ -296,9 +296,9 @@ nucliadb/tests/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,83
|
|
296
296
|
nucliadb/tests/config.py,sha256=JN_Jhgj-fwM9_8IeO9pwxr6C1PiwRDrXxm67Y38rU30,2080
|
297
297
|
nucliadb/tests/vectors.py,sha256=CcNKx-E8LPpyvRyljbmb-Tn_wST9Juw2CBoogWrKiTk,62843
|
298
298
|
nucliadb/train/__init__.py,sha256=NVwe5yULoHXb80itIJT8YJYEz2xbiOPQ7_OMys6XJw8,1301
|
299
|
-
nucliadb/train/app.py,sha256=
|
299
|
+
nucliadb/train/app.py,sha256=z6xlGVVVaJmZZmLPIVTgkjD-wIz5b0NYlXAQp7hBHYw,2652
|
300
300
|
nucliadb/train/generator.py,sha256=B3bdkH-IWiqib-ALpU_g8wFe0xOmdE0kEPxvki28yEU,4229
|
301
|
-
nucliadb/train/lifecycle.py,sha256=
|
301
|
+
nucliadb/train/lifecycle.py,sha256=3HadM4GRsYb2m-v4jtdr9C-KBEBx8GlrJDArPYi3SWQ,1960
|
302
302
|
nucliadb/train/models.py,sha256=BmgmMjDsu_1Ih5JDAqo6whhume90q0ASJcDP9dkMQm8,1198
|
303
303
|
nucliadb/train/nodes.py,sha256=HROQMRw2g5sJTnuBagh3B0id3iWonRJ68tg3skOme9k,5748
|
304
304
|
nucliadb/train/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -365,8 +365,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
365
365
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
366
366
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
367
367
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
368
|
-
nucliadb-6.3.7.
|
369
|
-
nucliadb-6.3.7.
|
370
|
-
nucliadb-6.3.7.
|
371
|
-
nucliadb-6.3.7.
|
372
|
-
nucliadb-6.3.7.
|
368
|
+
nucliadb-6.3.7.post4091.dist-info/METADATA,sha256=en368pfXpQ5ec1oDjrmsWTHGZbhM4PYtqKEbImJziR0,4226
|
369
|
+
nucliadb-6.3.7.post4091.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
370
|
+
nucliadb-6.3.7.post4091.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
371
|
+
nucliadb-6.3.7.post4091.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
372
|
+
nucliadb-6.3.7.post4091.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|