nucliadb 6.3.1.post3570__py3-none-any.whl → 6.3.1.post3571__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/export_import/tasks.py +2 -5
- nucliadb/tasks/producer.py +6 -18
- nucliadb/writer/api/v1/export_import.py +2 -2
- {nucliadb-6.3.1.post3570.dist-info → nucliadb-6.3.1.post3571.dist-info}/METADATA +6 -6
- {nucliadb-6.3.1.post3570.dist-info → nucliadb-6.3.1.post3571.dist-info}/RECORD +8 -8
- {nucliadb-6.3.1.post3570.dist-info → nucliadb-6.3.1.post3571.dist-info}/WHEEL +0 -0
- {nucliadb-6.3.1.post3570.dist-info → nucliadb-6.3.1.post3571.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.3.1.post3570.dist-info → nucliadb-6.3.1.post3571.dist-info}/top_level.txt +0 -0
nucliadb/export_import/tasks.py
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
# You should have received a copy of the GNU Affero General Public License
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
|
-
from nucliadb.common.context import ApplicationContext
|
21
20
|
from nucliadb.export_import.exporter import export_kb_to_blob_storage
|
22
21
|
from nucliadb.export_import.importer import import_kb_from_blob_storage
|
23
22
|
from nucliadb.export_import.models import NatsTaskMessage
|
@@ -60,14 +59,13 @@ def get_exports_consumer() -> NatsTaskConsumer[NatsTaskMessage]:
|
|
60
59
|
)
|
61
60
|
|
62
61
|
|
63
|
-
|
62
|
+
def get_exports_producer() -> NatsTaskProducer[NatsTaskMessage]:
|
64
63
|
producer = create_producer(
|
65
64
|
name="exports_producer",
|
66
65
|
stream=ExportsNatsConfig.stream,
|
67
66
|
producer_subject=ExportsNatsConfig.consumer.subject,
|
68
67
|
msg_type=NatsTaskMessage,
|
69
68
|
)
|
70
|
-
await producer.initialize(context)
|
71
69
|
return producer
|
72
70
|
|
73
71
|
|
@@ -82,12 +80,11 @@ def get_imports_consumer() -> NatsTaskConsumer[NatsTaskMessage]:
|
|
82
80
|
)
|
83
81
|
|
84
82
|
|
85
|
-
|
83
|
+
def get_imports_producer() -> NatsTaskProducer[NatsTaskMessage]:
|
86
84
|
producer = create_producer(
|
87
85
|
name="imports_producer",
|
88
86
|
stream=ImportsNatsConfig.stream,
|
89
87
|
producer_subject=ImportsNatsConfig.consumer.subject,
|
90
88
|
msg_type=NatsTaskMessage,
|
91
89
|
)
|
92
|
-
await producer.initialize(context)
|
93
90
|
return producer
|
nucliadb/tasks/producer.py
CHANGED
@@ -17,13 +17,13 @@
|
|
17
17
|
# You should have received a copy of the GNU Affero General Public License
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
|
-
from typing import Generic,
|
20
|
+
from typing import Generic, Type
|
21
21
|
|
22
|
-
from nucliadb.common.context import ApplicationContext
|
23
22
|
from nucliadb.tasks.logger import logger
|
24
23
|
from nucliadb.tasks.models import MsgType
|
25
|
-
from nucliadb.tasks.utils import NatsStream
|
24
|
+
from nucliadb.tasks.utils import NatsStream
|
26
25
|
from nucliadb_telemetry import errors
|
26
|
+
from nucliadb_utils.utilities import get_nats_manager
|
27
27
|
|
28
28
|
|
29
29
|
class NatsTaskProducer(Generic[MsgType]):
|
@@ -38,29 +38,17 @@ class NatsTaskProducer(Generic[MsgType]):
|
|
38
38
|
self.stream = stream
|
39
39
|
self.producer_subject = producer_subject
|
40
40
|
self.msg_type = msg_type
|
41
|
-
self.
|
42
|
-
self.initialized = False
|
43
|
-
|
44
|
-
async def initialize(self, context: ApplicationContext):
|
45
|
-
self.context = context
|
46
|
-
await create_nats_stream_if_not_exists(
|
47
|
-
self.context,
|
48
|
-
self.stream.name,
|
49
|
-
subjects=self.stream.subjects,
|
50
|
-
)
|
51
|
-
self.initialized = True
|
41
|
+
self.nats_manager = get_nats_manager()
|
52
42
|
|
53
43
|
async def send(self, msg: MsgType) -> int:
|
54
44
|
"""
|
55
45
|
Publish message to the producer's nats stream.
|
56
46
|
Returns the sequence number of the published message.
|
57
47
|
"""
|
58
|
-
if not self.initialized:
|
59
|
-
raise RuntimeError("NatsTaskProducer not initialized")
|
60
48
|
try:
|
61
|
-
pub_ack = await self.
|
49
|
+
pub_ack = await self.nats_manager.js.publish(
|
62
50
|
self.producer_subject,
|
63
|
-
msg.model_dump_json().encode("utf-8"),
|
51
|
+
msg.model_dump_json().encode("utf-8"),
|
64
52
|
)
|
65
53
|
logger.info(
|
66
54
|
"Message sent to Nats",
|
@@ -195,7 +195,7 @@ async def start_export_task(context: ApplicationContext, kbid: str, export_id: s
|
|
195
195
|
metadata.task.status = Status.SCHEDULED
|
196
196
|
await dm.set_metadata("export", metadata)
|
197
197
|
try:
|
198
|
-
producer =
|
198
|
+
producer = get_exports_producer()
|
199
199
|
msg = NatsTaskMessage(kbid=kbid, id=export_id)
|
200
200
|
seqid = await producer.send(msg)
|
201
201
|
logger.info(f"Export task produced. seqid={seqid} kbid={kbid} export_id={export_id}")
|
@@ -212,7 +212,7 @@ async def start_import_task(context: ApplicationContext, kbid: str, import_id: s
|
|
212
212
|
metadata.total = import_size or 0
|
213
213
|
await dm.set_metadata("import", metadata)
|
214
214
|
try:
|
215
|
-
producer =
|
215
|
+
producer = get_imports_producer()
|
216
216
|
msg = NatsTaskMessage(kbid=kbid, id=import_id)
|
217
217
|
seqid = await producer.send(msg)
|
218
218
|
logger.info(f"Import task produced. seqid={seqid} kbid={kbid} import_id={import_id}")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.3.1.
|
3
|
+
Version: 6.3.1.post3571
|
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.1.
|
24
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.1.
|
25
|
-
Requires-Dist: nucliadb-protos>=6.3.1.
|
26
|
-
Requires-Dist: nucliadb-models>=6.3.1.
|
27
|
-
Requires-Dist: nidx-protos>=6.3.1.
|
23
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.3.1.post3571
|
24
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.1.post3571
|
25
|
+
Requires-Dist: nucliadb-protos>=6.3.1.post3571
|
26
|
+
Requires-Dist: nucliadb-models>=6.3.1.post3571
|
27
|
+
Requires-Dist: nidx-protos>=6.3.1.post3571
|
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
|
@@ -108,7 +108,7 @@ nucliadb/export_import/exceptions.py,sha256=Dw8WqfG4r6MPJc5TPfbjMvCgXXWTcTOecGHR
|
|
108
108
|
nucliadb/export_import/exporter.py,sha256=k2QVx1EjqFlDYiggriWiEJzwtMXzHbldsqWdpGQM3_U,7074
|
109
109
|
nucliadb/export_import/importer.py,sha256=v5cq9Nn8c2zrY_K_00mydR52f8mdFxR7tLdtNLQ0qvk,4229
|
110
110
|
nucliadb/export_import/models.py,sha256=dbjScNkiMRv4X3Ktudy1JRliD25bfoDTy3JmEZgQSCc,2121
|
111
|
-
nucliadb/export_import/tasks.py,sha256=
|
111
|
+
nucliadb/export_import/tasks.py,sha256=DWbdqY97ffoyfipelGXz3Jqz1iam6JCjQSh367Fc3NA,2947
|
112
112
|
nucliadb/export_import/utils.py,sha256=iAQAjYuNx0dhM2b5-1A0NEs8tSRsznuT-izysUrTwS0,19986
|
113
113
|
nucliadb/ingest/__init__.py,sha256=fsw3C38VP50km3R-nHL775LNGPpJ4JxqXJ2Ib1f5SqE,1011
|
114
114
|
nucliadb/ingest/app.py,sha256=rX1KE5vsAzG9hlArBk8WE2SOlvdYylcb-jNkMQNPJdQ,7407
|
@@ -271,7 +271,7 @@ nucliadb/tasks/__init__.py,sha256=oFJ3A8HD7w11mBu-IixYE_KxA7juMGlYQb7YD_y6WPM,97
|
|
271
271
|
nucliadb/tasks/consumer.py,sha256=xc0Ql3N1Iq52dJ3t4YYGJFj1NCQAly0J5W_brfLa_F8,6894
|
272
272
|
nucliadb/tasks/logger.py,sha256=C7keOEO_mjLVp5VbqAZ2QXfqVB2Hot7NgBlUP_SDSMw,924
|
273
273
|
nucliadb/tasks/models.py,sha256=qrZKi5DNDQ07waMsp5L4_Fi7WRs57YiO-kmXlrBzEAA,1168
|
274
|
-
nucliadb/tasks/producer.py,sha256=
|
274
|
+
nucliadb/tasks/producer.py,sha256=UnpJAzhj_GElsCoO5G6T4m6MshsgOaqR2tVzJmEta64,2625
|
275
275
|
nucliadb/tasks/retries.py,sha256=Zv-3Hys-SKayG9VQ7_7EIflkegE5j-xPGrf-nwaxsfY,5075
|
276
276
|
nucliadb/tasks/utils.py,sha256=tV1AbWdFc3qfIULX44Veqj41FCD1B6XYjG6brULBeiw,1459
|
277
277
|
nucliadb/tests/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
@@ -322,7 +322,7 @@ nucliadb/writer/api/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20
|
|
322
322
|
nucliadb/writer/api/constants.py,sha256=qWEDjFUycrEZnSJyLnNK4PQNodU2oVmkO4NycaEZtio,1738
|
323
323
|
nucliadb/writer/api/utils.py,sha256=wIQHlU8RQiIGVLI72suvyVIKlCU44Unh0Ae0IiN6Qwo,1313
|
324
324
|
nucliadb/writer/api/v1/__init__.py,sha256=akI9A_jloNLb0dU4T5zjfdyvmSAiDeIdjAlzNx74FlU,1128
|
325
|
-
nucliadb/writer/api/v1/export_import.py,sha256=
|
325
|
+
nucliadb/writer/api/v1/export_import.py,sha256=elf-EQY5DD3mhw8kWb9tQpDcbrF9sY6VFYqxQOjuVP0,8201
|
326
326
|
nucliadb/writer/api/v1/field.py,sha256=OsWOYA0WQ6onE5Rkl20QIEdtrSi7Jgnu62fUt90Ziy8,17503
|
327
327
|
nucliadb/writer/api/v1/knowledgebox.py,sha256=MLeIuym4jPrJgfy1NTcN9CpUGwuBiqDHMcx0hY9DR7g,9530
|
328
328
|
nucliadb/writer/api/v1/learning_config.py,sha256=CKBjqcbewkfPwGUPLDWzZSpro6XkmCaVppe5Qtpu5Go,3117
|
@@ -347,8 +347,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
347
347
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
348
348
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
349
349
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
350
|
-
nucliadb-6.3.1.
|
351
|
-
nucliadb-6.3.1.
|
352
|
-
nucliadb-6.3.1.
|
353
|
-
nucliadb-6.3.1.
|
354
|
-
nucliadb-6.3.1.
|
350
|
+
nucliadb-6.3.1.post3571.dist-info/METADATA,sha256=s2P-Covs_cwHf5pNszgsGypGofi5r1zgIOV7ccxAh6M,4291
|
351
|
+
nucliadb-6.3.1.post3571.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
352
|
+
nucliadb-6.3.1.post3571.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
353
|
+
nucliadb-6.3.1.post3571.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
354
|
+
nucliadb-6.3.1.post3571.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|