16
16
from azure .core .polling import LROPoller
17
17
18
18
from azure .ai .ml ._azure_environments import (
19
+ CloudArgumentKeys ,
19
20
_get_base_url_from_metadata ,
20
21
_get_cloud_information_from_metadata ,
21
22
_get_default_cloud_name ,
22
23
_get_registry_discovery_endpoint_from_metadata ,
23
24
_set_cloud ,
25
+ _add_cloud_to_environments ,
24
26
)
25
27
from azure .ai .ml ._file_utils .file_utils import traverse_up_path_and_find_file
26
- from azure .ai .ml ._restclient .registry_discovery import AzureMachineLearningWorkspaces as ServiceClientRegistryDiscovery
28
+ from azure .ai .ml ._restclient .registry_discovery import (
29
+ AzureMachineLearningWorkspaces as ServiceClientRegistryDiscovery ,
30
+ )
27
31
from azure .ai .ml ._restclient .v2020_09_01_dataplanepreview import (
28
32
AzureMachineLearningWorkspaces as ServiceClient092020DataplanePreview ,
29
33
)
30
- from azure .ai .ml ._restclient .v2022_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012022Preview
31
- from azure .ai .ml ._restclient .v2022_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022022Preview
32
- from azure .ai .ml ._restclient .v2022_05_01 import AzureMachineLearningWorkspaces as ServiceClient052022
33
- from azure .ai .ml ._restclient .v2022_10_01 import AzureMachineLearningWorkspaces as ServiceClient102022
34
- from azure .ai .ml ._restclient .v2022_10_01_preview import AzureMachineLearningWorkspaces as ServiceClient102022Preview
35
- from azure .ai .ml ._restclient .v2022_12_01_preview import AzureMachineLearningWorkspaces as ServiceClient122022Preview
36
- from azure .ai .ml ._restclient .v2023_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022023Preview
37
- from azure .ai .ml ._scope_dependent_operations import OperationConfig , OperationsContainer , OperationScope
34
+ from azure .ai .ml ._restclient .v2022_01_01_preview import (
35
+ AzureMachineLearningWorkspaces as ServiceClient012022Preview ,
36
+ )
37
+ from azure .ai .ml ._restclient .v2022_02_01_preview import (
38
+ AzureMachineLearningWorkspaces as ServiceClient022022Preview ,
39
+ )
40
+ from azure .ai .ml ._restclient .v2022_05_01 import (
41
+ AzureMachineLearningWorkspaces as ServiceClient052022 ,
42
+ )
43
+ from azure .ai .ml ._restclient .v2022_10_01 import (
44
+ AzureMachineLearningWorkspaces as ServiceClient102022 ,
45
+ )
46
+ from azure .ai .ml ._restclient .v2022_10_01_preview import (
47
+ AzureMachineLearningWorkspaces as ServiceClient102022Preview ,
48
+ )
49
+ from azure .ai .ml ._restclient .v2022_12_01_preview import (
50
+ AzureMachineLearningWorkspaces as ServiceClient122022Preview ,
51
+ )
52
+ from azure .ai .ml ._restclient .v2023_02_01_preview import (
53
+ AzureMachineLearningWorkspaces as ServiceClient022023Preview ,
54
+ )
55
+ from azure .ai .ml ._scope_dependent_operations import (
56
+ OperationConfig ,
57
+ OperationsContainer ,
58
+ OperationScope ,
59
+ )
38
60
39
61
# from azure.ai.ml._telemetry.logging_handler import get_appinsights_log_handler
40
62
from azure .ai .ml ._user_agent import USER_AGENT
@@ -166,7 +188,21 @@ def __init__(
166
188
show_progress = kwargs .pop ("show_progress" , True )
167
189
self ._operation_config = OperationConfig (show_progress = show_progress )
168
190
169
- cloud_name = kwargs .get ("cloud" , _get_default_cloud_name ())
191
+ if "cloud" in kwargs :
192
+ cloud_name = kwargs ["cloud" ]
193
+ if CloudArgumentKeys .CLOUD_METADATA in kwargs :
194
+ try :
195
+ _add_cloud_to_environments (kwargs )
196
+ except AttributeError as e :
197
+ module_logger .debug ("Cloud already exists: %s" , e )
198
+ except LookupError as e :
199
+ module_logger .debug ("Missing keyword: %s" , e )
200
+ else :
201
+ module_logger .debug ("%s key not found in kwargs" , CloudArgumentKeys .CLOUD_METADATA )
202
+ else :
203
+ module_logger .debug ("cloud key not found in kwargs" )
204
+ cloud_name = _get_default_cloud_name ()
205
+
170
206
self ._cloud = cloud_name
171
207
_set_cloud (cloud_name )
172
208
if "cloud" not in kwargs :
@@ -187,7 +223,10 @@ def __init__(
187
223
credential = self ._credential , base_url = base_url , ** kwargs_registry
188
224
)
189
225
registry_discovery = RegistryDiscovery (
190
- self ._credential , registry_name , self ._service_client_registry_discovery_client , ** kwargs_registry
226
+ self ._credential ,
227
+ registry_name ,
228
+ self ._service_client_registry_discovery_client ,
229
+ ** kwargs_registry ,
191
230
)
192
231
self ._service_client_10_2021_dataplanepreview = registry_discovery .get_registry_service_client ()
193
232
subscription_id = registry_discovery .subscription_id
@@ -802,7 +841,15 @@ def create_or_update(
802
841
# R = valid inputs/outputs for begin_create_or_update
803
842
# Each entry here requires a registered _begin_create_or_update function below
804
843
R = TypeVar (
805
- "R" , Workspace , Registry , Compute , OnlineDeployment , OnlineEndpoint , BatchDeployment , BatchEndpoint , JobSchedule
844
+ "R" ,
845
+ Workspace ,
846
+ Registry ,
847
+ Compute ,
848
+ OnlineDeployment ,
849
+ OnlineEndpoint ,
850
+ BatchDeployment ,
851
+ BatchEndpoint ,
852
+ JobSchedule ,
806
853
)
807
854
808
855
def begin_create_or_update (
0 commit comments