Skip to content

Commit 347b6cb

Browse files
sagarsumantSagar Sumant
and
Sagar Sumant
authored
Format files touched by maap-finetuning-job changes. (Azure#38708)
* Format files. * Fix linting error. * Fix. * Fix as per black. --------- Co-authored-by: Sagar Sumant <[email protected]>
1 parent 75b4da9 commit 347b6cb

File tree

5 files changed

+175
-57
lines changed

5 files changed

+175
-57
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py

+55-20
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,56 @@
2424
from 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 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
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+
)
3654

3755
# Same object, but was renamed starting in v2023_08_01_preview
3856
from azure.ai.ml._restclient.v2023_10_01 import AzureMachineLearningServices as ServiceClient102023
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
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+
)
4369
from azure.ai.ml._restclient.workspace_dataplane import (
4470
AzureMachineLearningWorkspaces as ServiceClientWorkspaceDataplane,
4571
)
46-
from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationsContainer, OperationScope
72+
from azure.ai.ml._scope_dependent_operations import (
73+
OperationConfig,
74+
OperationsContainer,
75+
OperationScope,
76+
)
4777
from azure.ai.ml._telemetry.logging_handler import get_appinsights_log_handler
4878
from azure.ai.ml._user_agent import USER_AGENT
4979
from azure.ai.ml._utils._experimental import experimental
@@ -102,7 +132,9 @@
102132
from azure.ai.ml.operations._local_deployment_helper import _LocalDeploymentHelper
103133
from azure.ai.ml.operations._local_endpoint_helper import _LocalEndpointHelper
104134
from azure.ai.ml.operations._schedule_operations import ScheduleOperations
105-
from azure.ai.ml.operations._workspace_outbound_rule_operations import WorkspaceOutboundRuleOperations
135+
from azure.ai.ml.operations._workspace_outbound_rule_operations import (
136+
WorkspaceOutboundRuleOperations,
137+
)
106138
from azure.core.credentials import TokenCredential
107139
from azure.core.polling import LROPoller
108140

@@ -250,7 +282,10 @@ def __init__(
250282
resource_group_name,
251283
subscription_id,
252284
) = get_registry_client(
253-
self._credential, registry_name if registry_name else registry_reference, workspace_location, **kwargs
285+
self._credential,
286+
registry_name if registry_name else registry_reference,
287+
workspace_location,
288+
**kwargs,
254289
)
255290
if not workspace_name:
256291
workspace_name = workspace_reference
@@ -586,15 +621,15 @@ def __init__(
586621
self._code = CodeOperations(
587622
self._ws_operation_scope if registry_reference else self._operation_scope,
588623
self._operation_config,
589-
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023,
624+
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023),
590625
self._datastores,
591626
**ops_kwargs, # type: ignore[arg-type]
592627
)
593628
self._operation_container.add(AzureMLResourceType.CODE, self._code)
594629
self._environments = EnvironmentOperations(
595630
self._ws_operation_scope if registry_reference else self._operation_scope,
596631
self._operation_config,
597-
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview,
632+
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview),
598633
self._operation_container,
599634
**ops_kwargs, # type: ignore[arg-type]
600635
)
@@ -648,7 +683,7 @@ def __init__(
648683
self._data = DataOperations(
649684
self._operation_scope,
650685
self._operation_config,
651-
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview,
686+
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview),
652687
self._service_client_01_2024_preview,
653688
self._datastores,
654689
requests_pipeline=self._requests_pipeline,
@@ -659,7 +694,7 @@ def __init__(
659694
self._components = ComponentOperations(
660695
self._operation_scope,
661696
self._operation_config,
662-
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_01_2024_preview,
697+
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_01_2024_preview),
663698
self._operation_container,
664699
self._preflight,
665700
**ops_kwargs, # type: ignore[arg-type]

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/_input_output_helpers.py

+49-18
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,61 @@
66
import re
77
from typing import Any, Dict, Optional, Union
88

9-
from azure.ai.ml._restclient.v2023_04_01_preview.models import CustomModelJobInput as RestCustomModelJobInput
10-
from azure.ai.ml._restclient.v2023_04_01_preview.models import CustomModelJobOutput as RestCustomModelJobOutput
9+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
10+
CustomModelJobInput as RestCustomModelJobInput,
11+
)
12+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
13+
CustomModelJobOutput as RestCustomModelJobOutput,
14+
)
1115
from azure.ai.ml._restclient.v2023_04_01_preview.models import InputDeliveryMode
1216
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobInput as RestJobInput
1317
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobInputType
1418
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobOutput as RestJobOutput
1519
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobOutputType, LiteralJobInput
16-
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLFlowModelJobInput as RestMLFlowModelJobInput
17-
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLFlowModelJobOutput as RestMLFlowModelJobOutput
18-
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLTableJobInput as RestMLTableJobInput
19-
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLTableJobOutput as RestMLTableJobOutput
20+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
21+
MLFlowModelJobInput as RestMLFlowModelJobInput,
22+
)
23+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
24+
MLFlowModelJobOutput as RestMLFlowModelJobOutput,
25+
)
26+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
27+
MLTableJobInput as RestMLTableJobInput,
28+
)
29+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
30+
MLTableJobOutput as RestMLTableJobOutput,
31+
)
2032
from azure.ai.ml._restclient.v2023_04_01_preview.models import OutputDeliveryMode
21-
from azure.ai.ml._restclient.v2023_04_01_preview.models import TritonModelJobInput as RestTritonModelJobInput
22-
from azure.ai.ml._restclient.v2023_04_01_preview.models import TritonModelJobOutput as RestTritonModelJobOutput
23-
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFileJobInput as RestUriFileJobInput
24-
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFileJobOutput as RestUriFileJobOutput
25-
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFolderJobInput as RestUriFolderJobInput
26-
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFolderJobOutput as RestUriFolderJobOutput
33+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
34+
TritonModelJobInput as RestTritonModelJobInput,
35+
)
36+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
37+
TritonModelJobOutput as RestTritonModelJobOutput,
38+
)
39+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
40+
UriFileJobInput as RestUriFileJobInput,
41+
)
42+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
43+
UriFileJobOutput as RestUriFileJobOutput,
44+
)
45+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
46+
UriFolderJobInput as RestUriFolderJobInput,
47+
)
48+
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
49+
UriFolderJobOutput as RestUriFolderJobOutput,
50+
)
2751
from azure.ai.ml._utils.utils import is_data_binding_expression
2852
from azure.ai.ml.constants import AssetTypes, InputOutputModes, JobType
2953
from azure.ai.ml.constants._component import IOConstants
3054
from azure.ai.ml.entities._inputs_outputs import Input, Output
3155
from azure.ai.ml.entities._job.input_output_entry import InputOutputEntry
3256
from azure.ai.ml.entities._util import normalize_job_input_output_type
33-
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, JobException, ValidationErrorType, ValidationException
57+
from azure.ai.ml.exceptions import (
58+
ErrorCategory,
59+
ErrorTarget,
60+
JobException,
61+
ValidationErrorType,
62+
ValidationException,
63+
)
3464

3565
INPUT_MOUNT_MAPPING_FROM_REST = {
3666
InputDeliveryMode.READ_WRITE_MOUNT: InputOutputModes.RW_MOUNT,
@@ -175,7 +205,8 @@ def validate_pipeline_input_key_characters(key: str) -> None:
175205
# so a valid pipeline key is: ^{single_key}([.]{single_key})*$
176206
if re.match(IOConstants.VALID_KEY_PATTERN, key) is None:
177207
msg = (
178-
"Pipeline input key name {} must be composed letters, numbers, and underscores with optional split by dots."
208+
"Pipeline input key name {} must be composed letters, numbers, and underscores with optional "
209+
"split by dots."
179210
)
180211
raise ValidationException(
181212
message=msg.format(key),
@@ -229,7 +260,7 @@ def to_rest_dataset_literal_inputs(
229260
if input_value.type in target_cls_dict:
230261
input_data = target_cls_dict[input_value.type](
231262
uri=input_value.path,
232-
mode=INPUT_MOUNT_MAPPING_TO_REST[input_value.mode.lower()] if input_value.mode else None,
263+
mode=(INPUT_MOUNT_MAPPING_TO_REST[input_value.mode.lower()] if input_value.mode else None),
233264
)
234265

235266
else:
@@ -292,7 +323,7 @@ def from_rest_inputs_to_dataset_literal(inputs: Dict[str, RestJobInput]) -> Dict
292323
input_data = Input(
293324
type=type_transfer_dict[input_value.job_input_type],
294325
path=path,
295-
mode=INPUT_MOUNT_MAPPING_FROM_REST[input_value.mode] if input_value.mode else None,
326+
mode=(INPUT_MOUNT_MAPPING_FROM_REST[input_value.mode] if input_value.mode else None),
296327
path_on_compute=sourcePathOnCompute,
297328
)
298329
elif input_value.job_input_type in (JobInputType.LITERAL, JobInputType.LITERAL):
@@ -337,7 +368,7 @@ def to_rest_data_outputs(outputs: Optional[Dict]) -> Dict[str, RestJobOutput]:
337368
asset_name=output_value.name,
338369
asset_version=output_value.version,
339370
uri=output_value.path,
340-
mode=OUTPUT_MOUNT_MAPPING_TO_REST[output_value.mode.lower()] if output_value.mode else None,
371+
mode=(OUTPUT_MOUNT_MAPPING_TO_REST[output_value.mode.lower()] if output_value.mode else None),
341372
pathOnCompute=getattr(output_value, "path_on_compute", None),
342373
description=output_value.description,
343374
)
@@ -380,7 +411,7 @@ def from_rest_data_outputs(outputs: Dict[str, RestJobOutput]) -> Dict[str, Outpu
380411
from_rest_outputs[output_name] = Output(
381412
type=output_type_mapping[output_value.job_output_type],
382413
path=output_value.uri,
383-
mode=OUTPUT_MOUNT_MAPPING_FROM_REST[output_value.mode] if output_value.mode else None,
414+
mode=(OUTPUT_MOUNT_MAPPING_FROM_REST[output_value.mode] if output_value.mode else None),
384415
path_on_compute=sourcePathOnCompute,
385416
description=output_value.description,
386417
name=output_value.asset_name,

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/finetuning/custom_model_finetuning_job.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
FineTuningJob as RestFineTuningJob,
1313
JobBase as RestJobBase,
1414
)
15-
from azure.ai.ml.entities._job._input_output_helpers import from_rest_data_outputs, to_rest_data_outputs
15+
from azure.ai.ml.entities._job._input_output_helpers import (
16+
from_rest_data_outputs,
17+
to_rest_data_outputs,
18+
)
1619
from azure.ai.ml.entities._inputs_outputs import Input
1720
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY
1821
from azure.ai.ml.entities._job.finetuning.finetuning_vertical import FineTuningVertical
@@ -101,7 +104,9 @@ def _to_dict(self) -> Dict: # pylint: disable=arguments-differ
101104
:return: dictionary representation of the object.
102105
:rtype: typing.Dict
103106
"""
104-
from azure.ai.ml._schema._finetuning.custom_model_finetuning import CustomModelFineTuningSchema
107+
from azure.ai.ml._schema._finetuning.custom_model_finetuning import (
108+
CustomModelFineTuningSchema,
109+
)
105110

106111
schema_dict: dict = {}
107112
# TODO: Combeback to this later for FineTuningJob in pipeline
@@ -196,7 +201,9 @@ def _load_from_dict(
196201
:return: CustomModelFineTuningJob object.
197202
:rtype: CustomModelFineTuningJob
198203
"""
199-
from azure.ai.ml._schema._finetuning.custom_model_finetuning import CustomModelFineTuningSchema
204+
from azure.ai.ml._schema._finetuning.custom_model_finetuning import (
205+
CustomModelFineTuningSchema,
206+
)
200207

201208
# TODO: Combeback to this later - Pipeline part.
202209
# from azure.ai.ml._schema.pipeline.automl_node import AutoMLClassificationNodeSchema

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/job.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobBase, JobService
1818
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobType as RestJobType
1919
from azure.ai.ml._restclient.v2024_01_01_preview.models import JobBase as JobBase_2401
20-
from azure.ai.ml._restclient.v2024_01_01_preview.models import JobType as RestJobType_20240101Preview
20+
from azure.ai.ml._restclient.v2024_01_01_preview.models import (
21+
JobType as RestJobType_20240101Preview,
22+
)
2123
from azure.ai.ml._utils._html_utils import make_link, to_html
2224
from azure.ai.ml._utils.utils import dump_yaml_to_file
23-
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PARAMS_OVERRIDE_KEY, CommonYamlFields
25+
from azure.ai.ml.constants._common import (
26+
BASE_PATH_CONTEXT_KEY,
27+
PARAMS_OVERRIDE_KEY,
28+
CommonYamlFields,
29+
)
2430
from azure.ai.ml.constants._compute import ComputeType
2531
from azure.ai.ml.constants._job.job import JobServices, JobType
2632
from azure.ai.ml.entities._mixins import TelemetryMixin
@@ -191,7 +197,10 @@ def _repr_html_(self) -> str:
191197
if self.studio_url:
192198
info.update(
193199
[
194-
("Details Page", make_link(self.studio_url, "Link to Azure Machine Learning studio")),
200+
(
201+
"Details Page",
202+
make_link(self.studio_url, "Link to Azure Machine Learning studio"),
203+
),
195204
]
196205
)
197206
res: str = to_html(info)
@@ -334,7 +343,10 @@ def _from_rest_object( # pylint: disable=too-many-return-statements
334343
except Exception as ex:
335344
error_message = json.dumps(obj.as_dict(), indent=2) if obj else None
336345
module_logger.info(
337-
"Exception: %s.\n%s\nUnable to parse the job resource: %s.\n", ex, traceback.format_exc(), error_message
346+
"Exception: %s.\n%s\nUnable to parse the job resource: %s.\n",
347+
ex,
348+
traceback.format_exc(),
349+
error_message,
338350
)
339351
raise JobParsingError(
340352
message=str(ex),

0 commit comments

Comments
 (0)