nucliadb-utils 6.8.1.post4957__py3-none-any.whl → 6.8.1.post4965__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.
Potentially problematic release.
This version of nucliadb-utils might be problematic. Click here for more details.
- nucliadb_utils/storages/azure.py +11 -11
- nucliadb_utils/storages/exceptions.py +0 -6
- nucliadb_utils/storages/settings.py +3 -0
- nucliadb_utils/tests/azure.py +11 -3
- nucliadb_utils/utilities.py +2 -0
- {nucliadb_utils-6.8.1.post4957.dist-info → nucliadb_utils-6.8.1.post4965.dist-info}/METADATA +3 -3
- {nucliadb_utils-6.8.1.post4957.dist-info → nucliadb_utils-6.8.1.post4965.dist-info}/RECORD +9 -9
- {nucliadb_utils-6.8.1.post4957.dist-info → nucliadb_utils-6.8.1.post4965.dist-info}/WHEEL +0 -0
- {nucliadb_utils-6.8.1.post4957.dist-info → nucliadb_utils-6.8.1.post4965.dist-info}/top_level.txt +0 -0
nucliadb_utils/storages/azure.py
CHANGED
|
@@ -31,7 +31,6 @@ from azure.storage.blob.aio import BlobServiceClient
|
|
|
31
31
|
|
|
32
32
|
from nucliadb_protos.resources_pb2 import CloudFile
|
|
33
33
|
from nucliadb_telemetry import metrics
|
|
34
|
-
from nucliadb_utils.storages.exceptions import ObjectNotFoundError
|
|
35
34
|
from nucliadb_utils.storages.object_store import ObjectStore
|
|
36
35
|
from nucliadb_utils.storages.storage import Storage, StorageField
|
|
37
36
|
from nucliadb_utils.storages.utils import ObjectInfo, ObjectMetadata, Range
|
|
@@ -146,7 +145,7 @@ class AzureStorageField(StorageField):
|
|
|
146
145
|
return None
|
|
147
146
|
try:
|
|
148
147
|
return await self.storage.object_store.get_metadata(bucket, key)
|
|
149
|
-
except
|
|
148
|
+
except KeyError:
|
|
150
149
|
return None
|
|
151
150
|
|
|
152
151
|
async def upload(self, iterator: AsyncIterator, origin: CloudFile) -> CloudFile:
|
|
@@ -169,8 +168,8 @@ class AzureStorage(Storage):
|
|
|
169
168
|
def __init__(
|
|
170
169
|
self,
|
|
171
170
|
account_url: str,
|
|
172
|
-
deadletter_bucket: str = "deadletter",
|
|
173
|
-
indexing_bucket: str = "indexing",
|
|
171
|
+
deadletter_bucket: Optional[str] = "deadletter",
|
|
172
|
+
indexing_bucket: Optional[str] = "indexing",
|
|
174
173
|
connection_string: Optional[str] = None,
|
|
175
174
|
):
|
|
176
175
|
self.object_store = AzureObjectStore(account_url, connection_string=connection_string)
|
|
@@ -196,7 +195,7 @@ class AzureStorage(Storage):
|
|
|
196
195
|
async def delete_upload(self, uri: str, bucket_name: str):
|
|
197
196
|
try:
|
|
198
197
|
await self.object_store.delete(bucket_name, uri)
|
|
199
|
-
except
|
|
198
|
+
except KeyError:
|
|
200
199
|
pass
|
|
201
200
|
|
|
202
201
|
async def create_bucket(self, bucket_name: str, kbid: Optional[str] = None):
|
|
@@ -328,7 +327,7 @@ class AzureObjectStore(ObjectStore):
|
|
|
328
327
|
try:
|
|
329
328
|
await container_client.delete_blob(key, delete_snapshots="include")
|
|
330
329
|
except ResourceNotFoundError:
|
|
331
|
-
raise
|
|
330
|
+
raise KeyError(f"Not found: {bucket}/{key}")
|
|
332
331
|
|
|
333
332
|
@ops_observer.wrap({"type": "upload"})
|
|
334
333
|
async def upload(
|
|
@@ -350,6 +349,7 @@ class AzureObjectStore(ObjectStore):
|
|
|
350
349
|
name=key,
|
|
351
350
|
data=data,
|
|
352
351
|
length=length,
|
|
352
|
+
overwrite=True,
|
|
353
353
|
blob_type=BlobType.BLOCKBLOB,
|
|
354
354
|
metadata=custom_metadata,
|
|
355
355
|
content_settings=ContentSettings(
|
|
@@ -361,7 +361,7 @@ class AzureObjectStore(ObjectStore):
|
|
|
361
361
|
@ops_observer.wrap({"type": "insert"})
|
|
362
362
|
async def insert(self, bucket: str, key: str, data: bytes) -> None:
|
|
363
363
|
container_client = self.service_client.get_container_client(bucket)
|
|
364
|
-
await container_client.upload_blob(name=key, data=data, length=len(data))
|
|
364
|
+
await container_client.upload_blob(name=key, data=data, length=len(data), overwrite=True)
|
|
365
365
|
|
|
366
366
|
@ops_observer.wrap({"type": "download"})
|
|
367
367
|
async def download(self, bucket: str, key: str) -> bytes:
|
|
@@ -370,7 +370,7 @@ class AzureObjectStore(ObjectStore):
|
|
|
370
370
|
try:
|
|
371
371
|
downloader = await blob_client.download_blob()
|
|
372
372
|
except ResourceNotFoundError:
|
|
373
|
-
raise
|
|
373
|
+
raise KeyError(f"Not found: {bucket}/{key}")
|
|
374
374
|
return await downloader.readall()
|
|
375
375
|
|
|
376
376
|
async def download_stream(
|
|
@@ -383,14 +383,14 @@ class AzureObjectStore(ObjectStore):
|
|
|
383
383
|
length = None
|
|
384
384
|
if range.any():
|
|
385
385
|
offset = range.start or 0
|
|
386
|
-
length = range.end - offset + 1 if range.end else None
|
|
386
|
+
length = range.end - offset + 1 if range.end is not None else None
|
|
387
387
|
try:
|
|
388
388
|
downloader = await blob_client.download_blob(
|
|
389
389
|
offset=offset, # type: ignore
|
|
390
390
|
length=length, # type: ignore
|
|
391
391
|
)
|
|
392
392
|
except ResourceNotFoundError:
|
|
393
|
-
raise
|
|
393
|
+
raise KeyError(f"Not found: {bucket}/{key}")
|
|
394
394
|
async for chunk in downloader.chunks():
|
|
395
395
|
yield chunk
|
|
396
396
|
|
|
@@ -411,7 +411,7 @@ class AzureObjectStore(ObjectStore):
|
|
|
411
411
|
properties: BlobProperties = await blob_client.get_blob_properties()
|
|
412
412
|
return parse_object_metadata(properties, key)
|
|
413
413
|
except ResourceNotFoundError:
|
|
414
|
-
raise
|
|
414
|
+
raise KeyError(f"Not found: {bucket}/{key}")
|
|
415
415
|
|
|
416
416
|
@ops_observer.wrap({"type": "multipart_start"})
|
|
417
417
|
async def upload_multipart_start(self, bucket: str, key: str, metadata: ObjectMetadata) -> None:
|
|
@@ -33,6 +33,9 @@ class Settings(BaseSettings):
|
|
|
33
33
|
s3_deadletter_bucket: Optional[str] = None
|
|
34
34
|
s3_indexing_bucket: Optional[str] = None
|
|
35
35
|
|
|
36
|
+
azure_deadletter_bucket: Optional[str] = None
|
|
37
|
+
azure_indexing_bucket: Optional[str] = None
|
|
38
|
+
|
|
36
39
|
local_testing_files: str = os.path.dirname(__file__)
|
|
37
40
|
|
|
38
41
|
|
nucliadb_utils/tests/azure.py
CHANGED
|
@@ -28,6 +28,7 @@ from pytest_docker_fixtures.containers._base import BaseImage # type: ignore #
|
|
|
28
28
|
|
|
29
29
|
from nucliadb_utils.settings import FileBackendConfig, storage_settings
|
|
30
30
|
from nucliadb_utils.storages.azure import AzureStorage
|
|
31
|
+
from nucliadb_utils.storages.settings import settings as extended_storage_settings
|
|
31
32
|
|
|
32
33
|
images.settings["azurite"] = {
|
|
33
34
|
"image": "mcr.microsoft.com/azure-storage/azurite",
|
|
@@ -105,7 +106,7 @@ def azurite() -> Generator[AzuriteFixture, None, None]:
|
|
|
105
106
|
port=port,
|
|
106
107
|
container=container.container_obj,
|
|
107
108
|
connection_string=get_connection_string(host, port),
|
|
108
|
-
account_url=f"
|
|
109
|
+
account_url=f"https://devstoreaccount1.blob.core.windows.net",
|
|
109
110
|
)
|
|
110
111
|
finally:
|
|
111
112
|
container.stop()
|
|
@@ -118,12 +119,18 @@ def azure_storage_settings(azurite: AzuriteFixture) -> Iterator[dict[str, Any]]:
|
|
|
118
119
|
"azure_account_url": azurite.account_url,
|
|
119
120
|
"azure_connection_string": azurite.connection_string,
|
|
120
121
|
}
|
|
122
|
+
extended_settings = {
|
|
123
|
+
"azure_deadletter_bucket": "deadletter",
|
|
124
|
+
"azure_indexing_bucket": "indexing",
|
|
125
|
+
}
|
|
121
126
|
with ExitStack() as stack:
|
|
122
127
|
for key, value in settings.items():
|
|
123
128
|
context = patch.object(storage_settings, key, value)
|
|
124
129
|
stack.enter_context(context)
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
for key, value in extended_settings.items():
|
|
131
|
+
context = patch.object(extended_storage_settings, key, value)
|
|
132
|
+
stack.enter_context(context)
|
|
133
|
+
yield settings | extended_settings
|
|
127
134
|
|
|
128
135
|
|
|
129
136
|
@pytest.fixture(scope="function")
|
|
@@ -135,5 +142,6 @@ async def azure_storage(azurite, azure_storage_settings: dict[str, Any]):
|
|
|
135
142
|
connection_string=storage_settings.azure_connection_string,
|
|
136
143
|
)
|
|
137
144
|
await storage.initialize()
|
|
145
|
+
await storage.create_bucket("nidx")
|
|
138
146
|
yield storage
|
|
139
147
|
await storage.finalize()
|
nucliadb_utils/utilities.py
CHANGED
|
@@ -125,6 +125,8 @@ async def _create_storage(gcs_scopes: Optional[List[str]] = None) -> Storage:
|
|
|
125
125
|
azureutil = AzureStorage(
|
|
126
126
|
account_url=storage_settings.azure_account_url,
|
|
127
127
|
connection_string=storage_settings.azure_connection_string,
|
|
128
|
+
deadletter_bucket=extended_storage_settings.azure_deadletter_bucket,
|
|
129
|
+
indexing_bucket=extended_storage_settings.azure_indexing_bucket,
|
|
128
130
|
)
|
|
129
131
|
|
|
130
132
|
logger.info("Configuring Azure Storage")
|
{nucliadb_utils-6.8.1.post4957.dist-info → nucliadb_utils-6.8.1.post4965.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nucliadb_utils
|
|
3
|
-
Version: 6.8.1.
|
|
3
|
+
Version: 6.8.1.post4965
|
|
4
4
|
Summary: NucliaDB util library
|
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -27,8 +27,8 @@ Requires-Dist: nats-py[nkeys]>=2.6.0
|
|
|
27
27
|
Requires-Dist: PyNaCl
|
|
28
28
|
Requires-Dist: pyjwt>=2.4.0
|
|
29
29
|
Requires-Dist: mrflagly>=0.2.9
|
|
30
|
-
Requires-Dist: nucliadb-protos>=6.8.1.
|
|
31
|
-
Requires-Dist: nucliadb-telemetry>=6.8.1.
|
|
30
|
+
Requires-Dist: nucliadb-protos>=6.8.1.post4965
|
|
31
|
+
Requires-Dist: nucliadb-telemetry>=6.8.1.post4965
|
|
32
32
|
Provides-Extra: cache
|
|
33
33
|
Requires-Dist: redis>=4.3.4; extra == "cache"
|
|
34
34
|
Requires-Dist: orjson>=3.6.7; extra == "cache"
|
|
@@ -15,7 +15,7 @@ nucliadb_utils/settings.py,sha256=lZUCliwNKYfk_Tt0KiYeHsT4jRBG0gLAompuHWu9fBI,82
|
|
|
15
15
|
nucliadb_utils/signals.py,sha256=lo_Mk12NIX5Au--3H3WObvDOXq_OMurql2qiC2TnAao,2676
|
|
16
16
|
nucliadb_utils/store.py,sha256=kQ35HemE0v4_Qg6xVqNIJi8vSFAYQtwI3rDtMsNy62Y,890
|
|
17
17
|
nucliadb_utils/transaction.py,sha256=l3ZvrITYMnAs_fv1OOC-1nDZxWPG5qmbBhzvuC3DUzQ,8039
|
|
18
|
-
nucliadb_utils/utilities.py,sha256=
|
|
18
|
+
nucliadb_utils/utilities.py,sha256=C_qSKlCeCpi8wIWttjDp0TiQjSUUhd_yS08X5NuPbAs,15940
|
|
19
19
|
nucliadb_utils/aiopynecone/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
|
20
20
|
nucliadb_utils/aiopynecone/client.py,sha256=MPyHnDXwhukJr7U3CJh7BpsekfSuOkyM4g5b9LLtzc8,22941
|
|
21
21
|
nucliadb_utils/aiopynecone/exceptions.py,sha256=fUErx3ceKQK1MUbOnYcZhIzpNe8UVAptZE9JIRDLXDE,4000
|
|
@@ -39,25 +39,25 @@ nucliadb_utils/nuclia_usage/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn
|
|
|
39
39
|
nucliadb_utils/nuclia_usage/utils/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
|
40
40
|
nucliadb_utils/nuclia_usage/utils/kb_usage_report.py,sha256=6lLuxCCPQVn3dOuZNL5ThPjl2yws-1TJ_7duhQSWkPU,3934
|
|
41
41
|
nucliadb_utils/storages/__init__.py,sha256=5Qc8AUWiJv9_JbGCBpAn88AIJhwDlm0OPQpg2ZdRL4U,872
|
|
42
|
-
nucliadb_utils/storages/azure.py,sha256=
|
|
43
|
-
nucliadb_utils/storages/exceptions.py,sha256=
|
|
42
|
+
nucliadb_utils/storages/azure.py,sha256=SdZnz4GEFyBftsdXk36iiUvj-EZiXQ6PeDbZadSVkTk,17484
|
|
43
|
+
nucliadb_utils/storages/exceptions.py,sha256=6YhFLf8k0ABy5AVfxIJUo7w6AK0SJjktiyQTwF3gCdg,2344
|
|
44
44
|
nucliadb_utils/storages/gcs.py,sha256=VyT72My34N4pEMmrQc5wdAMNLiuqpYl8OW3d50cJfSA,28222
|
|
45
45
|
nucliadb_utils/storages/local.py,sha256=2aCHpZymORG_dUc1FDq0VFcgQulu0w2pZiUaj9dphFs,11686
|
|
46
46
|
nucliadb_utils/storages/nuclia.py,sha256=vEv94xAT7QM2g80S25QyrOw2pzvP2BAX-ADgZLtuCVc,2097
|
|
47
47
|
nucliadb_utils/storages/object_store.py,sha256=2PueRP5Q3XOuWgKhj6B9Kp2fyBql5np0T400YRUbqn4,4535
|
|
48
48
|
nucliadb_utils/storages/s3.py,sha256=eFFVRgNTIxTz1Hpmd6ofRz9KQhPJAmiyetW4EmWN8EM,21835
|
|
49
|
-
nucliadb_utils/storages/settings.py,sha256=
|
|
49
|
+
nucliadb_utils/storages/settings.py,sha256=mepN3wbLGL0Pv5yI6D-sNjSAFinEWT7aRi6N3eClNDg,1384
|
|
50
50
|
nucliadb_utils/storages/storage.py,sha256=2EIgnaCN5XzKpienounOjQ2AX3ANtQA2Xgl6hnMpHr4,21951
|
|
51
51
|
nucliadb_utils/storages/utils.py,sha256=F4Iboa_0_bhDQr-JOKD9sGPld_-hKwJW5ptyZdn9Oag,1505
|
|
52
52
|
nucliadb_utils/tests/__init__.py,sha256=Oo9CAE7B0eW5VHn8sHd6o30SQzOWUhktLPRXdlDOleA,1456
|
|
53
53
|
nucliadb_utils/tests/asyncbenchmark.py,sha256=vrX_x9ifCXi18PfNShc23w9x_VUiB_Ph-2nuolh9z3Q,10707
|
|
54
|
-
nucliadb_utils/tests/azure.py,sha256=
|
|
54
|
+
nucliadb_utils/tests/azure.py,sha256=rBRnS0XWqoh7Qa31MmHIl-XM20FxuQGJDxLazqa64-8,4939
|
|
55
55
|
nucliadb_utils/tests/fixtures.py,sha256=4lzz-khYvbGzdbT18IG6KKg40f7CVex2q3ho88I-jL8,3799
|
|
56
56
|
nucliadb_utils/tests/gcs.py,sha256=JNqp5ymeNNU9Ci8rNYTh7-VqP4fjybElhyB3ap7EV1c,4721
|
|
57
57
|
nucliadb_utils/tests/local.py,sha256=z9E11_ol1mu7N8Y6PkjKl-WMPPMl7JqQbDj3uhVa1A0,1933
|
|
58
58
|
nucliadb_utils/tests/nats.py,sha256=RWHjwqq5esuO7OFbP24yYX1cXnpPLcWJwDUdmwCpH28,1897
|
|
59
59
|
nucliadb_utils/tests/s3.py,sha256=kz9ULxrAYLVslZ59I8dtweZ9DJz5R8Ioy2XYrveZzHw,3829
|
|
60
|
-
nucliadb_utils-6.8.1.
|
|
61
|
-
nucliadb_utils-6.8.1.
|
|
62
|
-
nucliadb_utils-6.8.1.
|
|
63
|
-
nucliadb_utils-6.8.1.
|
|
60
|
+
nucliadb_utils-6.8.1.post4965.dist-info/METADATA,sha256=bBd184pMcsnkJvAw8xxNPgr9cqJcsxjq17BNr9I3m1U,2180
|
|
61
|
+
nucliadb_utils-6.8.1.post4965.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
62
|
+
nucliadb_utils-6.8.1.post4965.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
|
63
|
+
nucliadb_utils-6.8.1.post4965.dist-info/RECORD,,
|
|
File without changes
|
{nucliadb_utils-6.8.1.post4957.dist-info → nucliadb_utils-6.8.1.post4965.dist-info}/top_level.txt
RENAMED
|
File without changes
|