Skip to content

Commit 1cd8a1b

Browse files
authored
revert connection name (#35578) (#35584)
* revert connection name (#35578) * revert connection name * rename files and schema class * fake * undo fake * rename create field * run black * correct merge
1 parent 44fa956 commit 1cd8a1b

File tree

16 files changed

+171
-150
lines changed

16 files changed

+171
-150
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
### Breaking Changes
3333

34-
- WorkspaceConnection and subclasses renamed to just Connection
3534
- Removed WorkspaceHubConfig entity, and renamed WorkspaceHub to Hub.
3635
- workspace_hub input of Workspace class hidden, renamed to hub_id, and re-surfaced in child class Project.
3736
- Removed Workspace Hub Operations from ML Client.

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/connections/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
66

7-
from .connection import ConnectionSchema
7+
from .workspace_connection import WorkspaceConnectionSchema
88
from .connection_subtypes import (
99
AzureBlobStoreConnectionSchema,
1010
MicrosoftOneLakeConnectionSchema,
@@ -21,7 +21,7 @@
2121
)
2222

2323
__all__ = [
24-
"ConnectionSchema",
24+
"WorkspaceConnectionSchema",
2525
"AzureBlobStoreConnectionSchema",
2626
"MicrosoftOneLakeConnectionSchema",
2727
"AzureOpenAIConnectionSchema",

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/connections/connection_subtypes.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
AadCredentialConfigurationSchema,
2121
)
2222
from azure.ai.ml.entities import AadCredentialConfiguration
23-
from .connection import ConnectionSchema
23+
from .workspace_connection import WorkspaceConnectionSchema
2424

2525

2626
# pylint: disable-next=name-too-long
27-
class AzureBlobStoreConnectionSchema(ConnectionSchema):
27+
class AzureBlobStoreConnectionSchema(WorkspaceConnectionSchema):
2828
# type and credentials limited
2929
type = StringTransformedEnum(
3030
allowed_values=ConnectionCategory.AZURE_BLOB, casing_transform=camel_to_snake, required=True
@@ -52,7 +52,7 @@ def make(self, data, **kwargs):
5252

5353

5454
# pylint: disable-next=name-too-long
55-
class MicrosoftOneLakeConnectionSchema(ConnectionSchema):
55+
class MicrosoftOneLakeConnectionSchema(WorkspaceConnectionSchema):
5656
type = StringTransformedEnum(
5757
allowed_values=ConnectionCategory.AZURE_ONE_LAKE, casing_transform=camel_to_snake, required=True
5858
)
@@ -93,7 +93,7 @@ def make(self, data, **kwargs):
9393

9494

9595
# pylint: disable-next=name-too-long
96-
class AzureOpenAIConnectionSchema(ConnectionSchema):
96+
class AzureOpenAIConnectionSchema(WorkspaceConnectionSchema):
9797
# type and credentials limited
9898
type = StringTransformedEnum(
9999
allowed_values=ConnectionCategory.AZURE_OPEN_AI, casing_transform=camel_to_snake, required=True
@@ -112,7 +112,7 @@ def make(self, data, **kwargs):
112112

113113

114114
# pylint: disable-next=name-too-long
115-
class AzureAIServicesConnectionSchema(ConnectionSchema):
115+
class AzureAIServicesConnectionSchema(WorkspaceConnectionSchema):
116116
# type and credentials limited
117117
type = StringTransformedEnum(
118118
allowed_values=ConnectionTypes.AZURE_AI_SERVICES, casing_transform=camel_to_snake, required=True
@@ -129,7 +129,7 @@ def make(self, data, **kwargs):
129129

130130

131131
# pylint: disable-next=name-too-long
132-
class AzureAISearchConnectionSchema(ConnectionSchema):
132+
class AzureAISearchConnectionSchema(WorkspaceConnectionSchema):
133133
# type and credentials limited
134134
type = StringTransformedEnum(
135135
allowed_values=ConnectionTypes.AZURE_SEARCH, casing_transform=camel_to_snake, required=True
@@ -145,7 +145,7 @@ def make(self, data, **kwargs):
145145

146146

147147
# pylint: disable-next=name-too-long
148-
class AzureContentSafetyConnectionSchema(ConnectionSchema):
148+
class AzureContentSafetyConnectionSchema(WorkspaceConnectionSchema):
149149
# type and credentials limited
150150
type = StringTransformedEnum(
151151
allowed_values=ConnectionTypes.AZURE_CONTENT_SAFETY, casing_transform=camel_to_snake, required=True
@@ -161,7 +161,7 @@ def make(self, data, **kwargs):
161161

162162

163163
# pylint: disable-next=name-too-long
164-
class AzureSpeechServicesConnectionSchema(ConnectionSchema):
164+
class AzureSpeechServicesConnectionSchema(WorkspaceConnectionSchema):
165165
# type and credentials limited
166166
type = StringTransformedEnum(
167167
allowed_values=ConnectionTypes.AZURE_SPEECH_SERVICES, casing_transform=camel_to_snake, required=True
@@ -176,7 +176,7 @@ def make(self, data, **kwargs):
176176
return AzureSpeechServicesConnection(**data)
177177

178178

179-
class APIKeyConnectionSchema(ConnectionSchema):
179+
class APIKeyConnectionSchema(WorkspaceConnectionSchema):
180180
# type and credentials limited
181181
type = StringTransformedEnum(
182182
allowed_values=ConnectionCategory.API_KEY, casing_transform=camel_to_snake, required=True
@@ -192,7 +192,7 @@ def make(self, data, **kwargs):
192192

193193

194194
# pylint: disable-next=name-too-long
195-
class OpenAIConnectionSchema(ConnectionSchema):
195+
class OpenAIConnectionSchema(WorkspaceConnectionSchema):
196196
# type and credentials limited
197197
type = StringTransformedEnum(
198198
allowed_values=ConnectionCategory.OPEN_AI, casing_transform=camel_to_snake, required=True
@@ -207,7 +207,7 @@ def make(self, data, **kwargs):
207207

208208

209209
# pylint: disable-next=name-too-long
210-
class SerpConnectionSchema(ConnectionSchema):
210+
class SerpConnectionSchema(WorkspaceConnectionSchema):
211211
# type and credentials limited
212212
type = StringTransformedEnum(allowed_values=ConnectionCategory.SERP, casing_transform=camel_to_snake, required=True)
213213
api_key = fields.Str(required=True)
@@ -220,7 +220,7 @@ def make(self, data, **kwargs):
220220

221221

222222
# pylint: disable-next=name-too-long
223-
class ServerlessConnectionSchema(ConnectionSchema):
223+
class ServerlessConnectionSchema(WorkspaceConnectionSchema):
224224
# type and credentials limited
225225
type = StringTransformedEnum(
226226
allowed_values=ConnectionCategory.SERVERLESS, casing_transform=camel_to_snake, required=True

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/connections/connection.py renamed to sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/connections/workspace_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from azure.ai.ml.entities import NoneCredentialConfiguration, AadCredentialConfiguration
2828

2929

30-
class ConnectionSchema(ResourceSchema):
30+
class WorkspaceConnectionSchema(ResourceSchema):
3131
# Inherits name, id, tags, and description fields from ResourceSchema
3232
creation_context = NestedField(CreationContextSchema, dump_only=True)
3333
type = StringTransformedEnum(
@@ -73,7 +73,7 @@ class ConnectionSchema(ResourceSchema):
7373

7474
@post_load
7575
def make(self, data, **kwargs):
76-
from azure.ai.ml.entities import Connection
76+
from azure.ai.ml.entities import WorkspaceConnection
7777

7878
# Most non-subclassed connections default to a none credential if none
7979
# is provided. ALDS Gen 2 connections default to AAD with this code.
@@ -82,4 +82,4 @@ def make(self, data, **kwargs):
8282
and data.get("credentials", None) == NoneCredentialConfiguration()
8383
):
8484
data["credentials"] = AadCredentialConfiguration()
85-
return Connection(**data)
85+
return WorkspaceConnection(**data)

sdk/ml/azure-ai-ml/azure/ai/ml/entities/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
from ._system_data import SystemData
256256
from ._validation import ValidationResult
257257
from ._workspace.compute_runtime import ComputeRuntime
258-
from ._workspace.connections.connection import Connection
258+
from ._workspace.connections.workspace_connection import WorkspaceConnection
259259
from ._workspace.connections.connection_subtypes import (
260260
AzureBlobStoreConnection,
261261
MicrosoftOneLakeConnection,
@@ -352,7 +352,7 @@
352352
"ModelBatchDeploymentSettings",
353353
"Workspace",
354354
"WorkspaceKeys",
355-
"Connection",
355+
"WorkspaceConnection",
356356
"AzureBlobStoreConnection",
357357
"MicrosoftOneLakeConnection",
358358
"AzureOpenAIConnection",

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_load_functions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from azure.ai.ml.entities._resource import Resource
4545
from azure.ai.ml.entities._schedule.schedule import Schedule
4646
from azure.ai.ml.entities._validation import PathAwareSchemaValidatableMixin, ValidationResultBuilder
47-
from azure.ai.ml.entities._workspace.connections.connection import Connection
47+
from azure.ai.ml.entities._workspace.connections.workspace_connection import WorkspaceConnection
4848
from azure.ai.ml.entities._workspace.workspace import Workspace
4949
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationErrorType, ValidationException
5050

@@ -810,7 +810,7 @@ def load_connection(
810810
relative_origin: Optional[str] = None,
811811
params_override: Optional[List[Dict]] = None,
812812
**kwargs: Any,
813-
) -> Connection:
813+
) -> WorkspaceConnection:
814814
"""Construct a connection object from yaml file.
815815
816816
:param source: The local yaml source of a connection object. Must be either a
@@ -832,7 +832,9 @@ def load_connection(
832832
:rtype: Connection
833833
834834
"""
835-
return cast(Connection, load_common(Connection, source, relative_origin, params_override, **kwargs))
835+
return cast(
836+
WorkspaceConnection, load_common(WorkspaceConnection, source, relative_origin, params_override, **kwargs)
837+
)
836838

837839

838840
# Unlike other aspects of connections, this wasn't made experimental, and thus couldn't just be replaced
@@ -842,7 +844,7 @@ def load_workspace_connection(
842844
*,
843845
relative_origin: Optional[str] = None,
844846
**kwargs: Any,
845-
) -> Connection:
847+
) -> WorkspaceConnection:
846848
"""Deprecated - use 'load_connection' instead. Construct a connection object from yaml file.
847849
848850
:param source: The local yaml source of a connection object. Must be either a

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ class CustomMonitoringSignal(RestTranslatableMixin):
10161016
calculate the custom metrics.
10171017
:paramtype component_id: str
10181018
:keyword connection: Specify connection with environment variables and secret configs.
1019-
:paramtype connection: Optional[~azure.ai.ml.entities.Connection]
1019+
:paramtype connection: Optional[~azure.ai.ml.entities.WorkspaceConnection]
10201020
:keyword alert_enabled: Whether or not to enable alerts for the signal. Defaults to True.
10211021
:paramtype alert_enabled: bool
10221022
:keyword properties: A dictionary of custom properties for the signal.

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_workspace/connections/connection_subtypes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
ServerlessConnectionSchema,
4040
)
4141
from .one_lake_artifacts import OneLakeConnectionArtifact
42-
from .connection import Connection
42+
from .workspace_connection import WorkspaceConnection
4343

4444

4545
# Dev notes: Any new classes require modifying the elif chains in the following functions in the
4646
# WorkspaceConnection parent class: _from_rest_object, _get_entity_class_from_type, _get_schema_class_from_type
4747

4848

4949
@experimental
50-
class AzureBlobStoreConnection(Connection):
50+
class AzureBlobStoreConnection(WorkspaceConnection):
5151
"""A connection to an Azure Blob Store.
5252
5353
:param name: Name of the connection.
@@ -152,7 +152,7 @@ def account_name(self, value: str) -> None:
152152
# Due to this, we construct the target internally by composing more inputs
153153
# that are more user-accessible.
154154
@experimental
155-
class MicrosoftOneLakeConnection(Connection):
155+
class MicrosoftOneLakeConnection(WorkspaceConnection):
156156
"""A connection to a Microsoft One Lake. Connections of this type
157157
are further specified by their artifact class type, although
158158
the number of artifact classes is currently limited.
@@ -236,7 +236,7 @@ def _construct_target(cls, endpoint: str, workspace: str, artifact: OneLakeConne
236236

237237
# Not experimental since users should never see this,
238238
# No need to add an extra warning.
239-
class ApiOrAadConnection(Connection):
239+
class ApiOrAadConnection(WorkspaceConnection):
240240
"""Internal parent class for all connections that accept either an api key or
241241
entra ID as credentials. Entra ID credentials are implicitly assumed if no api key is provided.
242242

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_workspace/connections/connection.py renamed to sdk/ml/azure-ai-ml/azure/ai/ml/entities/_workspace/connections/workspace_connection.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
AADAuthTypeWorkspaceConnectionProperties,
2020
)
2121

22-
from azure.ai.ml._schema.workspace.connections.connection import ConnectionSchema
22+
from azure.ai.ml._schema.workspace.connections.workspace_connection import WorkspaceConnectionSchema
2323
from azure.ai.ml._utils._experimental import experimental
2424
from azure.ai.ml._utils.utils import _snake_to_camel, camel_to_snake, dump_yaml_to_file
2525
from azure.ai.ml.constants._common import (
@@ -73,7 +73,7 @@
7373
# In the rest client enum defined at _azure_machine_learning_services_enums.ConnectionCategory.
7474
# We avoid directly referencing it in the docs to avoid restclient references.
7575
@experimental
76-
class Connection(Resource):
76+
class WorkspaceConnection(Resource):
7777
"""Azure ML connection provides a secure way to store authentication and configuration information needed
7878
to connect and interact with the external resources.
7979
@@ -138,8 +138,8 @@ def __init__(
138138
# The additional undocumented kwarg "strict_typing" turns the warning into a value error.
139139
from_child = kwargs.pop("from_child", False)
140140
strict_typing = kwargs.pop("strict_typing", False)
141-
correct_class = Connection._get_entity_class_from_type(type)
142-
if not from_child and correct_class != Connection:
141+
correct_class = WorkspaceConnection._get_entity_class_from_type(type)
142+
if not from_child and correct_class != WorkspaceConnection:
143143
if strict_typing:
144144
raise ValueError(
145145
f"Cannot instantiate a base Connection with a type of {type}. "
@@ -360,7 +360,7 @@ def _load(
360360
yaml_path: Optional[Union[PathLike, str]] = None,
361361
params_override: Optional[list] = None,
362362
**kwargs: Any,
363-
) -> "Connection":
363+
) -> "WorkspaceConnection":
364364
data = data or {}
365365
params_override = params_override or []
366366
context = {
@@ -370,23 +370,23 @@ def _load(
370370
return cls._load_from_dict(data=data, context=context, **kwargs)
371371

372372
@classmethod
373-
def _load_from_dict(cls, data: Dict, context: Dict, **kwargs: Any) -> "Connection":
373+
def _load_from_dict(cls, data: Dict, context: Dict, **kwargs: Any) -> "WorkspaceConnection":
374374
conn_type = data["type"] if "type" in data else None
375375
schema_class = cls._get_schema_class_from_type(conn_type)
376-
loaded_data: Connection = load_from_dict(schema_class, data, context, **kwargs)
376+
loaded_data: WorkspaceConnection = load_from_dict(schema_class, data, context, **kwargs)
377377
return loaded_data
378378

379379
def _to_dict(self) -> Dict:
380380
# pylint: disable=no-member
381-
schema_class = Connection._get_schema_class_from_type(self.type)
381+
schema_class = WorkspaceConnection._get_schema_class_from_type(self.type)
382382
# Not sure what this pylint complaint was about, probably due to the polymorphic
383383
# tricks at play. Disabling since testing indicates no issue.
384384
# pylint: disable-next=missing-kwoa
385385
res: dict = schema_class(context={BASE_PATH_CONTEXT_KEY: "./"}).dump(self)
386386
return res
387387

388388
@classmethod
389-
def _from_rest_object(cls, rest_obj: RestWorkspaceConnection) -> Optional["Connection"]:
389+
def _from_rest_object(cls, rest_obj: RestWorkspaceConnection) -> Optional["WorkspaceConnection"]:
390390
if not rest_obj:
391391
return None
392392

@@ -420,7 +420,7 @@ def _from_rest_object(cls, rest_obj: RestWorkspaceConnection) -> Optional["Conne
420420
# No default in pop, this should fail if we somehow don't get a resource ID
421421
rest_kwargs["ai_services_resource_id"] = rest_kwargs.pop(camel_to_snake(CONNECTION_RESOURCE_ID_KEY))
422422
connection = conn_class(**rest_kwargs)
423-
return cast(Optional["Connection"], connection)
423+
return cast(Optional["WorkspaceConnection"], connection)
424424

425425
def _validate(self) -> str:
426426
return str(self.name)
@@ -544,7 +544,7 @@ def _get_entity_class_from_type(cls, type: str) -> Type:
544544

545545
conn_type = _snake_to_camel(type).lower()
546546
if conn_type is None:
547-
return Connection
547+
return WorkspaceConnection
548548

549549
# Connection categories don't perfectly follow perfect camel casing, so lower
550550
# case everything to avoid problems.
@@ -563,7 +563,7 @@ def _get_entity_class_from_type(cls, type: str) -> Type:
563563
_snake_to_camel(ConnectionTypes.AZURE_AI_SERVICES).lower(): AzureAIServicesConnection,
564564
ConnectionTypes.AI_SERVICES_REST_PLACEHOLDER.lower(): AzureAIServicesConnection,
565565
}
566-
return CONNECTION_CATEGORY_TO_SUBCLASS_MAP.get(conn_type, Connection)
566+
return CONNECTION_CATEGORY_TO_SUBCLASS_MAP.get(conn_type, WorkspaceConnection)
567567

568568
@classmethod
569569
def _get_entity_class_from_rest_obj(cls, rest_obj: RestWorkspaceConnection) -> Type:
@@ -580,7 +580,7 @@ def _get_entity_class_from_rest_obj(cls, rest_obj: RestWorkspaceConnection) -> T
580580
conn_type = rest_obj.properties.category
581581
conn_type = _snake_to_camel(conn_type).lower()
582582
if conn_type is None:
583-
return Connection
583+
return WorkspaceConnection
584584

585585
# Imports are done here to avoid circular imports on load.
586586
from .connection_subtypes import (
@@ -599,7 +599,7 @@ def _get_entity_class_from_rest_obj(cls, rest_obj: RestWorkspaceConnection) -> T
599599
return AzureContentSafetyConnection
600600
if kind == CognitiveServiceKinds.SPEECH.lower():
601601
return AzureSpeechServicesConnection
602-
return Connection
602+
return WorkspaceConnection
603603

604604
return cls._get_entity_class_from_type(type=conn_type)
605605

@@ -616,7 +616,7 @@ def _get_schema_class_from_type(cls, conn_type: Optional[str]) -> Type:
616616
:rtype: Type
617617
"""
618618
if conn_type is None:
619-
return ConnectionSchema
619+
return WorkspaceConnectionSchema
620620
entity_class = cls._get_entity_class_from_type(conn_type)
621621
return entity_class._get_schema_class()
622622

@@ -640,4 +640,4 @@ def _get_schema_class(cls) -> Type:
640640
:return: The appropriate schema class to use with this entity class.
641641
:rtype: Type
642642
"""
643-
return ConnectionSchema
643+
return WorkspaceConnectionSchema

0 commit comments

Comments
 (0)