nucliadb-utils 4.0.3.post602__py3-none-any.whl → 4.0.3.post604__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.
@@ -114,11 +114,16 @@ class StorageSettings(BaseSettings):
114
114
  description="Number of days that uploaded files are kept in Nulia's processing engine",
115
115
  )
116
116
 
117
- azure_connection_string: Optional[str] = Field(
117
+ azure_account_url: Optional[str] = Field(
118
118
  default=None,
119
- description="Azure Storage connection string: https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string", # noqa
119
+ description="Azure Account URL. The driver implementation uses Azure's default credential authentication method: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python", # noqa
120
+ examples=["https://<storageaccountname>.blob.core.windows.net"],
120
121
  )
121
122
 
123
+ # For testing purposes: Azurite docker image requires a connection string as it
124
+ # doesn't support Azure's default credential authentication method
125
+ azure_connection_string: Optional[str] = None
126
+
122
127
 
123
128
  storage_settings = StorageSettings()
124
129
 
@@ -25,6 +25,7 @@ from datetime import datetime
25
25
  from typing import AsyncGenerator, AsyncIterator, Optional, Union
26
26
 
27
27
  from azure.core.exceptions import ResourceExistsError, ResourceNotFoundError
28
+ from azure.identity import DefaultAzureCredential
28
29
  from azure.storage.blob import BlobProperties, BlobType, ContentSettings
29
30
  from azure.storage.blob.aio import BlobServiceClient
30
31
 
@@ -161,11 +162,12 @@ class AzureStorage(Storage):
161
162
 
162
163
  def __init__(
163
164
  self,
164
- connection_string: str,
165
+ account_url: str,
165
166
  deadletter_bucket: str = "deadletter",
166
167
  indexing_bucket: str = "indexing",
168
+ connection_string: Optional[str] = None,
167
169
  ):
168
- self.object_store = AzureObjectStore(connection_string)
170
+ self.object_store = AzureObjectStore(account_url, connection_string=connection_string)
169
171
  self.deadletter_bucket = deadletter_bucket
170
172
  self.indexing_bucket = indexing_bucket
171
173
 
@@ -215,7 +217,8 @@ class AzureStorage(Storage):
215
217
 
216
218
 
217
219
  class AzureObjectStore(ObjectStore):
218
- def __init__(self, connection_string: str):
220
+ def __init__(self, account_url: str, connection_string: Optional[str] = None):
221
+ self.account_url = account_url
219
222
  self.connection_string = connection_string
220
223
  self._service_client: Optional[BlobServiceClient] = None
221
224
 
@@ -226,7 +229,13 @@ class AzureObjectStore(ObjectStore):
226
229
  return self._service_client
227
230
 
228
231
  async def initialize(self):
229
- self._service_client = BlobServiceClient.from_connection_string(self.connection_string)
232
+ if self.connection_string:
233
+ # For testing purposes
234
+ self._service_client = BlobServiceClient.from_connection_string(self.connection_string)
235
+ else:
236
+ self._service_client = BlobServiceClient(
237
+ self.account_url, credential=DefaultAzureCredential()
238
+ )
230
239
 
231
240
  async def finalize(self):
232
241
  try:
@@ -74,6 +74,7 @@ class AzuriteFixture:
74
74
  port: int
75
75
  container: BaseImage
76
76
  connection_string: str
77
+ account_url: str
77
78
 
78
79
 
79
80
  def get_connection_string(host, port) -> str:
@@ -99,6 +100,7 @@ def azurite() -> Generator[AzuriteFixture, None, None]:
99
100
  port=port,
100
101
  container=container.container_obj,
101
102
  connection_string=get_connection_string(host, port),
103
+ account_url=f"http://{host}:{port}/devstoreaccount1",
102
104
  )
103
105
  finally:
104
106
  container.stop()
@@ -107,6 +109,7 @@ def azurite() -> Generator[AzuriteFixture, None, None]:
107
109
  @pytest.fixture(scope="function")
108
110
  async def azure_storage(azurite):
109
111
  storage = AzureStorage(
112
+ account_url=azurite.account_url,
110
113
  connection_string=azurite.connection_string,
111
114
  )
112
115
  MAIN[Utility.STORAGE] = storage
@@ -101,10 +101,11 @@ async def get_storage(
101
101
  if storage_settings.file_backend == FileBackendConfig.AZURE:
102
102
  from nucliadb_utils.storages.azure import AzureStorage
103
103
 
104
- if storage_settings.azure_connection_string is None:
105
- raise ConfigurationError("AZURE_CONNECTION_STRING env var not configured")
104
+ if storage_settings.azure_account_url is None:
105
+ raise ConfigurationError("AZURE_ACCOUNT_URL env variable not configured")
106
106
 
107
107
  azureutil = AzureStorage(
108
+ account_url=storage_settings.azure_account_url,
108
109
  connection_string=storage_settings.azure_connection_string,
109
110
  )
110
111
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nucliadb_utils
3
- Version: 4.0.3.post602
3
+ Version: 4.0.3.post604
4
4
  Home-page: https://nuclia.com
5
5
  License: BSD
6
6
  Classifier: Development Status :: 4 - Beta
@@ -23,8 +23,8 @@ Requires-Dist: PyNaCl
23
23
  Requires-Dist: pyjwt >=2.4.0
24
24
  Requires-Dist: memorylru >=1.1.2
25
25
  Requires-Dist: mrflagly
26
- Requires-Dist: nucliadb-protos >=4.0.3.post602
27
- Requires-Dist: nucliadb-telemetry >=4.0.3.post602
26
+ Requires-Dist: nucliadb-protos >=4.0.3.post604
27
+ Requires-Dist: nucliadb-telemetry >=4.0.3.post604
28
28
  Provides-Extra: cache
29
29
  Requires-Dist: redis >=4.3.4 ; extra == 'cache'
30
30
  Requires-Dist: orjson >=3.6.7 ; extra == 'cache'
@@ -44,6 +44,7 @@ Requires-Dist: aiofiles >=0.8.0 ; extra == 'storages'
44
44
  Requires-Dist: backoff >=1.11.1 ; extra == 'storages'
45
45
  Requires-Dist: google-auth >=2.4.1 ; extra == 'storages'
46
46
  Requires-Dist: azure-storage-blob >=12.20.0 ; extra == 'storages'
47
+ Requires-Dist: azure-identity >=1.16.1 ; extra == 'storages'
47
48
 
48
49
  # nucliadb util python library
49
50
 
@@ -12,11 +12,11 @@ nucliadb_utils/nats.py,sha256=zTAXECDXeCPtydk3F_6EMFDZ059kK0UYUU_tnWoxgXs,8208
12
12
  nucliadb_utils/partition.py,sha256=jBgy4Hu5Iwn4gjbPPcthSykwf-qNx-GcLAIwbzPd1d0,1157
13
13
  nucliadb_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  nucliadb_utils/run.py,sha256=HpAIM8xbR7UpVC2_7xOjB4fYbUVykyPP6yHrv2RD3DI,1707
15
- nucliadb_utils/settings.py,sha256=VXZuq-4-RvsUsMIjL-wRRjzCqM-b_AnTHsW_hGrax_o,7281
15
+ nucliadb_utils/settings.py,sha256=AaOtQZVRqRcMnUyN1l1MpR10lANaDT2uPrbhmTyn6uk,7647
16
16
  nucliadb_utils/signals.py,sha256=JRNv2y9zLtBjOANBf7krGfDGfOc9qcoXZ6N1nKWS2FE,2674
17
17
  nucliadb_utils/store.py,sha256=kQ35HemE0v4_Qg6xVqNIJi8vSFAYQtwI3rDtMsNy62Y,890
18
18
  nucliadb_utils/transaction.py,sha256=mwcI3aIHAvU5KOGqd_Uz_d1XQzXhk_-NWY8NqU1lfb0,7307
19
- nucliadb_utils/utilities.py,sha256=Vb7lXUSDtqS_7tNqI4CDQD2woHO_JFUGSjC2Yj4-uEA,14135
19
+ nucliadb_utils/utilities.py,sha256=puBRsquZEM3gnXNI8wPwXzG1gN8Gg86B7g-oJFlrXQQ,14188
20
20
  nucliadb_utils/audit/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
21
21
  nucliadb_utils/audit/audit.py,sha256=dn5ZnCVQUlCcvdjzaORghbrjk9QgVGrtkfIftq30Bp8,2819
22
22
  nucliadb_utils/audit/basic.py,sha256=NViey6mKbCXqRTLDBX2xNTcCg9I-2e4oB2xkekuhDvM,3392
@@ -39,7 +39,7 @@ nucliadb_utils/nuclia_usage/protos/kb_usage_pb2_grpc.pyi,sha256=6RIsZ2934iodEckf
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=E1eUSFXBVNzQP9Q2rWj9y3koCO5S7iKwckny_AoLKuk,3870
41
41
  nucliadb_utils/storages/__init__.py,sha256=5Qc8AUWiJv9_JbGCBpAn88AIJhwDlm0OPQpg2ZdRL4U,872
42
- nucliadb_utils/storages/azure.py,sha256=7cWbe144WIwt10IM6XPRThkjeg5M_U0WInj4Jk75THw,15591
42
+ nucliadb_utils/storages/azure.py,sha256=egMDwLNIGSQyVevuySt2AswzFdNAcih05BbRg3-p8IU,16015
43
43
  nucliadb_utils/storages/exceptions.py,sha256=mm_wX4YRtp7u7enkk_4pMSlX5AQQuFbq4xLmupVDt3Y,2502
44
44
  nucliadb_utils/storages/gcs.py,sha256=WblkxWoa1brevsJV3ebiE6s7Wb_eXFScw41202f5uP4,26999
45
45
  nucliadb_utils/storages/local.py,sha256=NxC_nMBd38NDsR266DSgoBLdQlvUwf0_sd50r-BLI0E,10288
@@ -51,15 +51,15 @@ nucliadb_utils/storages/storage.py,sha256=Ask2f1xuQHxavF3uKXXrmjOeY7w3ZljpZlcvmI
51
51
  nucliadb_utils/storages/utils.py,sha256=8g2rIwJeYIumQLOB47Yw1rx3twlhRB_cJxer65QfZmk,1479
52
52
  nucliadb_utils/tests/__init__.py,sha256=Oo9CAE7B0eW5VHn8sHd6o30SQzOWUhktLPRXdlDOleA,1456
53
53
  nucliadb_utils/tests/asyncbenchmark.py,sha256=x4be2IwCawle9zWgMOJkmwoUwk5p1tv7cLQGmybkEOg,10587
54
- nucliadb_utils/tests/azure.py,sha256=ji-BV54m_MHAB9KdSToYgsZ8OZZ-C5Yq2VqWOYZNMs4,3668
54
+ nucliadb_utils/tests/azure.py,sha256=7viGeUPC-HnRn7PG6cyDe8HhRsgOoAsU6tcuav3gl1A,3796
55
55
  nucliadb_utils/tests/fixtures.py,sha256=rmix1VGpPULBxJd_5ScgVD4Z0nRrkNOVt-uTW_WoURU,2144
56
56
  nucliadb_utils/tests/gcs.py,sha256=Ii8BCHUAAxFIzX67pKTRFRgbqv3FJ6DrPAdAx2Xod1Y,3036
57
57
  nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQFxk,1513
58
58
  nucliadb_utils/tests/local.py,sha256=c3gZJJWmvOftruJkIQIwB3q_hh3uxEhqGIAVWim1Bbk,1343
59
59
  nucliadb_utils/tests/nats.py,sha256=Tosonm9A9cusImyji80G4pgdXEHNVPaCLT5TbFK_ra0,7543
60
60
  nucliadb_utils/tests/s3.py,sha256=YB8QqDaBXxyhHonEHmeBbRRDmvB7sTOaKBSi8KBGokg,2330
61
- nucliadb_utils-4.0.3.post602.dist-info/METADATA,sha256=zYwnmt6KeiIBlFx0O7risLDV6mob6HkYxFGMTNZEm0c,2096
62
- nucliadb_utils-4.0.3.post602.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
63
- nucliadb_utils-4.0.3.post602.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
64
- nucliadb_utils-4.0.3.post602.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
65
- nucliadb_utils-4.0.3.post602.dist-info/RECORD,,
61
+ nucliadb_utils-4.0.3.post604.dist-info/METADATA,sha256=Phr4NyXmgKXlT-rQFz2UPNlkunJrWUKLEi20-7tCDZc,2157
62
+ nucliadb_utils-4.0.3.post604.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
63
+ nucliadb_utils-4.0.3.post604.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
64
+ nucliadb_utils-4.0.3.post604.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
65
+ nucliadb_utils-4.0.3.post604.dist-info/RECORD,,