nucliadb-utils 6.8.1.post4988__py3-none-any.whl → 6.8.1.post5003__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/settings.py +6 -0
- nucliadb_utils/storages/azure.py +20 -10
- nucliadb_utils/tests/azure.py +1 -0
- nucliadb_utils/utilities.py +1 -0
- {nucliadb_utils-6.8.1.post4988.dist-info → nucliadb_utils-6.8.1.post5003.dist-info}/METADATA +3 -3
- {nucliadb_utils-6.8.1.post4988.dist-info → nucliadb_utils-6.8.1.post5003.dist-info}/RECORD +8 -8
- {nucliadb_utils-6.8.1.post4988.dist-info → nucliadb_utils-6.8.1.post5003.dist-info}/WHEEL +0 -0
- {nucliadb_utils-6.8.1.post4988.dist-info → nucliadb_utils-6.8.1.post5003.dist-info}/top_level.txt +0 -0
nucliadb_utils/settings.py
CHANGED
|
@@ -125,6 +125,12 @@ class StorageSettings(BaseSettings):
|
|
|
125
125
|
examples=["https://<storageaccountname>.blob.core.windows.net"],
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
+
azure_kb_account_url: Optional[str] = Field(
|
|
129
|
+
default=None,
|
|
130
|
+
description="Azure Account URL for KB containers. If unspecified, uses `azure_account_url`", # noqa
|
|
131
|
+
examples=["https://<storageaccountname>.blob.core.windows.net"],
|
|
132
|
+
)
|
|
133
|
+
|
|
128
134
|
# For testing purposes: Azurite docker image requires a connection string as it
|
|
129
135
|
# doesn't support Azure's default credential authentication method
|
|
130
136
|
azure_connection_string: Optional[str] = None
|
nucliadb_utils/storages/azure.py
CHANGED
|
@@ -162,22 +162,32 @@ class AzureStorageField(StorageField):
|
|
|
162
162
|
|
|
163
163
|
class AzureStorage(Storage):
|
|
164
164
|
field_klass = AzureStorageField
|
|
165
|
-
object_store:
|
|
165
|
+
object_store: AzureObjectStore
|
|
166
|
+
kb_object_store: AzureObjectStore
|
|
166
167
|
source = CloudFile.AZURE
|
|
167
168
|
|
|
168
169
|
def __init__(
|
|
169
170
|
self,
|
|
170
171
|
account_url: str,
|
|
172
|
+
kb_account_url: str,
|
|
171
173
|
deadletter_bucket: Optional[str] = "deadletter",
|
|
172
174
|
indexing_bucket: Optional[str] = "indexing",
|
|
173
175
|
connection_string: Optional[str] = None,
|
|
174
176
|
):
|
|
175
177
|
self.object_store = AzureObjectStore(account_url, connection_string=connection_string)
|
|
178
|
+
self.kb_object_store = AzureObjectStore(kb_account_url, connection_string=connection_string)
|
|
176
179
|
self.deadletter_bucket = deadletter_bucket
|
|
177
180
|
self.indexing_bucket = indexing_bucket
|
|
178
181
|
|
|
182
|
+
def object_store_for_bucket(self, bucket_name: str) -> AzureObjectStore:
|
|
183
|
+
if bucket_name in [self.indexing_bucket, self.deadletter_bucket]:
|
|
184
|
+
return self.object_store
|
|
185
|
+
else:
|
|
186
|
+
return self.kb_object_store
|
|
187
|
+
|
|
179
188
|
async def initialize(self, service_name: Optional[str] = None):
|
|
180
189
|
await self.object_store.initialize()
|
|
190
|
+
await self.kb_object_store.initialize()
|
|
181
191
|
for bucket in [
|
|
182
192
|
self.deadletter_bucket,
|
|
183
193
|
self.indexing_bucket,
|
|
@@ -194,39 +204,39 @@ class AzureStorage(Storage):
|
|
|
194
204
|
|
|
195
205
|
async def delete_upload(self, uri: str, bucket_name: str):
|
|
196
206
|
try:
|
|
197
|
-
await self.
|
|
207
|
+
await self.object_store_for_bucket(bucket_name).delete(bucket_name, uri)
|
|
198
208
|
except KeyError:
|
|
199
209
|
pass
|
|
200
210
|
|
|
201
211
|
async def create_bucket(self, bucket_name: str, kbid: Optional[str] = None):
|
|
202
|
-
if await self.
|
|
212
|
+
if await self.object_store_for_bucket(bucket_name).bucket_exists(bucket_name):
|
|
203
213
|
return
|
|
204
|
-
await self.
|
|
214
|
+
await self.object_store_for_bucket(bucket_name).bucket_create(bucket_name)
|
|
205
215
|
|
|
206
216
|
def get_bucket_name(self, kbid: str):
|
|
207
217
|
return f"nucliadb-{kbid}"
|
|
208
218
|
|
|
209
219
|
async def create_kb(self, kbid: str) -> bool:
|
|
210
220
|
bucket_name = self.get_bucket_name(kbid)
|
|
211
|
-
return await self.
|
|
221
|
+
return await self.kb_object_store.bucket_create(bucket_name)
|
|
212
222
|
|
|
213
223
|
async def schedule_delete_kb(self, kbid: str) -> bool:
|
|
214
224
|
bucket_name = self.get_bucket_name(kbid)
|
|
215
|
-
deleted, _ = await self.
|
|
225
|
+
deleted, _ = await self.kb_object_store.bucket_delete(bucket_name)
|
|
216
226
|
return deleted
|
|
217
227
|
|
|
218
228
|
async def delete_kb(self, kbid: str) -> tuple[bool, bool]:
|
|
219
229
|
bucket_name = self.get_bucket_name(kbid)
|
|
220
|
-
return await self.
|
|
230
|
+
return await self.kb_object_store.bucket_delete(bucket_name)
|
|
221
231
|
|
|
222
232
|
async def iterate_objects(
|
|
223
233
|
self, bucket: str, prefix: str, start: Optional[str] = None
|
|
224
234
|
) -> AsyncGenerator[ObjectInfo, None]:
|
|
225
|
-
async for obj in self.
|
|
235
|
+
async for obj in self.object_store_for_bucket(bucket).iterate(bucket, prefix, start):
|
|
226
236
|
yield obj
|
|
227
237
|
|
|
228
|
-
async def insert_object(self,
|
|
229
|
-
await self.
|
|
238
|
+
async def insert_object(self, bucket: str, key: str, data: bytes) -> None:
|
|
239
|
+
await self.object_store_for_bucket(bucket).insert(bucket, key, data)
|
|
230
240
|
|
|
231
241
|
|
|
232
242
|
class AzureObjectStore(ObjectStore):
|
nucliadb_utils/tests/azure.py
CHANGED
|
@@ -139,6 +139,7 @@ async def azure_storage(azurite, azure_storage_settings: dict[str, Any]):
|
|
|
139
139
|
|
|
140
140
|
storage = AzureStorage(
|
|
141
141
|
account_url=storage_settings.azure_account_url,
|
|
142
|
+
kb_account_url=storage_settings.azure_kb_account_url or storage_settings.azure_account_url,
|
|
142
143
|
connection_string=storage_settings.azure_connection_string,
|
|
143
144
|
)
|
|
144
145
|
await storage.initialize()
|
nucliadb_utils/utilities.py
CHANGED
|
@@ -124,6 +124,7 @@ async def _create_storage(gcs_scopes: Optional[List[str]] = None) -> Storage:
|
|
|
124
124
|
|
|
125
125
|
azureutil = AzureStorage(
|
|
126
126
|
account_url=storage_settings.azure_account_url,
|
|
127
|
+
kb_account_url=storage_settings.azure_kb_account_url or storage_settings.azure_account_url,
|
|
127
128
|
connection_string=storage_settings.azure_connection_string,
|
|
128
129
|
deadletter_bucket=extended_storage_settings.azure_deadletter_bucket,
|
|
129
130
|
indexing_bucket=extended_storage_settings.azure_indexing_bucket,
|
{nucliadb_utils-6.8.1.post4988.dist-info → nucliadb_utils-6.8.1.post5003.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.post5003
|
|
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.post5003
|
|
31
|
+
Requires-Dist: nucliadb-telemetry>=6.8.1.post5003
|
|
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"
|
|
@@ -11,11 +11,11 @@ nucliadb_utils/nats.py,sha256=U21Cfg36_IHd3ZLXEC4eZ7nZ1Soh_ZNFFwjryNyd2-8,15248
|
|
|
11
11
|
nucliadb_utils/partition.py,sha256=jBgy4Hu5Iwn4gjbPPcthSykwf-qNx-GcLAIwbzPd1d0,1157
|
|
12
12
|
nucliadb_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
nucliadb_utils/run.py,sha256=Es0_Bu5Yc-LWczvwL6gzWqSwC85RjDCk-0oFQAJi9g4,1827
|
|
14
|
-
nucliadb_utils/settings.py,sha256=
|
|
14
|
+
nucliadb_utils/settings.py,sha256=H9yKrHPR5emTxai-D4owg4CjE4_-E0qR0HyuHERQNH4,8493
|
|
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=Q5sJmoX7JSnAId1BC9Lr3H9IQ85YmFwUMtw9Lco_brQ,16044
|
|
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,7 +39,7 @@ 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=
|
|
42
|
+
nucliadb_utils/storages/azure.py,sha256=pu0IyKPCn32oT0wI3oJIG6iUxnPtwNgg1zu00C8wDjo,18057
|
|
43
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
|
|
@@ -51,13 +51,13 @@ nucliadb_utils/storages/storage.py,sha256=aOJnx6-WX8U3AAqPL_sWPCghIzlr8e3GKGi8z3
|
|
|
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=rt1KRSYZW1EYhKy4Q0i7IEL9vdoOU6BYw2__S51YfGg,5039
|
|
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.post5003.dist-info/METADATA,sha256=Oi5iEbnWxJ0O1LvUaI4n79YZ5KHB8FfaLgCqqQ6eOPM,2180
|
|
61
|
+
nucliadb_utils-6.8.1.post5003.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
62
|
+
nucliadb_utils-6.8.1.post5003.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
|
63
|
+
nucliadb_utils-6.8.1.post5003.dist-info/RECORD,,
|
|
File without changes
|
{nucliadb_utils-6.8.1.post4988.dist-info → nucliadb_utils-6.8.1.post5003.dist-info}/top_level.txt
RENAMED
|
File without changes
|