Skip to content

Commit 35e77b4

Browse files
authored
Merge pull request #14 from bpkroth/sergiym/svc/fs_token_auth
move sanity check into __init__
2 parents d9bf3fe + 00ff3bf commit 35e77b4

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

mlos_bench/mlos_bench/services/remote/azure/azure_fileshare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def __init__(
6060
"storageFileShareName",
6161
},
6262
)
63+
assert self._parent is not None and isinstance(
64+
self._parent, SupportsAuth
65+
), "Authorization service not provided. Include service-auth.jsonc?"
6366
self._share_client: Optional[ShareClient] = None
6467

6568
def _get_share_client(self) -> ShareClient:
6669
"""Get the Azure file share client object."""
6770
if self._share_client is None:
68-
assert self._parent is not None and isinstance(
69-
self._parent, SupportsAuth
70-
), "Authorization service not provided. Include service-auth.jsonc?"
7171
self._share_client = ShareClient.from_share_url(
7272
AzureFileShareService._SHARE_URL.format(
7373
account_name=self.config["storageAccountName"],

mlos_bench/mlos_bench/tests/config/services/test_load_service_config_examples.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,23 @@ def test_load_service_config_examples(
4848
config_path: str,
4949
) -> None:
5050
"""Tests loading a config example."""
51+
parent: Service = config_loader_service
5152
config = config_loader_service.load_config(config_path, ConfigSchema.SERVICE)
53+
if config.get("class", "").split(".")[-1] == "AzureFileShareService":
54+
# AzureFileShareService requires an auth service to be loaded as well.
55+
auth_service_config = config_loader_service.load_config(
56+
"services/remote/azure/service-auth.jsonc",
57+
ConfigSchema.SERVICE,
58+
)
59+
auth_service = config_loader_service.build_service(
60+
config=auth_service_config,
61+
parent=config_loader_service,
62+
)
63+
parent = auth_service
5264
# Make an instance of the class based on the config.
5365
service_inst = config_loader_service.build_service(
5466
config=config,
55-
parent=config_loader_service,
67+
parent=parent,
5668
)
5769
assert service_inst is not None
5870
assert isinstance(service_inst, Service)

0 commit comments

Comments
 (0)