Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
75 changes: 55 additions & 20 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,56 @@
from azure.ai.ml._restclient.v2020_09_01_dataplanepreview import (
AzureMachineLearningWorkspaces as ServiceClient092020DataplanePreview,
)
from azure.ai.ml._restclient.v2022_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022022Preview
from azure.ai.ml._restclient.v2022_05_01 import AzureMachineLearningWorkspaces as ServiceClient052022
from azure.ai.ml._restclient.v2022_10_01 import AzureMachineLearningWorkspaces as ServiceClient102022
from azure.ai.ml._restclient.v2022_10_01_preview import AzureMachineLearningWorkspaces as ServiceClient102022Preview
from azure.ai.ml._restclient.v2023_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022023Preview
from azure.ai.ml._restclient.v2023_04_01 import AzureMachineLearningWorkspaces as ServiceClient042023
from azure.ai.ml._restclient.v2023_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient042023Preview
from azure.ai.ml._restclient.v2023_06_01_preview import AzureMachineLearningWorkspaces as ServiceClient062023Preview
from azure.ai.ml._restclient.v2023_08_01_preview import AzureMachineLearningWorkspaces as ServiceClient082023Preview
from azure.ai.ml._restclient.v2022_02_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient022022Preview,
)
from azure.ai.ml._restclient.v2022_05_01 import (
AzureMachineLearningWorkspaces as ServiceClient052022,
)
from azure.ai.ml._restclient.v2022_10_01 import (
AzureMachineLearningWorkspaces as ServiceClient102022,
)
from azure.ai.ml._restclient.v2022_10_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient102022Preview,
)
from azure.ai.ml._restclient.v2023_02_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient022023Preview,
)
from azure.ai.ml._restclient.v2023_04_01 import (
AzureMachineLearningWorkspaces as ServiceClient042023,
)
from azure.ai.ml._restclient.v2023_04_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient042023Preview,
)
from azure.ai.ml._restclient.v2023_06_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient062023Preview,
)
from azure.ai.ml._restclient.v2023_08_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient082023Preview,
)

# Same object, but was renamed starting in v2023_08_01_preview
from azure.ai.ml._restclient.v2023_10_01 import AzureMachineLearningServices as ServiceClient102023
from azure.ai.ml._restclient.v2024_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012024Preview
from azure.ai.ml._restclient.v2024_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient042024Preview
from azure.ai.ml._restclient.v2024_07_01_preview import AzureMachineLearningWorkspaces as ServiceClient072024Preview
from azure.ai.ml._restclient.v2024_10_01_preview import AzureMachineLearningWorkspaces as ServiceClient102024Preview
from azure.ai.ml._restclient.v2024_01_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient012024Preview,
)
from azure.ai.ml._restclient.v2024_04_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient042024Preview,
)
from azure.ai.ml._restclient.v2024_07_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient072024Preview,
)
from azure.ai.ml._restclient.v2024_10_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient102024Preview,
)
from azure.ai.ml._restclient.workspace_dataplane import (
AzureMachineLearningWorkspaces as ServiceClientWorkspaceDataplane,
)
from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationsContainer, OperationScope
from azure.ai.ml._scope_dependent_operations import (
OperationConfig,
OperationsContainer,
OperationScope,
)
from azure.ai.ml._telemetry.logging_handler import get_appinsights_log_handler
from azure.ai.ml._user_agent import USER_AGENT
from azure.ai.ml._utils._experimental import experimental
Expand Down Expand Up @@ -102,7 +132,9 @@
from azure.ai.ml.operations._local_deployment_helper import _LocalDeploymentHelper
from azure.ai.ml.operations._local_endpoint_helper import _LocalEndpointHelper
from azure.ai.ml.operations._schedule_operations import ScheduleOperations
from azure.ai.ml.operations._workspace_outbound_rule_operations import WorkspaceOutboundRuleOperations
from azure.ai.ml.operations._workspace_outbound_rule_operations import (
WorkspaceOutboundRuleOperations,
)
from azure.core.credentials import TokenCredential
from azure.core.polling import LROPoller

Expand Down Expand Up @@ -250,7 +282,10 @@ def __init__(
resource_group_name,
subscription_id,
) = get_registry_client(
self._credential, registry_name if registry_name else registry_reference, workspace_location, **kwargs
self._credential,
registry_name if registry_name else registry_reference,
workspace_location,
**kwargs,
)
if not workspace_name:
workspace_name = workspace_reference
Expand Down Expand Up @@ -586,15 +621,15 @@ def __init__(
self._code = CodeOperations(
self._ws_operation_scope if registry_reference else self._operation_scope,
self._operation_config,
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023,
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023),
self._datastores,
**ops_kwargs, # type: ignore[arg-type]
)
self._operation_container.add(AzureMLResourceType.CODE, self._code)
self._environments = EnvironmentOperations(
self._ws_operation_scope if registry_reference else self._operation_scope,
self._operation_config,
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview,
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview),
self._operation_container,
**ops_kwargs, # type: ignore[arg-type]
)
Expand Down Expand Up @@ -648,7 +683,7 @@ def __init__(
self._data = DataOperations(
self._operation_scope,
self._operation_config,
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview,
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_04_2023_preview),
self._service_client_01_2024_preview,
self._datastores,
requests_pipeline=self._requests_pipeline,
Expand All @@ -659,7 +694,7 @@ def __init__(
self._components = ComponentOperations(
self._operation_scope,
self._operation_config,
self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_01_2024_preview,
(self._service_client_10_2021_dataplanepreview if registry_name else self._service_client_01_2024_preview),
self._operation_container,
self._preflight,
**ops_kwargs, # type: ignore[arg-type]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,61 @@
import re
from typing import Any, Dict, Optional, Union

from azure.ai.ml._restclient.v2023_04_01_preview.models import CustomModelJobInput as RestCustomModelJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import CustomModelJobOutput as RestCustomModelJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
CustomModelJobInput as RestCustomModelJobInput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
CustomModelJobOutput as RestCustomModelJobOutput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import InputDeliveryMode
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobInput as RestJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobInputType
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobOutput as RestJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobOutputType, LiteralJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLFlowModelJobInput as RestMLFlowModelJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLFlowModelJobOutput as RestMLFlowModelJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLTableJobInput as RestMLTableJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import MLTableJobOutput as RestMLTableJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
MLFlowModelJobInput as RestMLFlowModelJobInput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
MLFlowModelJobOutput as RestMLFlowModelJobOutput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
MLTableJobInput as RestMLTableJobInput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
MLTableJobOutput as RestMLTableJobOutput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import OutputDeliveryMode
from azure.ai.ml._restclient.v2023_04_01_preview.models import TritonModelJobInput as RestTritonModelJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import TritonModelJobOutput as RestTritonModelJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFileJobInput as RestUriFileJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFileJobOutput as RestUriFileJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFolderJobInput as RestUriFolderJobInput
from azure.ai.ml._restclient.v2023_04_01_preview.models import UriFolderJobOutput as RestUriFolderJobOutput
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
TritonModelJobInput as RestTritonModelJobInput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
TritonModelJobOutput as RestTritonModelJobOutput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
UriFileJobInput as RestUriFileJobInput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
UriFileJobOutput as RestUriFileJobOutput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
UriFolderJobInput as RestUriFolderJobInput,
)
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
UriFolderJobOutput as RestUriFolderJobOutput,
)
from azure.ai.ml._utils.utils import is_data_binding_expression
from azure.ai.ml.constants import AssetTypes, InputOutputModes, JobType
from azure.ai.ml.constants._component import IOConstants
from azure.ai.ml.entities._inputs_outputs import Input, Output
from azure.ai.ml.entities._job.input_output_entry import InputOutputEntry
from azure.ai.ml.entities._util import normalize_job_input_output_type
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, JobException, ValidationErrorType, ValidationException
from azure.ai.ml.exceptions import (
ErrorCategory,
ErrorTarget,
JobException,
ValidationErrorType,
ValidationException,
)

INPUT_MOUNT_MAPPING_FROM_REST = {
InputDeliveryMode.READ_WRITE_MOUNT: InputOutputModes.RW_MOUNT,
Expand Down Expand Up @@ -175,7 +205,8 @@ def validate_pipeline_input_key_characters(key: str) -> None:
# so a valid pipeline key is: ^{single_key}([.]{single_key})*$
if re.match(IOConstants.VALID_KEY_PATTERN, key) is None:
msg = (
"Pipeline input key name {} must be composed letters, numbers, and underscores with optional split by dots."
"Pipeline input key name {} must be composed letters, numbers, and underscores with optional "
"split by dots."
)
raise ValidationException(
message=msg.format(key),
Expand Down Expand Up @@ -229,7 +260,7 @@ def to_rest_dataset_literal_inputs(
if input_value.type in target_cls_dict:
input_data = target_cls_dict[input_value.type](
uri=input_value.path,
mode=INPUT_MOUNT_MAPPING_TO_REST[input_value.mode.lower()] if input_value.mode else None,
mode=(INPUT_MOUNT_MAPPING_TO_REST[input_value.mode.lower()] if input_value.mode else None),
)

else:
Expand Down Expand Up @@ -292,7 +323,7 @@ def from_rest_inputs_to_dataset_literal(inputs: Dict[str, RestJobInput]) -> Dict
input_data = Input(
type=type_transfer_dict[input_value.job_input_type],
path=path,
mode=INPUT_MOUNT_MAPPING_FROM_REST[input_value.mode] if input_value.mode else None,
mode=(INPUT_MOUNT_MAPPING_FROM_REST[input_value.mode] if input_value.mode else None),
path_on_compute=sourcePathOnCompute,
)
elif input_value.job_input_type in (JobInputType.LITERAL, JobInputType.LITERAL):
Expand Down Expand Up @@ -337,7 +368,7 @@ def to_rest_data_outputs(outputs: Optional[Dict]) -> Dict[str, RestJobOutput]:
asset_name=output_value.name,
asset_version=output_value.version,
uri=output_value.path,
mode=OUTPUT_MOUNT_MAPPING_TO_REST[output_value.mode.lower()] if output_value.mode else None,
mode=(OUTPUT_MOUNT_MAPPING_TO_REST[output_value.mode.lower()] if output_value.mode else None),
pathOnCompute=getattr(output_value, "path_on_compute", None),
description=output_value.description,
)
Expand Down Expand Up @@ -380,7 +411,7 @@ def from_rest_data_outputs(outputs: Dict[str, RestJobOutput]) -> Dict[str, Outpu
from_rest_outputs[output_name] = Output(
type=output_type_mapping[output_value.job_output_type],
path=output_value.uri,
mode=OUTPUT_MOUNT_MAPPING_FROM_REST[output_value.mode] if output_value.mode else None,
mode=(OUTPUT_MOUNT_MAPPING_FROM_REST[output_value.mode] if output_value.mode else None),
path_on_compute=sourcePathOnCompute,
description=output_value.description,
name=output_value.asset_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
FineTuningJob as RestFineTuningJob,
JobBase as RestJobBase,
)
from azure.ai.ml.entities._job._input_output_helpers import from_rest_data_outputs, to_rest_data_outputs
from azure.ai.ml.entities._job._input_output_helpers import (
from_rest_data_outputs,
to_rest_data_outputs,
)
from azure.ai.ml.entities._inputs_outputs import Input
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY
from azure.ai.ml.entities._job.finetuning.finetuning_vertical import FineTuningVertical
Expand Down Expand Up @@ -101,7 +104,9 @@ def _to_dict(self) -> Dict: # pylint: disable=arguments-differ
:return: dictionary representation of the object.
:rtype: typing.Dict
"""
from azure.ai.ml._schema._finetuning.custom_model_finetuning import CustomModelFineTuningSchema
from azure.ai.ml._schema._finetuning.custom_model_finetuning import (
CustomModelFineTuningSchema,
)

schema_dict: dict = {}
# TODO: Combeback to this later for FineTuningJob in pipeline
Expand Down Expand Up @@ -196,7 +201,9 @@ def _load_from_dict(
:return: CustomModelFineTuningJob object.
:rtype: CustomModelFineTuningJob
"""
from azure.ai.ml._schema._finetuning.custom_model_finetuning import CustomModelFineTuningSchema
from azure.ai.ml._schema._finetuning.custom_model_finetuning import (
CustomModelFineTuningSchema,
)

# TODO: Combeback to this later - Pipeline part.
# from azure.ai.ml._schema.pipeline.automl_node import AutoMLClassificationNodeSchema
Expand Down
20 changes: 16 additions & 4 deletions sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobBase, JobService
from azure.ai.ml._restclient.v2023_04_01_preview.models import JobType as RestJobType
from azure.ai.ml._restclient.v2024_01_01_preview.models import JobBase as JobBase_2401
from azure.ai.ml._restclient.v2024_01_01_preview.models import JobType as RestJobType_20240101Preview
from azure.ai.ml._restclient.v2024_01_01_preview.models import (
JobType as RestJobType_20240101Preview,
)
from azure.ai.ml._utils._html_utils import make_link, to_html
from azure.ai.ml._utils.utils import dump_yaml_to_file
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PARAMS_OVERRIDE_KEY, CommonYamlFields
from azure.ai.ml.constants._common import (
BASE_PATH_CONTEXT_KEY,
PARAMS_OVERRIDE_KEY,
CommonYamlFields,
)
from azure.ai.ml.constants._compute import ComputeType
from azure.ai.ml.constants._job.job import JobServices, JobType
from azure.ai.ml.entities._mixins import TelemetryMixin
Expand Down Expand Up @@ -191,7 +197,10 @@ def _repr_html_(self) -> str:
if self.studio_url:
info.update(
[
("Details Page", make_link(self.studio_url, "Link to Azure Machine Learning studio")),
(
"Details Page",
make_link(self.studio_url, "Link to Azure Machine Learning studio"),
),
]
)
res: str = to_html(info)
Expand Down Expand Up @@ -334,7 +343,10 @@ def _from_rest_object( # pylint: disable=too-many-return-statements
except Exception as ex:
error_message = json.dumps(obj.as_dict(), indent=2) if obj else None
module_logger.info(
"Exception: %s.\n%s\nUnable to parse the job resource: %s.\n", ex, traceback.format_exc(), error_message
"Exception: %s.\n%s\nUnable to parse the job resource: %s.\n",
ex,
traceback.format_exc(),
error_message,
)
raise JobParsingError(
message=str(ex),
Expand Down
Loading