Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5947e8b
get other conn types in list op
MilesHolland Jan 12, 2024
4f006da
accept empty connections in rest-local conversion
MilesHolland Jan 25, 2024
e319d40
Merge branch 'main' of https://github.com/azure/azure-sdk-for-python
MilesHolland Jan 25, 2024
e5af527
Merge branch 'main' into connections-jan-asks
MilesHolland Jan 25, 2024
9318317
azure blob base changes
MilesHolland Jan 31, 2024
d986da9
Merge branch 'main' into connections-jan-asks
MilesHolland Jan 31, 2024
1b6d921
partial replacement of if-else with maps in wc
MilesHolland Feb 2, 2024
6263dc6
more if-else removal refactors
MilesHolland Feb 5, 2024
4b6f2dc
Merge branch 'main' into connections-jan-asks
MilesHolland Feb 5, 2024
5882887
solidify connection changes
MilesHolland Feb 6, 2024
47c9b51
run black on v2
MilesHolland Feb 6, 2024
de24812
Merge branch 'main' into connections-jan-asks
MilesHolland Feb 6, 2024
5c8930f
initial self review
MilesHolland Feb 6, 2024
4b4c988
spelling
MilesHolland Feb 6, 2024
6f539fd
rerun black and ai nit
MilesHolland Feb 6, 2024
ea5b62f
more nits, and push flag to v2
MilesHolland Feb 7, 2024
7d4ca46
e2e test
MilesHolland Feb 7, 2024
d87bba7
Merge branch 'main' into connections-jan-asks
MilesHolland Feb 7, 2024
663ea4c
e2e test recordings and use 2024 restclient
MilesHolland Feb 7, 2024
a3907f9
analyze ci issues
MilesHolland Feb 7, 2024
2e85ab2
Merge branch 'main' into connections-jan-asks
MilesHolland Feb 7, 2024
5aa8207
mypy fixes
MilesHolland Feb 8, 2024
7795de7
more mypy
MilesHolland Feb 8, 2024
ec10c08
Merge branch 'connections-jan-asks' of github.com:MilesHolland/azure-…
MilesHolland Feb 8, 2024
0e2d312
remove 2024 conn dep until CI wakes up
MilesHolland Feb 8, 2024
31939b5
skip problematic test
MilesHolland Feb 8, 2024
e3be48b
try bumping mindep
MilesHolland Feb 8, 2024
710b06a
remove skip
MilesHolland Feb 8, 2024
b922eec
undo 1.14.0 dep
MilesHolland Feb 8, 2024
9d800cb
add back in 1.14 dep
MilesHolland Feb 8, 2024
a408731
comments
MilesHolland Feb 12, 2024
10922a1
linting
MilesHolland Feb 12, 2024
d2c66ed
remove extra line
MilesHolland Feb 12, 2024
dba0cbd
more linting
MilesHolland Feb 13, 2024
66e202c
run black
MilesHolland Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rerun black and ai nit
  • Loading branch information
MilesHolland committed Feb 6, 2024
commit 6f539fd36582855c4851ce87c146556eccc088aa
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get(self, name: str, scope: str = OperationScope.AI_RESOURCE, **kwargs) -> B
"""
client = self._resource_ml_client if scope == OperationScope.AI_RESOURCE else self._project_ml_client
workspace_connection = client._workspace_connections.get(name=name, **kwargs)
connection = BaseConnection._from_v2_workspace_connection(workspace_connection, params={"includeAll": "true"})
connection = BaseConnection._from_v2_workspace_connection(workspace_connection)

# It's by design that both API and V2 SDK don't include the secrets from API response, the following
# code fills the gap when possible
Expand Down
16 changes: 12 additions & 4 deletions sdk/ml/azure-ai-ml/azure/ai/ml/entities/_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
UsernamePasswordAuthTypeWorkspaceConnectionProperties,
)


class _BaseIdentityConfiguration(ABC, DictMixin, RestTranslatableMixin):
def __init__(self) -> None:
self.type: Any = None
Expand All @@ -99,7 +100,9 @@ def _get_credential_class_from_rest_type(cls, auth_type: str) -> Type:
}
if not auth_type:
return NoneCredentialConfiguration
return REST_CREDENTIAL_TYPE_TO_CLIENT_CLASS_MAP.get(_snake_to_camel(auth_type).lower(), NoneCredentialConfiguration)
return REST_CREDENTIAL_TYPE_TO_CLIENT_CLASS_MAP.get(
_snake_to_camel(auth_type).lower(), NoneCredentialConfiguration
)


class AccountKeyConfiguration(RestTranslatableMixin, DictMixin):
Expand Down Expand Up @@ -162,7 +165,7 @@ def __eq__(self, other: object) -> bool:

def __ne__(self, other: object) -> bool:
return not self.__eq__(other)

@classmethod
def _get_rest_properties_class(cls) -> Type:
return SASAuthTypeWorkspaceConnectionProperties
Expand Down Expand Up @@ -207,6 +210,7 @@ def __eq__(self, other: object) -> bool:
def _get_rest_properties_class(cls) -> Type:
return PATAuthTypeWorkspaceConnectionProperties


class UsernamePasswordConfiguration(RestTranslatableMixin, DictMixin):
"""Username and password credentials.

Expand Down Expand Up @@ -248,6 +252,7 @@ def __eq__(self, other: object) -> bool:
def _get_rest_properties_class(cls) -> Type:
return UsernamePasswordAuthTypeWorkspaceConnectionProperties


class BaseTenantCredentials(RestTranslatableMixin, DictMixin, ABC):
"""Base class for tenant credentials.

Expand Down Expand Up @@ -354,6 +359,7 @@ def __ne__(self, other: object) -> bool:
def _get_rest_properties_class(cls) -> Type:
return ServicePrincipalAuthTypeWorkspaceConnectionProperties


class CertificateConfiguration(BaseTenantCredentials):
def __init__(
self,
Expand Down Expand Up @@ -574,6 +580,7 @@ def __eq__(self, other: object) -> bool:
def _get_rest_properties_class(cls) -> Type:
return ManagedIdentityAuthTypeWorkspaceConnectionProperties


class UserIdentityConfiguration(_BaseIdentityConfiguration):
"""User identity configuration.

Expand Down Expand Up @@ -816,6 +823,7 @@ def __ne__(self, other: object) -> bool:
def _get_rest_properties_class(cls) -> Type:
return NoneAuthTypeWorkspaceConnectionProperties


class AccessKeyConfiguration(RestTranslatableMixin, DictMixin):
"""Access Key Credentials.

Expand Down Expand Up @@ -854,7 +862,7 @@ def __eq__(self, other: object) -> bool:
if not isinstance(other, AccessKeyConfiguration):
return NotImplemented
return self.access_key_id == other.access_key_id and self.secret_access_key == other.secret_access_key

def _get_rest_properties_class(self):
return AccessKeyAuthTypeWorkspaceConnectionProperties

Expand Down Expand Up @@ -893,6 +901,6 @@ def __eq__(self, other: object) -> bool:
if not isinstance(other, ApiKeyConfiguration):
return NotImplemented
return bool(self.key == other.key)

def _get_rest_properties_class(self):
return ApiKeyAuthWorkspaceConnectionProperties
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ def _to_rest_object(self) -> RestWorkspaceConnection:
# No credential property bag uniquely has different inputs from ALL other propety bag classes.
if workspace_connection_properties_class == NoneAuthTypeWorkspaceConnectionProperties:
properties = workspace_connection_properties_class(
target=self.target,
metadata=self.tags,
category=_snake_to_camel(conn_type),
is_shared_to_all=self.is_shared,
)
target=self.target,
metadata=self.tags,
category=_snake_to_camel(conn_type),
is_shared_to_all=self.is_shared,
)
else:
properties = workspace_connection_properties_class(
target=self.target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ def __init__(
# Blob store connections returned from the API generally have no credentials, but we still don't want
# to silently run over user inputted connections if they want to play with them locally, so double-check
# kwargs for them.
super().__init__(target=target, type="azure_blob", credentials=kwargs.pop("credentials", None), from_child=True, **kwargs)
super().__init__(
target=target, type="azure_blob", credentials=kwargs.pop("credentials", None), from_child=True, **kwargs
)

self.tags[CONNECTION_CONTAINER_NAME_KEY] = container_name
self.tags[CONNECTION_ACCOUNT_NAME_KEY] = account_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from azure.ai.ml.entities._credentials import PatTokenConfiguration
from azure.ai.ml.constants._common import WorkspaceConnectionTypes


@pytest.mark.unittest
@pytest.mark.core_sdk_test
class TestWorkspaceConnectionEntity:
Expand Down