Skip to content

Commit 52f0083

Browse files
committed
updated docs
1 parent 494ad54 commit 52f0083

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

src/maggma/stores/azure.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@
4141
]
4242

4343

44-
def _get_azure_credential(credential_class: str):
44+
def _get_azure_credential(credential_class):
4545
"""Import the azure.identity module and return the credential class."""
46-
module_name = "azure.identity"
47-
credential_class = getattr(importlib.import_module(module_name), credential_class)
46+
if isinstance(credential_class, str):
47+
module_name = "azure.identity"
48+
credential_class = getattr(importlib.import_module(module_name), credential_class)
4849
return credential_class()
4950

5051

@@ -86,7 +87,9 @@ def __init__(
8687
Currently supported keywords:
8788
- connection_string: a connection string for the Azure blob
8889
credential_type: the type of credential to use to authenticate with Azure.
89-
Default is "DefaultAzureCredential".
90+
Default is "DefaultAzureCredential". For serializable stores, provide
91+
a string representation of the credential class. Otherwises, you may
92+
provide the class itself.
9093
compress: compress files inserted into the store
9194
sub_dir: (optional) subdirectory of the container to store the data.
9295
When defined, a final "/" will be added if not already present.

tests/stores/test_azure.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,32 @@ def test_no_login():
422422
store.connect()
423423

424424

425-
@pytest.mark.parametrize(
426-
"credential_type",
427-
[
428-
"DefaultAzureCredential",
429-
"AzureCliCredential",
430-
],
431-
)
432-
def test_credential_type_valid(credential_type):
433-
with azurite_container():
434-
index = MemoryStore("index")
435-
store = AzureBlobStore(
436-
index,
437-
AZURITE_CONTAINER_NAME,
438-
credential_type=credential_type,
439-
)
440-
store.connect()
425+
def test_credential_type_valid():
426+
credential_type = "DefaultAzureCredential"
427+
index = MemoryStore("index")
428+
store = AzureBlobStore(
429+
index,
430+
AZURITE_CONTAINER_NAME,
431+
credential_type=credential_type,
432+
)
433+
assert store.credential_type == credential_type
434+
435+
credential_type = "AzureCliCredential"
436+
index = MemoryStore("index")
437+
store = AzureBlobStore(
438+
index,
439+
AZURITE_CONTAINER_NAME,
440+
credential_type=credential_type,
441+
)
442+
assert store.credential_type == credential_type
443+
444+
from azure.identity import DefaultAzureCredential
445+
446+
credential_type = DefaultAzureCredential
447+
index = MemoryStore("index")
448+
store = AzureBlobStore(
449+
index,
450+
AZURITE_CONTAINER_NAME,
451+
credential_type=credential_type,
452+
)
453+
assert not isinstance(store.credential_type, str)

0 commit comments

Comments
 (0)