diff options
Diffstat (limited to '.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online')
14 files changed, 455 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/__init__.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/__init__.py new file mode 100644 index 00000000..fdf8caba --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/__init__.py @@ -0,0 +1,5 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/data_asset_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/data_asset_schema.py new file mode 100644 index 00000000..84bd37e3 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/data_asset_schema.py @@ -0,0 +1,26 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + + +import logging +from typing import Any + +from marshmallow import fields, post_load + +from azure.ai.ml._schema import PatchedSchemaMeta + +module_logger = logging.getLogger(__name__) + + +class DataAssetSchema(metaclass=PatchedSchemaMeta): + name = fields.Str() + path = fields.Str() + version = fields.Str() + data_id = fields.Str() + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: # pylint: disable=unused-argument + from azure.ai.ml.entities._deployment.data_asset import DataAsset + + return DataAsset(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/data_collector_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/data_collector_schema.py new file mode 100644 index 00000000..633f96fc --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/data_collector_schema.py @@ -0,0 +1,39 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + + +import logging +from typing import Any + +from marshmallow import fields, post_load, validates, ValidationError + +from azure.ai.ml._schema import NestedField, PatchedSchemaMeta, StringTransformedEnum +from azure.ai.ml._schema._deployment.online.request_logging_schema import RequestLoggingSchema +from azure.ai.ml._schema._deployment.online.deployment_collection_schema import DeploymentCollectionSchema + +from azure.ai.ml.constants._common import RollingRate + +module_logger = logging.getLogger(__name__) + + +class DataCollectorSchema(metaclass=PatchedSchemaMeta): + collections = fields.Dict(keys=fields.Str, values=NestedField(DeploymentCollectionSchema)) + rolling_rate = StringTransformedEnum( + required=False, + allowed_values=[RollingRate.MINUTE, RollingRate.DAY, RollingRate.HOUR], + ) + sampling_rate = fields.Float() # Should be copied to each of the collections + request_logging = NestedField(RequestLoggingSchema) + + # pylint: disable=unused-argument + @validates("sampling_rate") + def validate_sampling_rate(self, value, **kwargs): + if value > 1.0 or value < 0.0: + raise ValidationError("Sampling rate must be an number in range (0.0-1.0)") + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: # pylint: disable=unused-argument + from azure.ai.ml.entities._deployment.data_collector import DataCollector + + return DataCollector(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/deployment_collection_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/deployment_collection_schema.py new file mode 100644 index 00000000..4be4a9cc --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/deployment_collection_schema.py @@ -0,0 +1,32 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +import logging +from typing import Any + +from marshmallow import post_load, fields + +from azure.ai.ml._schema import PatchedSchemaMeta, StringTransformedEnum, NestedField, UnionField +from azure.ai.ml._schema._deployment.online.data_asset_schema import DataAssetSchema +from azure.ai.ml.constants._common import Boolean + +module_logger = logging.getLogger(__name__) + + +class DeploymentCollectionSchema(metaclass=PatchedSchemaMeta): + enabled = StringTransformedEnum(required=True, allowed_values=[Boolean.TRUE, Boolean.FALSE]) + data = UnionField( + [ + NestedField(DataAssetSchema), + fields.Str(), + ] + ) + client_id = fields.Str() + + # pylint: disable=unused-argument + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities._deployment.deployment_collection import DeploymentCollection + + return DeploymentCollection(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/event_hub_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/event_hub_schema.py new file mode 100644 index 00000000..27b603de --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/event_hub_schema.py @@ -0,0 +1,31 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import ValidationError, fields, post_load, validates + +from azure.ai.ml._schema import NestedField, PatchedSchemaMeta +from azure.ai.ml._schema._deployment.online.oversize_data_config_schema import OversizeDataConfigSchema + +module_logger = logging.getLogger(__name__) + + +class EventHubSchema(metaclass=PatchedSchemaMeta): + namespace = fields.Str() + oversize_data_config = NestedField(OversizeDataConfigSchema) + + @validates("namespace") + def validate_namespace(self, value, **kwargs): + if len(value.split(".")) != 2: + raise ValidationError("Namespace must follow format of {namespace}.{name}") + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities._deployment.event_hub import EventHub + + return EventHub(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/liveness_probe.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/liveness_probe.py new file mode 100644 index 00000000..d1008b8b --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/liveness_probe.py @@ -0,0 +1,28 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import fields, post_load + +from azure.ai.ml._schema.core.schema import PatchedSchemaMeta + +module_logger = logging.getLogger(__name__) + + +class LivenessProbeSchema(metaclass=PatchedSchemaMeta): + period = fields.Int() + initial_delay = fields.Int() + timeout = fields.Int() + success_threshold = fields.Int() + failure_threshold = fields.Int() + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities import ProbeSettings + + return ProbeSettings(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/online_deployment.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/online_deployment.py new file mode 100644 index 00000000..7f0760fe --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/online_deployment.py @@ -0,0 +1,79 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import fields, post_load + +from azure.ai.ml._restclient.v2022_02_01_preview.models import EndpointComputeType +from azure.ai.ml._schema._deployment.deployment import DeploymentSchema +from azure.ai.ml._schema._utils.utils import exit_if_registry_assets +from azure.ai.ml._schema.core.fields import ExperimentalField, NestedField, StringTransformedEnum, UnionField +from azure.ai.ml._utils.utils import camel_to_snake +from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PublicNetworkAccess +from azure.ai.ml._schema.job.creation_context import CreationContextSchema + +from .data_collector_schema import DataCollectorSchema +from .liveness_probe import LivenessProbeSchema +from .request_settings_schema import RequestSettingsSchema +from .resource_requirements_schema import ResourceRequirementsSchema +from .scale_settings_schema import DefaultScaleSettingsSchema, TargetUtilizationScaleSettingsSchema + +module_logger = logging.getLogger(__name__) + + +class OnlineDeploymentSchema(DeploymentSchema): + app_insights_enabled = fields.Bool() + scale_settings = UnionField( + [ + NestedField(DefaultScaleSettingsSchema), + NestedField(TargetUtilizationScaleSettingsSchema), + ] + ) + request_settings = NestedField(RequestSettingsSchema) + liveness_probe = NestedField(LivenessProbeSchema) + readiness_probe = NestedField(LivenessProbeSchema) + provisioning_state = fields.Str() + instance_count = fields.Int() + type = StringTransformedEnum( + required=False, + allowed_values=[ + EndpointComputeType.MANAGED.value, + EndpointComputeType.KUBERNETES.value, + ], + casing_transform=camel_to_snake, + ) + model_mount_path = fields.Str() + instance_type = fields.Str() + data_collector = ExperimentalField(NestedField(DataCollectorSchema)) + + +class KubernetesOnlineDeploymentSchema(OnlineDeploymentSchema): + resources = NestedField(ResourceRequirementsSchema) + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities import KubernetesOnlineDeployment + + exit_if_registry_assets(data=data, caller="K8SDeployment") + return KubernetesOnlineDeployment(base_path=self.context[BASE_PATH_CONTEXT_KEY], **data) + + +class ManagedOnlineDeploymentSchema(OnlineDeploymentSchema): + instance_type = fields.Str(required=True) + egress_public_network_access = StringTransformedEnum( + allowed_values=[PublicNetworkAccess.ENABLED, PublicNetworkAccess.DISABLED] + ) + private_network_connection = ExperimentalField(fields.Bool()) + data_collector = NestedField(DataCollectorSchema) + creation_context = NestedField(CreationContextSchema, dump_only=True) + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities import ManagedOnlineDeployment + + return ManagedOnlineDeployment(base_path=self.context[BASE_PATH_CONTEXT_KEY], **data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/oversize_data_config_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/oversize_data_config_schema.py new file mode 100644 index 00000000..8103681a --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/oversize_data_config_schema.py @@ -0,0 +1,31 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +import logging +from typing import Any + +from marshmallow import ValidationError, fields, post_load, validates + +from azure.ai.ml._schema import PatchedSchemaMeta +from azure.ai.ml._utils._storage_utils import AzureMLDatastorePathUri + +module_logger = logging.getLogger(__name__) + + +class OversizeDataConfigSchema(metaclass=PatchedSchemaMeta): + path = fields.Str() + + # pylint: disable=unused-argument + @validates("path") + def validate_path(self, value, **kwargs): + datastore_path = AzureMLDatastorePathUri(value) + if datastore_path.uri_type != "Datastore": + raise ValidationError(f"Path '{value}' is not a properly formatted datastore path.") + + # pylint: disable=unused-argument + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities._deployment.oversize_data_config import OversizeDataConfig + + return OversizeDataConfig(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/payload_response_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/payload_response_schema.py new file mode 100644 index 00000000..172af4f1 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/payload_response_schema.py @@ -0,0 +1,24 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +import logging +from typing import Any + +from marshmallow import post_load + +from azure.ai.ml._schema import PatchedSchemaMeta, StringTransformedEnum +from azure.ai.ml.constants._common import Boolean + +module_logger = logging.getLogger(__name__) + + +class PayloadResponseSchema(metaclass=PatchedSchemaMeta): + enabled = StringTransformedEnum(required=True, allowed_values=[Boolean.TRUE, Boolean.FALSE]) + + # pylint: disable=unused-argument + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities._deployment.payload_response import PayloadResponse + + return PayloadResponse(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/request_logging_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/request_logging_schema.py new file mode 100644 index 00000000..4ac0b466 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/request_logging_schema.py @@ -0,0 +1,23 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +import logging +from typing import Any + +from marshmallow import fields, post_load + +from azure.ai.ml._schema import PatchedSchemaMeta + +module_logger = logging.getLogger(__name__) + + +class RequestLoggingSchema(metaclass=PatchedSchemaMeta): + capture_headers = fields.List(fields.Str()) + + # pylint: disable=unused-argument + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities._deployment.request_logging import RequestLogging + + return RequestLogging(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/request_settings_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/request_settings_schema.py new file mode 100644 index 00000000..887a71c5 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/request_settings_schema.py @@ -0,0 +1,26 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import fields, post_load + +from azure.ai.ml._schema.core.schema import PatchedSchemaMeta + +module_logger = logging.getLogger(__name__) + + +class RequestSettingsSchema(metaclass=PatchedSchemaMeta): + request_timeout_ms = fields.Int(required=False) + max_concurrent_requests_per_instance = fields.Int(required=False) + max_queue_wait_ms = fields.Int(required=False) + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities import OnlineRequestSettings + + return OnlineRequestSettings(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/resource_requirements_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/resource_requirements_schema.py new file mode 100644 index 00000000..7f43d91f --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/resource_requirements_schema.py @@ -0,0 +1,28 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import post_load + +from azure.ai.ml._schema.core.fields import NestedField +from azure.ai.ml._schema.core.schema import PatchedSchemaMeta + +from .resource_settings_schema import ResourceSettingsSchema + +module_logger = logging.getLogger(__name__) + + +class ResourceRequirementsSchema(metaclass=PatchedSchemaMeta): + requests = NestedField(ResourceSettingsSchema) + limits = NestedField(ResourceSettingsSchema) + + @post_load + def make(self, data: Any, **kwargs: Any) -> "ResourceRequirementsSettings": + from azure.ai.ml.entities import ResourceRequirementsSettings + + return ResourceRequirementsSettings(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/resource_settings_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/resource_settings_schema.py new file mode 100644 index 00000000..21a229ad --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/resource_settings_schema.py @@ -0,0 +1,32 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import fields, post_load, pre_load + +from azure.ai.ml._schema._utils.utils import replace_key_in_odict +from azure.ai.ml._schema.core.schema import PatchedSchemaMeta + +module_logger = logging.getLogger(__name__) + + +class ResourceSettingsSchema(metaclass=PatchedSchemaMeta): + cpu = fields.String() + memory = fields.String() + gpu = fields.String() + + @pre_load + def conversion(self, data: Any, **kwargs) -> Any: + data = replace_key_in_odict(data, "nvidia.com/gpu", "gpu") + return data + + @post_load + def make(self, data: Any, **kwargs: Any) -> Any: + from azure.ai.ml.entities import ResourceSettings + + return ResourceSettings(**data) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/scale_settings_schema.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/scale_settings_schema.py new file mode 100644 index 00000000..6c5c5283 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/_deployment/online/scale_settings_schema.py @@ -0,0 +1,51 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +import logging +from typing import Any + +from marshmallow import fields, post_load + +from azure.ai.ml._restclient.v2022_10_01.models import ScaleType +from azure.ai.ml._schema.core.fields import StringTransformedEnum +from azure.ai.ml._schema.core.schema import PatchedSchemaMeta +from azure.ai.ml._utils.utils import camel_to_snake + +module_logger = logging.getLogger(__name__) + + +class DefaultScaleSettingsSchema(metaclass=PatchedSchemaMeta): + type = StringTransformedEnum( + required=True, + allowed_values=ScaleType.DEFAULT, + casing_transform=camel_to_snake, + data_key="type", + ) + + @post_load + def make(self, data: Any, **kwargs: Any) -> "DefaultScaleSettings": + from azure.ai.ml.entities import DefaultScaleSettings + + return DefaultScaleSettings(**data) + + +class TargetUtilizationScaleSettingsSchema(metaclass=PatchedSchemaMeta): + type = StringTransformedEnum( + required=True, + allowed_values=ScaleType.TARGET_UTILIZATION, + casing_transform=camel_to_snake, + data_key="type", + ) + polling_interval = fields.Int() + target_utilization_percentage = fields.Int() + min_instances = fields.Int() + max_instances = fields.Int() + + @post_load + def make(self, data: Any, **kwargs: Any) -> "TargetUtilizationScaleSettings": + from azure.ai.ml.entities import TargetUtilizationScaleSettings + + return TargetUtilizationScaleSettings(**data) |
