nucliadb 6.3.1.post3531__py3-none-any.whl → 6.3.1.post3546__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/backups/const.py +8 -0
- nucliadb/backups/create.py +3 -3
- nucliadb/backups/delete.py +5 -2
- nucliadb/backups/models.py +3 -3
- nucliadb/backups/restore.py +4 -2
- nucliadb/backups/tasks.py +25 -24
- nucliadb/ingest/service/writer.py +4 -4
- {nucliadb-6.3.1.post3531.dist-info → nucliadb-6.3.1.post3546.dist-info}/METADATA +6 -6
- {nucliadb-6.3.1.post3531.dist-info → nucliadb-6.3.1.post3546.dist-info}/RECORD +12 -12
- {nucliadb-6.3.1.post3531.dist-info → nucliadb-6.3.1.post3546.dist-info}/WHEEL +0 -0
- {nucliadb-6.3.1.post3531.dist-info → nucliadb-6.3.1.post3546.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.3.1.post3531.dist-info → nucliadb-6.3.1.post3546.dist-info}/top_level.txt +0 -0
nucliadb/backups/const.py
CHANGED
@@ -39,3 +39,11 @@ class StorageKeys:
|
|
39
39
|
class BackupFinishedStream:
|
40
40
|
name = "backups"
|
41
41
|
subject = "backups.creation_finished"
|
42
|
+
|
43
|
+
|
44
|
+
class BackupsNatsStream:
|
45
|
+
name = "ndb-backups"
|
46
|
+
stream_subjects = ["ndb-backups.>"]
|
47
|
+
create_subject = "ndb-backups.create"
|
48
|
+
delete_subject = "ndb-backups.delete"
|
49
|
+
restore_subject = "ndb-backups.restore"
|
nucliadb/backups/create.py
CHANGED
@@ -45,8 +45,8 @@ from nucliadb_utils.storages.storage import StorageField
|
|
45
45
|
from nucliadb_utils.utilities import get_audit
|
46
46
|
|
47
47
|
|
48
|
-
async def
|
49
|
-
kbid = msg.
|
48
|
+
async def backup_kb_task(context: ApplicationContext, msg: CreateBackupRequest):
|
49
|
+
kbid = msg.kb_id
|
50
50
|
backup_id = msg.backup_id
|
51
51
|
|
52
52
|
retry_handler = TaskRetryHandler(
|
@@ -79,7 +79,7 @@ async def backup_resources(context: ApplicationContext, kbid: str, backup_id: st
|
|
79
79
|
metadata = await get_metadata(context, kbid, backup_id)
|
80
80
|
if metadata is None:
|
81
81
|
metadata = BackupMetadata(
|
82
|
-
|
82
|
+
kb_id=kbid,
|
83
83
|
requested_at=datetime.now(tz=timezone.utc),
|
84
84
|
)
|
85
85
|
async for rid in datamanagers.resources.iterate_resource_ids(kbid=kbid):
|
nucliadb/backups/delete.py
CHANGED
@@ -27,11 +27,14 @@ from nucliadb.backups.settings import settings
|
|
27
27
|
from nucliadb.common.context import ApplicationContext
|
28
28
|
|
29
29
|
|
30
|
-
async def
|
30
|
+
async def delete_backup_task(context: ApplicationContext, msg: DeleteBackupRequest):
|
31
31
|
"""
|
32
32
|
Deletes the backup files from the cloud storage.
|
33
33
|
"""
|
34
|
-
|
34
|
+
await delete_backup(context, msg.backup_id)
|
35
|
+
|
36
|
+
|
37
|
+
async def delete_backup(context: ApplicationContext, backup_id: str):
|
35
38
|
while True:
|
36
39
|
deleted = await delete_n(context, backup_id, n=1000)
|
37
40
|
if deleted == 0:
|
nucliadb/backups/models.py
CHANGED
@@ -23,12 +23,12 @@ from pydantic import BaseModel
|
|
23
23
|
|
24
24
|
|
25
25
|
class CreateBackupRequest(BaseModel):
|
26
|
-
|
26
|
+
kb_id: str
|
27
27
|
backup_id: str
|
28
28
|
|
29
29
|
|
30
30
|
class RestoreBackupRequest(BaseModel):
|
31
|
-
|
31
|
+
kb_id: str
|
32
32
|
backup_id: str
|
33
33
|
|
34
34
|
|
@@ -37,7 +37,7 @@ class DeleteBackupRequest(BaseModel):
|
|
37
37
|
|
38
38
|
|
39
39
|
class BackupMetadata(BaseModel):
|
40
|
-
|
40
|
+
kb_id: str
|
41
41
|
requested_at: datetime
|
42
42
|
total_resources: int = 0
|
43
43
|
missing_resources: list[str] = []
|
nucliadb/backups/restore.py
CHANGED
@@ -40,8 +40,8 @@ from nucliadb_protos.resources_pb2 import CloudFile
|
|
40
40
|
from nucliadb_protos.writer_pb2 import BrokerMessage
|
41
41
|
|
42
42
|
|
43
|
-
async def
|
44
|
-
kbid = msg.
|
43
|
+
async def restore_kb_task(context: ApplicationContext, msg: RestoreBackupRequest):
|
44
|
+
kbid = msg.kb_id
|
45
45
|
backup_id = msg.backup_id
|
46
46
|
|
47
47
|
retry_handler = TaskRetryHandler(
|
@@ -135,6 +135,8 @@ class ResourceBackupReader:
|
|
135
135
|
async def read(self, size: int) -> bytes:
|
136
136
|
while len(self.buffer) < size:
|
137
137
|
chunk = await self.download_stream.__anext__()
|
138
|
+
if not chunk:
|
139
|
+
continue
|
138
140
|
self.buffer += chunk
|
139
141
|
result = self.buffer[:size]
|
140
142
|
self.buffer = self.buffer[size:]
|
nucliadb/backups/tasks.py
CHANGED
@@ -19,10 +19,11 @@
|
|
19
19
|
#
|
20
20
|
from typing import Awaitable, Callable
|
21
21
|
|
22
|
-
from nucliadb.backups.
|
22
|
+
from nucliadb.backups.const import BackupsNatsStream
|
23
|
+
from nucliadb.backups.create import backup_kb_task
|
23
24
|
from nucliadb.backups.delete import delete_backup
|
24
25
|
from nucliadb.backups.models import CreateBackupRequest, DeleteBackupRequest, RestoreBackupRequest
|
25
|
-
from nucliadb.backups.restore import
|
26
|
+
from nucliadb.backups.restore import restore_kb_task
|
26
27
|
from nucliadb.common.context import ApplicationContext
|
27
28
|
from nucliadb.tasks import create_consumer, create_producer
|
28
29
|
from nucliadb.tasks.consumer import NatsTaskConsumer
|
@@ -32,10 +33,10 @@ from nucliadb.tasks.producer import NatsTaskProducer
|
|
32
33
|
def creator_consumer() -> NatsTaskConsumer[CreateBackupRequest]:
|
33
34
|
consumer: NatsTaskConsumer = create_consumer(
|
34
35
|
name="backup_creator",
|
35
|
-
stream=
|
36
|
-
stream_subjects=
|
37
|
-
consumer_subject=
|
38
|
-
callback=
|
36
|
+
stream=BackupsNatsStream.name,
|
37
|
+
stream_subjects=BackupsNatsStream.stream_subjects,
|
38
|
+
consumer_subject=BackupsNatsStream.create_subject,
|
39
|
+
callback=backup_kb_task,
|
39
40
|
msg_type=CreateBackupRequest,
|
40
41
|
max_concurrent_messages=10,
|
41
42
|
)
|
@@ -45,13 +46,13 @@ def creator_consumer() -> NatsTaskConsumer[CreateBackupRequest]:
|
|
45
46
|
async def create(kbid: str, backup_id: str) -> None:
|
46
47
|
producer: NatsTaskProducer[CreateBackupRequest] = create_producer(
|
47
48
|
name="backup_creator",
|
48
|
-
stream=
|
49
|
-
stream_subjects=
|
50
|
-
producer_subject=
|
49
|
+
stream=BackupsNatsStream.name,
|
50
|
+
stream_subjects=BackupsNatsStream.stream_subjects,
|
51
|
+
producer_subject=BackupsNatsStream.create_subject,
|
51
52
|
msg_type=CreateBackupRequest,
|
52
53
|
)
|
53
54
|
msg = CreateBackupRequest(
|
54
|
-
|
55
|
+
kb_id=kbid,
|
55
56
|
backup_id=backup_id,
|
56
57
|
)
|
57
58
|
await producer.send(msg)
|
@@ -60,10 +61,10 @@ async def create(kbid: str, backup_id: str) -> None:
|
|
60
61
|
def restorer_consumer() -> NatsTaskConsumer[RestoreBackupRequest]:
|
61
62
|
consumer: NatsTaskConsumer = create_consumer(
|
62
63
|
name="backup_restorer",
|
63
|
-
stream=
|
64
|
-
stream_subjects=
|
65
|
-
consumer_subject=
|
66
|
-
callback=
|
64
|
+
stream=BackupsNatsStream.name,
|
65
|
+
stream_subjects=BackupsNatsStream.stream_subjects,
|
66
|
+
consumer_subject=BackupsNatsStream.restore_subject,
|
67
|
+
callback=restore_kb_task,
|
67
68
|
msg_type=RestoreBackupRequest,
|
68
69
|
max_concurrent_messages=10,
|
69
70
|
)
|
@@ -73,13 +74,13 @@ def restorer_consumer() -> NatsTaskConsumer[RestoreBackupRequest]:
|
|
73
74
|
async def restore(kbid: str, backup_id: str) -> None:
|
74
75
|
producer: NatsTaskProducer[RestoreBackupRequest] = create_producer(
|
75
76
|
name="backup_restorer",
|
76
|
-
stream=
|
77
|
-
stream_subjects=
|
78
|
-
producer_subject=
|
77
|
+
stream=BackupsNatsStream.name,
|
78
|
+
stream_subjects=BackupsNatsStream.stream_subjects,
|
79
|
+
producer_subject=BackupsNatsStream.restore_subject,
|
79
80
|
msg_type=RestoreBackupRequest,
|
80
81
|
)
|
81
82
|
msg = RestoreBackupRequest(
|
82
|
-
|
83
|
+
kb_id=kbid,
|
83
84
|
backup_id=backup_id,
|
84
85
|
)
|
85
86
|
await producer.send(msg)
|
@@ -88,9 +89,9 @@ async def restore(kbid: str, backup_id: str) -> None:
|
|
88
89
|
def deleter_consumer() -> NatsTaskConsumer[DeleteBackupRequest]:
|
89
90
|
consumer: NatsTaskConsumer = create_consumer(
|
90
91
|
name="backup_deleter",
|
91
|
-
stream=
|
92
|
-
stream_subjects=
|
93
|
-
consumer_subject=
|
92
|
+
stream=BackupsNatsStream.name,
|
93
|
+
stream_subjects=BackupsNatsStream.stream_subjects,
|
94
|
+
consumer_subject=BackupsNatsStream.delete_subject,
|
94
95
|
callback=delete_backup,
|
95
96
|
msg_type=DeleteBackupRequest,
|
96
97
|
max_concurrent_messages=2,
|
@@ -101,9 +102,9 @@ def deleter_consumer() -> NatsTaskConsumer[DeleteBackupRequest]:
|
|
101
102
|
async def delete(backup_id: str) -> None:
|
102
103
|
producer: NatsTaskProducer[DeleteBackupRequest] = create_producer(
|
103
104
|
name="backup_deleter",
|
104
|
-
stream=
|
105
|
-
stream_subjects=
|
106
|
-
producer_subject=
|
105
|
+
stream=BackupsNatsStream.name,
|
106
|
+
stream_subjects=BackupsNatsStream.stream_subjects,
|
107
|
+
producer_subject=BackupsNatsStream.delete_subject,
|
107
108
|
msg_type=DeleteBackupRequest,
|
108
109
|
)
|
109
110
|
msg = DeleteBackupRequest(
|
@@ -473,11 +473,11 @@ class WriterServicer(writer_pb2_grpc.WriterServicer):
|
|
473
473
|
async def CreateBackup(
|
474
474
|
self, request: backups_pb2.CreateBackupRequest, context=None
|
475
475
|
) -> backups_pb2.CreateBackupResponse:
|
476
|
-
if not await exists_kb(request.
|
476
|
+
if not await exists_kb(request.kb_id):
|
477
477
|
return backups_pb2.CreateBackupResponse(
|
478
478
|
status=backups_pb2.CreateBackupResponse.Status.KB_NOT_FOUND
|
479
479
|
)
|
480
|
-
await backup_tasks.create(request.
|
480
|
+
await backup_tasks.create(request.kb_id, request.backup_id)
|
481
481
|
return backups_pb2.CreateBackupResponse(status=backups_pb2.CreateBackupResponse.Status.OK)
|
482
482
|
|
483
483
|
async def DeleteBackup(
|
@@ -493,7 +493,7 @@ class WriterServicer(writer_pb2_grpc.WriterServicer):
|
|
493
493
|
async def RestoreBackup(
|
494
494
|
self, request: backups_pb2.RestoreBackupRequest, context=None
|
495
495
|
) -> backups_pb2.RestoreBackupResponse:
|
496
|
-
if not await exists_kb(request.
|
496
|
+
if not await exists_kb(request.kb_id):
|
497
497
|
return backups_pb2.RestoreBackupResponse(
|
498
498
|
status=backups_pb2.RestoreBackupResponse.Status.NOT_FOUND
|
499
499
|
)
|
@@ -501,7 +501,7 @@ class WriterServicer(writer_pb2_grpc.WriterServicer):
|
|
501
501
|
return backups_pb2.RestoreBackupResponse(
|
502
502
|
status=backups_pb2.RestoreBackupResponse.Status.NOT_FOUND
|
503
503
|
)
|
504
|
-
await backup_tasks.restore(request.
|
504
|
+
await backup_tasks.restore(request.kb_id, request.backup_id)
|
505
505
|
return backups_pb2.RestoreBackupResponse(status=backups_pb2.RestoreBackupResponse.Status.OK)
|
506
506
|
|
507
507
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.3.1.
|
3
|
+
Version: 6.3.1.post3546
|
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.post3546
|
24
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.1.post3546
|
25
|
+
Requires-Dist: nucliadb-protos>=6.3.1.post3546
|
26
|
+
Requires-Dist: nucliadb-models>=6.3.1.post3546
|
27
|
+
Requires-Dist: nidx-protos>=6.3.1.post3546
|
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
|
@@ -40,13 +40,13 @@ nucliadb/metrics_exporter.py,sha256=6u0geEYFxgE5I2Fhl_sxsvGN-ZkaFZNGutSXwrzrsVs,
|
|
40
40
|
nucliadb/openapi.py,sha256=wDiw0dVEvTpJvbatkJ0JZLkKm9RItZT5PWRHjqRfqTA,2272
|
41
41
|
nucliadb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
42
|
nucliadb/backups/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
43
|
-
nucliadb/backups/const.py,sha256=
|
44
|
-
nucliadb/backups/create.py,sha256
|
45
|
-
nucliadb/backups/delete.py,sha256=
|
46
|
-
nucliadb/backups/models.py,sha256
|
47
|
-
nucliadb/backups/restore.py,sha256=
|
43
|
+
nucliadb/backups/const.py,sha256=llb5TaC53Ce6BMmlPKPUrVhVGl7uQrqv_Vle-P4GET4,1673
|
44
|
+
nucliadb/backups/create.py,sha256=AM_nC7TgHOX0EFGaTXClS28jBSK28fHrKNZi14z2wek,10442
|
45
|
+
nucliadb/backups/delete.py,sha256=1rnBhVUGYYZJXSZUrrgYMDZ5NyswEWkIA-G-crRCyHk,2404
|
46
|
+
nucliadb/backups/models.py,sha256=-hITU4Mv6AxePu12toBu_fjpEv6vVGcwNVxV22O9jQA,1273
|
47
|
+
nucliadb/backups/restore.py,sha256=xhslVvTf4H8VmDucZpjrEFpKj6csPIWBadCPMVJYKQ8,9703
|
48
48
|
nucliadb/backups/settings.py,sha256=SyzsInj1BRbBI0atg5IXWbMbOZ_eVg4eSQ3IcnUhCxQ,1357
|
49
|
-
nucliadb/backups/tasks.py,sha256=
|
49
|
+
nucliadb/backups/tasks.py,sha256=QgGDBBWsTpD-jLcrRP-C897Zo1qvc_ux1b4L-SlCnd8,4530
|
50
50
|
nucliadb/backups/utils.py,sha256=ayDaxfWP5cPnAkQH-tF4M6cnowsPQgU2ljYz_iL1CbE,1249
|
51
51
|
nucliadb/common/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
52
52
|
nucliadb/common/constants.py,sha256=QpigxJh_CtD85Evy0PtV5cVq6x0U_f9xfIcXz1ymkUg,869
|
@@ -154,7 +154,7 @@ nucliadb/ingest/orm/processor/processor.py,sha256=oaiZ9HUszhUbvNMCmDq5Xj_jtXiCDj
|
|
154
154
|
nucliadb/ingest/orm/processor/sequence_manager.py,sha256=uqEphtI1Ir_yk9jRl2gPf7BlzzXWovbARY5MNZSBI_8,1704
|
155
155
|
nucliadb/ingest/service/__init__.py,sha256=MME_G_ERxzJR6JW_hfE2qcfXpmpH1kdG-S0a-M0qRm8,2043
|
156
156
|
nucliadb/ingest/service/exceptions.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
157
|
-
nucliadb/ingest/service/writer.py,sha256=
|
157
|
+
nucliadb/ingest/service/writer.py,sha256=8oHJru1Yc8e05MXKmdQMbcNOzLHFFbWmHlJXIMjJcnY,22315
|
158
158
|
nucliadb/middleware/__init__.py,sha256=A8NBlBuEkunCFMKpR9gnfNELsVn0Plc55BIQMbWDM8Q,2202
|
159
159
|
nucliadb/migrator/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
160
160
|
nucliadb/migrator/command.py,sha256=dKbJ1tAmP6X4lMVRSSlz351euaqs2wBPpOczLjATUes,2089
|
@@ -349,8 +349,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
349
349
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
350
350
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
351
351
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
352
|
-
nucliadb-6.3.1.
|
353
|
-
nucliadb-6.3.1.
|
354
|
-
nucliadb-6.3.1.
|
355
|
-
nucliadb-6.3.1.
|
356
|
-
nucliadb-6.3.1.
|
352
|
+
nucliadb-6.3.1.post3546.dist-info/METADATA,sha256=DNgc6YIrIj8zGIewzwiHRTsrQL_kYcQVR8VddQdzKLw,4291
|
353
|
+
nucliadb-6.3.1.post3546.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
354
|
+
nucliadb-6.3.1.post3546.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
355
|
+
nucliadb-6.3.1.post3546.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
356
|
+
nucliadb-6.3.1.post3546.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|