nucliadb 6.3.1.post3590__py3-none-any.whl → 6.3.1.post3593__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/create.py +3 -3
- nucliadb/backups/restore.py +13 -13
- {nucliadb-6.3.1.post3590.dist-info → nucliadb-6.3.1.post3593.dist-info}/METADATA +6 -6
- {nucliadb-6.3.1.post3590.dist-info → nucliadb-6.3.1.post3593.dist-info}/RECORD +7 -7
- {nucliadb-6.3.1.post3590.dist-info → nucliadb-6.3.1.post3593.dist-info}/WHEEL +0 -0
- {nucliadb-6.3.1.post3590.dist-info → nucliadb-6.3.1.post3593.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.3.1.post3590.dist-info → nucliadb-6.3.1.post3593.dist-info}/top_level.txt +0 -0
nucliadb/backups/create.py
CHANGED
@@ -170,7 +170,7 @@ async def backup_resource_with_binaries(
|
|
170
170
|
"""
|
171
171
|
nonlocal total_size
|
172
172
|
|
173
|
-
for cloud_file in get_cloud_files(bm):
|
173
|
+
for index, cloud_file in enumerate(get_cloud_files(bm)):
|
174
174
|
if not await exists_cf(context, cloud_file):
|
175
175
|
logger.warning(
|
176
176
|
"Cloud file not found in storage, skipping",
|
@@ -184,13 +184,13 @@ async def backup_resource_with_binaries(
|
|
184
184
|
yield serialized_cf
|
185
185
|
|
186
186
|
async for chunk in to_tar(
|
187
|
-
name=f"cloud-files/{
|
187
|
+
name=f"cloud-files/{index}", size=len(serialized_cf), chunks=cf_iterator()
|
188
188
|
):
|
189
189
|
yield chunk
|
190
190
|
total_size += len(chunk)
|
191
191
|
|
192
192
|
async for chunk in to_tar(
|
193
|
-
name=f"binaries/{
|
193
|
+
name=f"binaries/{index}",
|
194
194
|
size=cloud_file.size,
|
195
195
|
chunks=download_binary(context, cloud_file),
|
196
196
|
):
|
nucliadb/backups/restore.py
CHANGED
@@ -69,11 +69,11 @@ async def restore_kb(context: ApplicationContext, kbid: str, backup_id: str):
|
|
69
69
|
await restore_resources(context, kbid, backup_id)
|
70
70
|
await restore_labels(context, kbid, backup_id)
|
71
71
|
await restore_entities(context, kbid, backup_id)
|
72
|
-
await
|
72
|
+
await delete_last_restored(context, kbid, backup_id)
|
73
73
|
|
74
74
|
|
75
75
|
async def restore_resources(context: ApplicationContext, kbid: str, backup_id: str):
|
76
|
-
last_restored = await
|
76
|
+
last_restored = await get_last_restored(context, kbid, backup_id)
|
77
77
|
tasks = []
|
78
78
|
async for object_info in context.blob_storage.iterate_objects(
|
79
79
|
bucket=settings.backups_bucket,
|
@@ -86,16 +86,14 @@ async def restore_resources(context: ApplicationContext, kbid: str, backup_id: s
|
|
86
86
|
if len(tasks) > settings.restore_resources_concurrency:
|
87
87
|
await asyncio.gather(*tasks)
|
88
88
|
tasks = []
|
89
|
-
await
|
89
|
+
await set_last_restored(context, kbid, backup_id, key)
|
90
90
|
if len(tasks) > 0:
|
91
91
|
await asyncio.gather(*tasks)
|
92
92
|
tasks = []
|
93
|
-
await
|
93
|
+
await set_last_restored(context, kbid, backup_id, key)
|
94
94
|
|
95
95
|
|
96
|
-
async def
|
97
|
-
context: ApplicationContext, kbid: str, backup_id: str
|
98
|
-
) -> Optional[str]:
|
96
|
+
async def get_last_restored(context: ApplicationContext, kbid: str, backup_id: str) -> Optional[str]:
|
99
97
|
key = MaindbKeys.LAST_RESTORED.format(kbid=kbid, backup_id=backup_id)
|
100
98
|
async with context.kv_driver.transaction(read_only=True) as txn:
|
101
99
|
raw = await txn.get(key)
|
@@ -104,16 +102,14 @@ async def get_last_restored_resource_key(
|
|
104
102
|
return raw.decode()
|
105
103
|
|
106
104
|
|
107
|
-
async def
|
108
|
-
context: ApplicationContext, kbid: str, backup_id: str, resource_id: str
|
109
|
-
):
|
105
|
+
async def set_last_restored(context: ApplicationContext, kbid: str, backup_id: str, resource_id: str):
|
110
106
|
key = MaindbKeys.LAST_RESTORED.format(kbid=kbid, backup_id=backup_id)
|
111
107
|
async with context.kv_driver.transaction() as txn:
|
112
108
|
await txn.set(key, resource_id.encode())
|
113
109
|
await txn.commit()
|
114
110
|
|
115
111
|
|
116
|
-
async def
|
112
|
+
async def delete_last_restored(context: ApplicationContext, kbid: str, backup_id: str):
|
117
113
|
key = MaindbKeys.LAST_RESTORED.format(kbid=kbid, backup_id=backup_id)
|
118
114
|
async with context.kv_driver.transaction() as txn:
|
119
115
|
await txn.delete(key)
|
@@ -134,6 +130,7 @@ class ResourceBackupReader:
|
|
134
130
|
def __init__(self, download_stream: AsyncIterator[bytes]):
|
135
131
|
self.download_stream = download_stream
|
136
132
|
self.buffer = b""
|
133
|
+
self.cloud_files: dict[int, CloudFile] = {}
|
137
134
|
|
138
135
|
async def read(self, size: int) -> bytes:
|
139
136
|
while len(self.buffer) < size:
|
@@ -194,15 +191,18 @@ class ResourceBackupReader:
|
|
194
191
|
bm.ParseFromString(raw_bm)
|
195
192
|
return bm
|
196
193
|
elif tarinfo.name.startswith("cloud-files"):
|
194
|
+
cf_index = int(tarinfo.name.split("cloud-files/")[-1])
|
197
195
|
raw_cf = await self.read_data(tarinfo)
|
198
196
|
cf = CloudFile()
|
199
197
|
cf.ParseFromString(raw_cf)
|
198
|
+
self.cloud_files[cf_index] = cf
|
200
199
|
return cf
|
201
200
|
elif tarinfo.name.startswith("binaries"):
|
202
|
-
|
201
|
+
bin_index = int(tarinfo.name.split("binaries/")[-1])
|
203
202
|
size = tarinfo.size
|
204
203
|
download_stream = functools.partial(self.iter_data, size)
|
205
|
-
|
204
|
+
cf = self.cloud_files[bin_index]
|
205
|
+
return CloudFileBinary(cf.uri, download_stream)
|
206
206
|
else: # pragma: no cover
|
207
207
|
raise ValueError(f"Unknown tar entry: {tarinfo.name}")
|
208
208
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.3.1.
|
3
|
+
Version: 6.3.1.post3593
|
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.post3593
|
24
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.1.post3593
|
25
|
+
Requires-Dist: nucliadb-protos>=6.3.1.post3593
|
26
|
+
Requires-Dist: nucliadb-models>=6.3.1.post3593
|
27
|
+
Requires-Dist: nidx-protos>=6.3.1.post3593
|
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
|
@@ -41,10 +41,10 @@ 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
43
|
nucliadb/backups/const.py,sha256=9vPAhLxQO_gNAjSdPxWuv3V66s9WcdpjOQ89CZlfmuk,1894
|
44
|
-
nucliadb/backups/create.py,sha256=
|
44
|
+
nucliadb/backups/create.py,sha256=x5Ezd1p8qqlcn-srbE_iFxTwEEjycKWhTezUIkXL-oo,11230
|
45
45
|
nucliadb/backups/delete.py,sha256=1rnBhVUGYYZJXSZUrrgYMDZ5NyswEWkIA-G-crRCyHk,2404
|
46
46
|
nucliadb/backups/models.py,sha256=-hITU4Mv6AxePu12toBu_fjpEv6vVGcwNVxV22O9jQA,1273
|
47
|
-
nucliadb/backups/restore.py,sha256=
|
47
|
+
nucliadb/backups/restore.py,sha256=BIsJPXDKIsobO0C2mX6g9WUysKAKpJ9RX-DrxqqZSnY,10123
|
48
48
|
nucliadb/backups/settings.py,sha256=SyzsInj1BRbBI0atg5IXWbMbOZ_eVg4eSQ3IcnUhCxQ,1357
|
49
49
|
nucliadb/backups/tasks.py,sha256=4_kOVJ2yCwMvDEpzJgTuTt75TNlpq5woyw9sTAcaSkw,4194
|
50
50
|
nucliadb/backups/utils.py,sha256=_Vogjqcru5oqNZM-bZ0q7Ju79Bv1PD-LVFEa7Z-Q13I,1261
|
@@ -351,8 +351,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
351
351
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
352
352
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
353
353
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
354
|
-
nucliadb-6.3.1.
|
355
|
-
nucliadb-6.3.1.
|
356
|
-
nucliadb-6.3.1.
|
357
|
-
nucliadb-6.3.1.
|
358
|
-
nucliadb-6.3.1.
|
354
|
+
nucliadb-6.3.1.post3593.dist-info/METADATA,sha256=jU-nHJGJbWgLgYiZlT1k8GatmOMazY89YO66_nL_N_k,4291
|
355
|
+
nucliadb-6.3.1.post3593.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
356
|
+
nucliadb-6.3.1.post3593.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
357
|
+
nucliadb-6.3.1.post3593.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
358
|
+
nucliadb-6.3.1.post3593.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|