Skip to content

Commit 83a6833

Browse files
authored
Fix kubernets online deployment and scale settings (Azure#30271)
1 parent 63d0178 commit 83a6833

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/online_deployment.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
from azure.ai.ml.entities._assets._artifacts.model import Model
3333
from azure.ai.ml.entities._assets.environment import Environment
3434
from azure.ai.ml.entities._deployment.code_configuration import CodeConfiguration
35+
from azure.ai.ml.entities._deployment.data_collector import DataCollector
3536
from azure.ai.ml.entities._deployment.deployment_settings import OnlineRequestSettings, ProbeSettings
3637
from azure.ai.ml.entities._deployment.resource_requirements_settings import ResourceRequirementsSettings
3738
from azure.ai.ml.entities._deployment.scale_settings import (
3839
DefaultScaleSettings,
3940
OnlineScaleSettings,
4041
TargetUtilizationScaleSettings,
4142
)
42-
from azure.ai.ml.entities._deployment.data_collector import DataCollector
4343
from azure.ai.ml.entities._endpoint._endpoint_helpers import validate_endpoint_or_deployment_name
4444
from azure.ai.ml.entities._util import load_from_dict
4545
from azure.ai.ml.exceptions import (
@@ -49,6 +49,7 @@
4949
ValidationErrorType,
5050
ValidationException,
5151
)
52+
5253
from .deployment import Deployment
5354

5455
module_logger = logging.getLogger(__name__)
@@ -564,7 +565,7 @@ def _from_rest_object(cls, resource: RestOnlineDeploymentData) -> "KubernetesOnl
564565
else None
565566
)
566567

567-
entity = KubernetesOnlineDeployment(
568+
return KubernetesOnlineDeployment(
568569
id=resource.id,
569570
name=resource.name,
570571
tags=resource.tags,
@@ -583,10 +584,11 @@ def _from_rest_object(cls, resource: RestOnlineDeploymentData) -> "KubernetesOnl
583584
endpoint_name=_parse_endpoint_name_from_deployment_id(resource.id),
584585
instance_count=resource.sku.capacity if resource.sku else None,
585586
instance_type=deployment.instance_type,
587+
data_collector=DataCollector._from_rest_object(deployment.data_collector)
588+
if hasattr(deployment, "data_collector") and deployment.data_collector
589+
else None,
586590
)
587591

588-
return OnlineDeployment._filter_datastore_from_rest_object(entity=entity, deployment=deployment)
589-
590592

591593
class ManagedOnlineDeployment(OnlineDeployment):
592594
"""Managed Online endpoint deployment entity.
@@ -823,7 +825,7 @@ def _from_rest_object(cls, resource: RestOnlineDeploymentData) -> "ManagedOnline
823825
else None,
824826
egress_public_network_access=deployment.egress_public_network_access,
825827
data_collector=DataCollector._from_rest_object(deployment.data_collector)
826-
if deployment.data_collector
828+
if hasattr(deployment, "data_collector") and deployment.data_collector
827829
else None,
828830
)
829831

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/scale_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def _merge_with(self, other: "OnlineScaleSettings") -> None:
4747
def _from_rest_object( # pylint: disable=arguments-renamed
4848
cls, settings: RestOnlineScaleSettings
4949
) -> "OnlineScaleSettings":
50-
if isinstance(settings, RestDefaultScaleSettings):
50+
if settings.scale_type == "Default":
5151
return DefaultScaleSettings._from_rest_object(settings)
52-
if isinstance(settings, RestTargetUtilizationScaleSettings):
52+
if settings.scale_type == "TargetUtilization":
5353
return TargetUtilizationScaleSettings._from_rest_object(settings)
5454

5555
msg = f"Unsupported online scale setting type {settings.type}."

0 commit comments

Comments
 (0)