From 292ea61d76aec72ef80c054a6ee6220fc5c0b5a2 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:22:32 -0400 Subject: [PATCH 1/3] refactor: Use MonintorInputDataType instead of magic constants --- .../azure/ai/ml/constants/_monitoring.py | 9 +++++++++ .../azure/ai/ml/entities/_monitoring/input_data.py | 14 +++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/constants/_monitoring.py b/sdk/ml/azure-ai-ml/azure/ai/ml/constants/_monitoring.py index 29db298134f1..5e600910809f 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/constants/_monitoring.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/constants/_monitoring.py @@ -94,6 +94,15 @@ class MonitorTargetTasks(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUESTION_ANSWERING = "QuestionAnswering" +class MonitorInputDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + #: An input data with a fixed window size. + STATIC = "Static" + #: An input data which trailing relatively to the monitor's current run. + TRAILING = "Trailing" + #: An input data with tabular format which doesn't require preprocessing. + FIXED = "Fixed" + + class FADColumnNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): PREDICTION = "prediction" PREDICTION_PROBABILITY = "prediction_probability" diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py index 2164b029c08d..29042e2ff9f5 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py @@ -18,7 +18,7 @@ from azure.ai.ml._utils._experimental import experimental from azure.ai.ml._utils.utils import camel_to_snake, snake_to_camel -from azure.ai.ml.constants._monitoring import MonitorDatasetContext +from azure.ai.ml.constants._monitoring import MonitorDatasetContext, MonitorInputDataType @experimental @@ -54,11 +54,11 @@ def __init__( @classmethod def _from_rest_object(cls, obj: RestMonitorInputBase) -> Optional["MonitorInputData"]: - if obj.input_data_type == "Fixed": + if obj.input_data_type == MonitorInputDataType.FIXED: return FixedInputData._from_rest_object(obj) - if obj.input_data_type == "Trailing": + if obj.input_data_type == MonitorInputDataType.TRAILING: return TrailingInputData._from_rest_object(obj) - if obj.input_data_type == "Static": + if obj.input_data_type == MonitorInputDataType.STATIC: return StaticInputData._from_rest_object(obj) return None @@ -75,7 +75,7 @@ def __init__( uri: str = None, ): super().__init__( - input_type="Fixed", + input_type=MonitorInputDataType.FIXED, data_context=data_context, target_columns=target_columns, job_type=job_type, @@ -114,7 +114,7 @@ def __init__( pre_processing_component_id: str = None, ): super().__init__( - input_type="Trailing", + input_type=MonitorInputDataType.TRAILING, data_context=data_context, target_columns=target_columns, job_type=job_type, @@ -162,7 +162,7 @@ def __init__( window_end: str = None, ): super().__init__( - input_type="Static", + input_type=MonitorInputDataType.STATIC, data_context=data_context, target_columns=target_columns, job_type=job_type, From b5f011772d918d946d3cb351a8f87f277d8edd2e Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:24:09 -0400 Subject: [PATCH 2/3] refactor: input_type -> type --- .../azure/ai/ml/entities/_monitoring/input_data.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py index 29042e2ff9f5..bd073062fcd9 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py @@ -40,13 +40,13 @@ class MonitorInputData(RestTranslatableMixin): def __init__( self, *, - input_type: str = None, + type: MonitorInputDataType = None, data_context: MonitorDatasetContext = None, target_columns: Dict = None, job_type: str = None, uri: str = None, ): - self.input_type = input_type + self.type = type self.data_context = data_context self.target_columns = target_columns self.job_type = job_type @@ -75,7 +75,7 @@ def __init__( uri: str = None, ): super().__init__( - input_type=MonitorInputDataType.FIXED, + type=MonitorInputDataType.FIXED, data_context=data_context, target_columns=target_columns, job_type=job_type, @@ -114,7 +114,7 @@ def __init__( pre_processing_component_id: str = None, ): super().__init__( - input_type=MonitorInputDataType.TRAILING, + type=MonitorInputDataType.TRAILING, data_context=data_context, target_columns=target_columns, job_type=job_type, @@ -162,7 +162,7 @@ def __init__( window_end: str = None, ): super().__init__( - input_type=MonitorInputDataType.STATIC, + type=MonitorInputDataType.STATIC, data_context=data_context, target_columns=target_columns, job_type=job_type, From f5d890d682658137f1ea82b93dad836b42935912 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:25:38 -0400 Subject: [PATCH 3/3] docs: Document type instance var --- .../ai/ml/entities/_monitoring/input_data.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py index bd073062fcd9..5be18670c8f3 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py @@ -25,6 +25,8 @@ class MonitorInputData(RestTranslatableMixin): """Monitor input data. + :keyword type: Specifies the type of monitoring input data. + :paramtype type: MonitorInputDataType :keyword input_dataset: Input data used by the monitor :paramtype input_dataset: Optional[~azure.ai.ml.Input] :keyword dataset_context: The context of the input dataset. Accepted values are "model_inputs", @@ -66,6 +68,11 @@ def _from_rest_object(cls, obj: RestMonitorInputBase) -> Optional["MonitorInputD @experimental class FixedInputData(MonitorInputData): + """ + :ivar type: Specifies the type of monitoring input data. Set automatically to "Fixed" for this class. + :var type: MonitorInputDataType + """ + def __init__( self, *, @@ -102,6 +109,11 @@ def _from_rest_object(cls, obj: RestFixedInputData) -> "FixedInputData": @experimental class TrailingInputData(MonitorInputData): + """ + :ivar type: Specifies the type of monitoring input data. Set automatically to "Trailing" for this class. + :var type: MonitorInputDataType + """ + def __init__( self, *, @@ -150,6 +162,11 @@ def _from_rest_object(cls, obj: RestTrailingInputData) -> "TrailingInputData": @experimental class StaticInputData(MonitorInputData): + """ + :ivar type: Specifies the type of monitoring input data. Set automatically to "Static" for this class. + :var type: MonitorInputDataType + """ + def __init__( self, *,