Skip to content

Commit f13dc36

Browse files
[ml] Fix datalake gen2 datastore type annotation (#34669)
* Remove Optional type annotation from get() methods * Remove duplicate overloads * Update type annotations --------- Co-authored-by: Anna Tisch <[email protected]>
1 parent 62e49b4 commit f13dc36

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_datastore/azure_storage.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
from azure.ai.ml._restclient.v2023_04_01_preview.models import DatastoreType
1818
from azure.ai.ml._schema._datastore import AzureBlobSchema, AzureDataLakeGen2Schema, AzureFileSchema
1919
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, TYPE
20-
from azure.ai.ml.entities._credentials import AccountKeyConfiguration, SasTokenConfiguration
20+
from azure.ai.ml.entities._credentials import (
21+
AccountKeyConfiguration,
22+
CertificateConfiguration,
23+
SasTokenConfiguration,
24+
ServicePrincipalConfiguration,
25+
)
2126
from azure.ai.ml.entities._datastore.datastore import Datastore
2227
from azure.ai.ml.entities._datastore.utils import from_rest_datastore_credentials
2328
from azure.ai.ml.entities._util import load_from_dict
@@ -244,8 +249,11 @@ class AzureDataLakeGen2Datastore(Datastore):
244249
:param protocol: Protocol to use to connect with the Azure storage account
245250
:type protocol: str
246251
:param credentials: Credentials to use for Azure ML workspace to connect to the storage.
247-
:type credentials: Union[~azure.ai.ml.entities.AccountKeyConfiguration,
248-
~azure.ai.ml.entities.SasTokenConfiguration]
252+
:type credentials: Union[
253+
~azure.ai.ml.entities.ServicePrincipalConfiguration,
254+
~azure.ai.ml.entities.CertificateConfiguration
255+
256+
]
249257
:param properties: The asset property dictionary.
250258
:type properties: dict[str, str]
251259
:param kwargs: A dictionary of additional configuration parameters.
@@ -263,7 +271,7 @@ def __init__(
263271
endpoint: str = _get_storage_endpoint_from_metadata(),
264272
protocol: str = HTTPS,
265273
properties: Optional[Dict] = None,
266-
credentials: Optional[Union[AccountKeyConfiguration, SasTokenConfiguration]] = None,
274+
credentials: Optional[Union[ServicePrincipalConfiguration, CertificateConfiguration]] = None,
267275
**kwargs: Any
268276
):
269277
kwargs[TYPE] = DatastoreType.AZURE_DATA_LAKE_GEN2

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_datastore/datastore.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
from azure.ai.ml._restclient.v2023_04_01_preview.models import DatastoreType
1414
from azure.ai.ml._utils.utils import camel_to_snake, dump_yaml_to_file
1515
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PARAMS_OVERRIDE_KEY, CommonYamlFields
16-
from azure.ai.ml.entities._credentials import NoneCredentialConfiguration
16+
from azure.ai.ml.entities._credentials import (
17+
AccountKeyConfiguration,
18+
CertificateConfiguration,
19+
NoneCredentialConfiguration,
20+
SasTokenConfiguration,
21+
ServicePrincipalConfiguration,
22+
)
1723
from azure.ai.ml.entities._mixins import RestTranslatableMixin
1824
from azure.ai.ml.entities._resource import Resource
1925
from azure.ai.ml.entities._util import find_type_in_override
@@ -28,7 +34,14 @@ class Datastore(Resource, RestTranslatableMixin, ABC):
2834
:param description: Description of the resource.
2935
:type description: str
3036
:param credentials: Credentials to use for Azure ML workspace to connect to the storage.
31-
:type credentials: Union[ServicePrincipalSection, CertificateSection]
37+
:type credentials: Optional[Union[
38+
~azure.ai.ml.entities.ServicePrincipalConfiguration,
39+
~azure.ai.ml.entities.CertificateConfiguration,
40+
~azure.ai.ml.entities.NoneCredentialConfiguration,
41+
~azure.ai.ml.entities.AccountKeyConfiguration,
42+
~azure.ai.ml.entities.SasTokenConfiguration
43+
44+
]]
3245
:param tags: Tag dictionary. Tags can be added, removed, and updated.
3346
:type tags: dict[str, str]
3447
:param properties: The asset property dictionary.
@@ -39,7 +52,15 @@ class Datastore(Resource, RestTranslatableMixin, ABC):
3952

4053
def __init__(
4154
self,
42-
credentials: Any,
55+
credentials: Optional[
56+
Union[
57+
ServicePrincipalConfiguration,
58+
CertificateConfiguration,
59+
NoneCredentialConfiguration,
60+
AccountKeyConfiguration,
61+
SasTokenConfiguration,
62+
]
63+
],
4364
name: Optional[str] = None,
4465
description: Optional[str] = None,
4566
tags: Optional[Dict] = None,

0 commit comments

Comments
 (0)