1010from functools import singledispatch
1111from itertools import product
1212from pathlib import Path
13- from typing import Any , Dict , Optional , Tuple , TypeVar , Union
13+ from typing import Any , Optional , Tuple , TypeVar , Union
1414
1515from azure .ai .ml ._azure_environments import (
1616 CloudArgumentKeys ,
2424from azure .ai .ml ._restclient .v2020_09_01_dataplanepreview import (
2525 AzureMachineLearningWorkspaces as ServiceClient092020DataplanePreview ,
2626)
27- from azure .ai .ml ._restclient .v2022_02_01_preview import (
28- AzureMachineLearningWorkspaces as ServiceClient022022Preview ,
29- )
30- from azure .ai .ml ._restclient .v2022_05_01 import (
31- AzureMachineLearningWorkspaces as ServiceClient052022 ,
32- )
33- from azure .ai .ml ._restclient .v2022_10_01 import (
34- AzureMachineLearningWorkspaces as ServiceClient102022 ,
35- )
36- from azure .ai .ml ._restclient .v2022_10_01_preview import (
37- AzureMachineLearningWorkspaces as ServiceClient102022Preview ,
38- )
39- from azure .ai .ml ._restclient .v2023_02_01_preview import (
40- AzureMachineLearningWorkspaces as ServiceClient022023Preview ,
41- )
42- from azure .ai .ml ._restclient .v2023_04_01 import (
43- AzureMachineLearningWorkspaces as ServiceClient042023 ,
44- )
45- from azure .ai .ml ._restclient .v2023_04_01_preview import (
46- AzureMachineLearningWorkspaces as ServiceClient042023Preview ,
47- )
48- from azure .ai .ml ._restclient .v2023_06_01_preview import (
49- AzureMachineLearningWorkspaces as ServiceClient062023Preview ,
50- )
51- from azure .ai .ml ._restclient .v2023_08_01_preview import (
52- AzureMachineLearningWorkspaces as ServiceClient082023Preview ,
53- )
27+ from azure .ai .ml ._restclient .v2022_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022022Preview
28+ from azure .ai .ml ._restclient .v2022_05_01 import AzureMachineLearningWorkspaces as ServiceClient052022
29+ from azure .ai .ml ._restclient .v2022_10_01 import AzureMachineLearningWorkspaces as ServiceClient102022
30+ from azure .ai .ml ._restclient .v2022_10_01_preview import AzureMachineLearningWorkspaces as ServiceClient102022Preview
31+ from azure .ai .ml ._restclient .v2023_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022023Preview
32+ from azure .ai .ml ._restclient .v2023_04_01 import AzureMachineLearningWorkspaces as ServiceClient042023
33+ from azure .ai .ml ._restclient .v2023_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient042023Preview
34+ from azure .ai .ml ._restclient .v2023_06_01_preview import AzureMachineLearningWorkspaces as ServiceClient062023Preview
35+ from azure .ai .ml ._restclient .v2023_08_01_preview import AzureMachineLearningWorkspaces as ServiceClient082023Preview
5436
5537# Same object, but was renamed starting in v2023_08_01_preview
5638from azure .ai .ml ._restclient .v2023_10_01 import AzureMachineLearningServices as ServiceClient102023
57- from azure .ai .ml ._restclient .v2024_01_01_preview import (
58- AzureMachineLearningWorkspaces as ServiceClient012024Preview ,
59- )
60- from azure .ai .ml ._restclient .v2024_04_01_preview import (
61- AzureMachineLearningWorkspaces as ServiceClient042024Preview ,
62- )
63- from azure .ai .ml ._restclient .v2024_07_01_preview import (
64- AzureMachineLearningWorkspaces as ServiceClient072024Preview ,
65- )
66- from azure .ai .ml ._restclient .v2024_10_01_preview import (
67- AzureMachineLearningWorkspaces as ServiceClient102024Preview ,
68- )
39+ from azure .ai .ml ._restclient .v2024_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012024Preview
40+ from azure .ai .ml ._restclient .v2024_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient042024Preview
41+ from azure .ai .ml ._restclient .v2024_07_01_preview import AzureMachineLearningWorkspaces as ServiceClient072024Preview
42+ from azure .ai .ml ._restclient .v2024_10_01_preview import AzureMachineLearningWorkspaces as ServiceClient102024Preview
6943from azure .ai .ml ._restclient .workspace_dataplane import (
7044 AzureMachineLearningWorkspaces as ServiceClientWorkspaceDataplane ,
7145)
72- from azure .ai .ml ._scope_dependent_operations import (
73- OperationConfig ,
74- OperationsContainer ,
75- OperationScope ,
76- )
77- from azure .ai .ml ._telemetry .logging_handler import get_appinsights_log_handler
46+ from azure .ai .ml ._scope_dependent_operations import OperationConfig , OperationsContainer , OperationScope
47+ from azure .ai .ml ._telemetry .logging_handler import configure_appinsights_logging
7848from azure .ai .ml ._user_agent import USER_AGENT
7949from azure .ai .ml ._utils ._experimental import experimental
8050from azure .ai .ml ._utils ._http_utils import HttpPipeline
12696 WorkspaceConnectionsOperations ,
12797 WorkspaceOperations ,
12898)
99+ from azure .ai .ml .operations ._capability_hosts_operations import CapabilityHostsOperations
129100from azure .ai .ml .operations ._code_operations import CodeOperations
130101from azure .ai .ml .operations ._feature_set_operations import FeatureSetOperations
131102from azure .ai .ml .operations ._feature_store_entity_operations import FeatureStoreEntityOperations
132103from azure .ai .ml .operations ._feature_store_operations import FeatureStoreOperations
133104from azure .ai .ml .operations ._local_deployment_helper import _LocalDeploymentHelper
134105from azure .ai .ml .operations ._local_endpoint_helper import _LocalEndpointHelper
135106from azure .ai .ml .operations ._schedule_operations import ScheduleOperations
136- from azure .ai .ml .operations ._capability_hosts_operations import CapabilityHostsOperations
137- from azure .ai .ml .operations ._workspace_outbound_rule_operations import (
138- WorkspaceOutboundRuleOperations ,
139- )
107+ from azure .ai .ml .operations ._workspace_outbound_rule_operations import WorkspaceOutboundRuleOperations
140108from azure .core .credentials import TokenCredential
141109from azure .core .polling import LROPoller
142110
@@ -316,12 +284,11 @@ def __init__(
316284
317285 user_agent = kwargs .get ("user_agent" , None )
318286
319- app_insights_handler : Tuple = get_appinsights_log_handler (
287+ configure_appinsights_logging (
320288 user_agent ,
321289 ** {"properties" : properties },
322290 enable_telemetry = self ._operation_config .enable_telemetry ,
323291 )
324- app_insights_handler_kwargs : Dict [str , Tuple ] = {"app_insights_handler" : app_insights_handler }
325292
326293 base_url = _get_base_url_from_metadata (cloud_name = cloud_name , is_local_mfe = True )
327294 self ._base_url = base_url
@@ -330,7 +297,7 @@ def __init__(
330297 self ._operation_container = OperationsContainer ()
331298
332299 # kwargs related to operations alone not all kwargs passed to MLClient are needed by operations
333- ops_kwargs = app_insights_handler_kwargs
300+ ops_kwargs = {}
334301 if base_url :
335302 ops_kwargs ["enforce_https" ] = _is_https_url (base_url )
336303
@@ -532,7 +499,6 @@ def __init__(
532499 self ._credential ,
533500 requests_pipeline = self ._requests_pipeline ,
534501 dataplane_client = self ._service_client_workspace_dataplane ,
535- ** app_insights_handler_kwargs ,
536502 )
537503 self ._operation_container .add (AzureMLResourceType .WORKSPACE , self ._workspaces ) # type: ignore[arg-type]
538504
@@ -550,7 +516,6 @@ def __init__(
550516 self ._service_client_10_2022_preview ,
551517 self ._operation_container ,
552518 self ._credential ,
553- ** app_insights_handler_kwargs , # type: ignore[arg-type]
554519 )
555520 self ._operation_container .add (AzureMLResourceType .REGISTRY , self ._registries ) # type: ignore[arg-type]
556521
@@ -582,7 +547,6 @@ def __init__(
582547 self ._operation_config ,
583548 self ._service_client_08_2023_preview ,
584549 self ._service_client_04_2024_preview ,
585- ** app_insights_handler_kwargs , # type: ignore[arg-type]
586550 )
587551 self ._operation_container .add (AzureMLResourceType .COMPUTE , self ._compute )
588552 self ._datastores = DatastoreOperations (
@@ -608,7 +572,6 @@ def __init__(
608572 workspace_rg = self ._ws_rg ,
609573 workspace_sub = self ._ws_sub ,
610574 registry_reference = registry_reference ,
611- ** app_insights_handler_kwargs , # type: ignore[arg-type]
612575 )
613576 # Evaluators
614577 self ._evaluators = EvaluatorOperations (
@@ -626,7 +589,6 @@ def __init__(
626589 workspace_rg = self ._ws_rg ,
627590 workspace_sub = self ._ws_sub ,
628591 registry_reference = registry_reference ,
629- ** app_insights_handler_kwargs , # type: ignore[arg-type]
630592 )
631593
632594 self ._operation_container .add (AzureMLResourceType .MODEL , self ._models )
@@ -770,7 +732,6 @@ def __init__(
770732 self ._service_client_10_2024_preview ,
771733 self ._operation_container ,
772734 self ._credential ,
773- ** app_insights_handler_kwargs , # type: ignore[arg-type]
774735 )
775736
776737 self ._featuresets = FeatureSetOperations (
0 commit comments