Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pipeline info to properties in batch-deployments #34905

Merged
merged 3 commits into from
Mar 25, 2024
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
2 changes: 1 addition & 1 deletion sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def __init__(
self._batch_deployments = BatchDeploymentOperations(
self._operation_scope,
self._operation_config,
self._service_client_10_2023,
self._service_client_01_2024_preview,
self._operation_container,
credentials=self._credential,
requests_pipeline=self._requests_pipeline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from pathlib import Path
from typing import Any, Dict, Optional, Union

from azure.ai.ml._restclient.v2022_05_01.models import BatchDeploymentData
from azure.ai.ml._restclient.v2022_05_01.models import BatchDeploymentDetails as RestBatchDeployment
from azure.ai.ml._restclient.v2022_05_01.models import BatchOutputAction
from azure.ai.ml._restclient.v2022_05_01.models import CodeConfiguration as RestCodeConfiguration
from azure.ai.ml._restclient.v2022_05_01.models import IdAssetReference
from azure.ai.ml._restclient.v2024_01_01_preview.models import BatchDeployment as BatchDeploymentData
from azure.ai.ml._restclient.v2024_01_01_preview.models import BatchDeploymentProperties as RestBatchDeployment
from azure.ai.ml._restclient.v2024_01_01_preview.models import BatchOutputAction
from azure.ai.ml._restclient.v2024_01_01_preview.models import CodeConfiguration as RestCodeConfiguration
from azure.ai.ml._restclient.v2024_01_01_preview.models import IdAssetReference
from azure.ai.ml._schema._deployment.batch.batch_deployment import BatchDeploymentSchema
from azure.ai.ml._utils._arm_id_utils import _parse_endpoint_name_from_deployment_id
from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PARAMS_OVERRIDE_KEY
Expand Down Expand Up @@ -253,6 +253,24 @@ def _from_rest_object( # pylint: disable=arguments-renamed
cls, deployment: BatchDeploymentData
) -> BatchDeploymentData:
modelId = deployment.properties.model.asset_id if deployment.properties.model else None

if hasattr(deployment.properties, "deployment_configuration"):
settings = deployment.properties.deployment_configuration.settings
deployment_comp_settings = {
"deployment_configuration_type": deployment.properties.deployment_configuration.deployment_configuration_type, # pylint: disable=line-too-long
"componentDeployment.Settings.continue_on_step_failure": settings.get(
"ComponentDeployment.Settings.continue_on_step_failure", None
),
"default_datastore": settings.get("default_datastore", None),
"default_compute": settings.get("default_compute", None),
}
properties = {}
if deployment.properties.properties:
properties.update(deployment.properties.properties)
properties.update(deployment_comp_settings)
else:
properties = deployment.properties.properties

code_configuration = (
CodeConfiguration._from_rest_code_configuration(deployment.properties.code_configuration)
if deployment.properties.code_configuration
Expand Down Expand Up @@ -280,7 +298,7 @@ def _from_rest_object( # pylint: disable=arguments-renamed
environment_variables=deployment.properties.environment_variables,
max_concurrency_per_instance=deployment.properties.max_concurrency_per_instance,
endpoint_name=_parse_endpoint_name_from_deployment_id(deployment.id),
properties=deployment.properties.properties,
properties=properties,
creation_context=SystemData._from_rest_object(deployment.system_data),
provisioning_state=deployment.properties.provisioning_state,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from pathlib import Path
from typing import IO, Any, AnyStr, Dict, Optional, Union

from azure.ai.ml._restclient.v2023_04_01_preview.models import BatchDeployment as RestBatchDeployment
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
from azure.ai.ml._restclient.v2024_01_01_preview.models import BatchDeployment as RestBatchDeployment
from azure.ai.ml._restclient.v2024_01_01_preview.models import (
BatchDeploymentProperties,
BatchPipelineComponentDeploymentConfiguration,
IdAssetReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import re
from typing import Any, Optional, TypeVar, Union

from azure.ai.ml._restclient.v2022_05_01 import AzureMachineLearningWorkspaces as ServiceClient052022
from azure.ai.ml._restclient.v2024_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012024Preview
from azure.ai.ml._scope_dependent_operations import (
OperationConfig,
OperationsContainer,
Expand Down Expand Up @@ -64,18 +64,18 @@ def __init__(
self,
operation_scope: OperationScope,
operation_config: OperationConfig,
service_client_05_2022: ServiceClient052022,
service_client_01_2024_preview: ServiceClient012024Preview,
all_operations: OperationsContainer,
credentials: Optional[TokenCredential] = None,
**kwargs: Any,
):
super(BatchDeploymentOperations, self).__init__(operation_scope, operation_config)
ops_logger.update_info(kwargs)
self._batch_deployment = service_client_05_2022.batch_deployments
self._batch_deployment = service_client_01_2024_preview.batch_deployments
self._batch_job_deployment = kwargs.pop("service_client_09_2020_dataplanepreview").batch_job_deployment
service_client_02_2023_preview = kwargs.pop("service_client_02_2023_preview")
self._component_batch_deployment_operations = service_client_02_2023_preview.batch_deployments
self._batch_endpoint_operations = service_client_05_2022.batch_endpoints
self._batch_endpoint_operations = service_client_01_2024_preview.batch_endpoints
self._component_operations = service_client_02_2023_preview.component_versions
self._all_operations = all_operations
self._credentials = credentials
Expand Down Expand Up @@ -191,7 +191,6 @@ def get(self, name: str, endpoint_name: str) -> BatchDeployment:
:dedent: 8
:caption: Get example.
"""

deployment = BatchDeployment._from_rest_object(
self._batch_deployment.get(
endpoint_name=endpoint_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def mock_local_endpoint_helper() -> Mock:
def mock_batch_deployment_operations(
mock_workspace_scope: OperationScope,
mock_operation_config: OperationConfig,
mock_aml_services_2022_05_01: Mock,
mock_aml_services_2024_01_01_preview: Mock,
mock_aml_services_2023_02_01_preview: Mock,
mock_aml_services_2020_09_01_dataplanepreview: Mock,
mock_machinelearning_client: Mock,
Expand All @@ -75,7 +75,7 @@ def mock_batch_deployment_operations(
yield BatchDeploymentOperations(
operation_scope=mock_workspace_scope,
operation_config=mock_operation_config,
service_client_05_2022=mock_aml_services_2022_05_01,
service_client_01_2024_preview=mock_aml_services_2024_01_01_preview,
all_operations=mock_machinelearning_client._operation_container,
requests_pipeline=mock_machinelearning_client._requests_pipeline,
**kwargs,
Expand Down Expand Up @@ -125,11 +125,11 @@ def test_list_deployment_jobs(
def test_delete_batch_endpoint(
self,
mock_batch_deployment_operations: BatchDeploymentOperations,
mock_aml_services_2022_05_01: Mock,
mock_aml_services_2024_01_01_preview: Mock,
mocker: MockFixture,
mock_delete_poller: LROPoller,
) -> None:
random_name = "random_name"
mock_aml_services_2022_05_01.batch_deployments.begin_delete.return_value = mock_delete_poller
mock_aml_services_2024_01_01_preview.batch_deployments.begin_delete.return_value = mock_delete_poller
mock_batch_deployment_operations.begin_delete(endpoint_name="batch-ept", name=random_name)
mock_batch_deployment_operations._batch_deployment.begin_delete.assert_called_once()