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
more nits, and push flag to v2
  • Loading branch information
MilesHolland committed Feb 7, 2024
commit ea5b62f487bcf094a3e98d020dab71cc0f9c95a0
4 changes: 2 additions & 2 deletions sdk/ai/azure-ai-resources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

### Features Added

- Connections LIST operation now includes data connections.
- Connections have read-only support for 3 new connection types: alds gen 2, data lake, and azure blob.
- Connections LIST operation now supports returning data connections via new optional flag: include_data_connections.
- Connections have read-only support for 3 new connection types: gen 2, data lake, and azure blob.

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,22 @@ def _from_v2_workspace_connection(cls, workspace_connection: WorkspaceConnection
:rtype: ~azure.ai.resources.entities.Connection
"""
conn_class = cls._get_ai_connection_class_from_type(workspace_connection.type)
# It's simpler to create a placeholder connection, then overwrite it..
# We don't need to worry about the accidentally changing WC fields this way.
conn = conn_class(type="a", target="a", credentials=None, name="a", make_empty=True, api_version=None, api_type=None, kind=None)
# This slightly-cheeky initiliazation is just a placeholder that is immediately replaced
# with a directly-injected v2 connection object.
# Since all connection class initializers have kwargs, we can just throw a kitchen sink's
# worth of inputs to satisfy all possible subclass input requirements.
conn = conn_class(
type="a",
target="a",
credentials=None,
name="a",
make_empty=True,
api_version=None,
api_type=None,
kind=None,
account_name="a",
container_name="a",
)
conn._workspace_connection = workspace_connection
return conn

Expand Down Expand Up @@ -111,7 +124,7 @@ def _get_ai_connection_class_from_type(cls, conn_type: str):
ConnectionCategory.COGNITIVE_SEARCH.lower(): AzureAISearchConnection,
ConnectionCategory.COGNITIVE_SERVICE.lower(): AzureAIServiceConnection,
ConnectionCategory.GIT.lower(): GitHubConnection,
"azure_blob".lower(): AzureBlobStoreConnection,
"azureblob": AzureBlobStoreConnection,
ConnectionCategory.CUSTOM_KEYS.lower(): CustomConnection,
WorkspaceConnectionTypes.CUSTOM.lower(): CustomConnection
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
CONNECTION_API_VERSION_KEY,
CONNECTION_API_TYPE_KEY,
CONNECTION_KIND_KEY,
CONNECTION_ACCOUNT_NAME_KEY,
CONNECTION_CONTAINER_NAME_KEY,
)

from .base_connection import BaseConnection
Expand Down Expand Up @@ -356,7 +358,8 @@ def container_name(self) -> str:
:return: the container name of the connection.
:rtype: str
"""
return self._workspace_connection.container_name
if self._workspace_connection.tags is not None and CONNECTION_CONTAINER_NAME_KEY in self._workspace_connection.tags:
return self._workspace_connection.tags[CONNECTION_CONTAINER_NAME_KEY]

@container_name.setter
def container_name(self, value: str) -> None:
Expand All @@ -365,7 +368,7 @@ def container_name(self, value: str) -> None:
:param value: the new container name of the connection.
:type value: str
"""
self._workspace_connection.container_name = value
self._workspace_connection.tags[CONNECTION_CONTAINER_NAME_KEY] = value

@property
def account_name(self) -> str:
Expand All @@ -374,7 +377,8 @@ def account_name(self) -> str:
:return: the account name of the connection.
:rtype: str
"""
return self._workspace_connection.account_name
if self._workspace_connection.tags is not None and CONNECTION_ACCOUNT_NAME_KEY in self._workspace_connection.tags:
return self._workspace_connection.tags[CONNECTION_ACCOUNT_NAME_KEY]

@account_name.setter
def account_name(self, value: str) -> None:
Expand All @@ -383,8 +387,7 @@ def account_name(self, value: str) -> None:
:param value: the new account name of the connection.
:type value: str
"""
self._workspace_connection.account_name = value

self._workspace_connection.tags[CONNECTION_ACCOUNT_NAME_KEY] = value
class CustomConnection(BaseConnection):
"""A Connection to system that's not encapsulated by other connection types.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def list(
self,
connection_type: Optional[str] = None,
scope: str = OperationScope.AI_RESOURCE,
include_data_connection: bool = True,
include_data_connections: bool = False,
) -> Iterable[BaseConnection]:
"""List all connection assets in a project.

Expand All @@ -44,21 +44,18 @@ def list(
that are available to the AI Client's AI Resource or just those available to the project.
Defaults to AI resource-level scoping.
:type scope: ~azure.ai.resources.constants.OperationScope
:param include_data_connection: If true, also return data connections. Defaults to True.
:type include_data_connection: bool
:param include_data_connections: If true, also return data connections. Defaults to False.
:type include_data_connections: bool

:return: An iterator like instance of connection objects
:return: An iterator of connection objects
:rtype: Iterable[Connection]
"""
client = self._resource_ml_client if scope == OperationScope.AI_RESOURCE else self._project_ml_client

if include_data_connection:
operation_result = client._workspace_connections.list(
connection_type=connection_type,
params={"includeAll": "true"}
)
else:
operation_result = client._workspace_connections.list(connection_type=connection_type)
operation_result = client._workspace_connections.list(
connection_type=connection_type,
include_data_connections=include_data_connections
)

return [BaseConnection._from_v2_workspace_connection(conn) for conn in operation_result]

Expand Down
2 changes: 1 addition & 1 deletion sdk/ml/azure-ai-ml/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Remove `experimental` tag for `ml_client.jobs.validate`.
- Workspace Connection has new read-only subclass: AzureBlobStoreWorkspaceConnectionSchema.
- Workspace Connection supports 2 new types under main class: gen 2 and azure_one_lake.
- Workspace connection supports reading data connections.
- Workspace Connection LIST operation can return data connections via new optional flag: include_data_connections.

### Bugs Fixed
- Fix pipeline job `outputs` not load correctly when `component: <local-file>` exists in pipeline job yaml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def _to_rest_object(self) -> RestWorkspaceConnection:
if conn_type == WorkspaceConnectionTypes.CUSTOM:
conn_type = ConnectionCategory.CUSTOM_KEYS

# No credential property bag uniquely has different inputs from ALL other propety bag classes.
# No credential property bag uniquely has different inputs from ALL other property bag classes.
if workspace_connection_properties_class == NoneAuthTypeWorkspaceConnectionProperties:
properties = workspace_connection_properties_class(
target=self.target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ def delete(self, name: str) -> None:
def list(
self,
connection_type: Optional[str] = None,
include_data_connections: bool = False,
**kwargs: Any,
) -> Iterable[WorkspaceConnection]:
"""List all workspace connections for a workspace.

:param connection_type: Type of workspace connection to list.
:type connection_type: Optional[str]
:param include_data_connections: If true, also return data connections. Defaults to False.
:type include_data_connections: bool
:return: An iterator like instance of workspace connection objects
:rtype: Iterable[~azure.ai.ml.entities.WorkspaceConnection]

Expand All @@ -150,6 +153,13 @@ def list(
:dedent: 8
:caption: Lists all connections for a workspace for a certain type, in this case "git".
"""

if include_data_connections:
if "params" in kwargs:
kwargs["params"]["includeAll"] = "true"
else:
kwargs["params"] = {"includeAll": "true"}

return cast(
Iterable[WorkspaceConnection],
self._operation.list(
Expand Down