Skip to content

Commit 973d6e5

Browse files
authored
[ML] fix: Add type instance var to MonitorInputData (Azure#32281)
* refactor: Use MonintorInputDataType instead of magic constants * refactor: input_type -> type * docs: Document type instance var
1 parent 4ac2a37 commit 973d6e5

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/constants/_monitoring.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ class MonitorTargetTasks(str, Enum, metaclass=CaseInsensitiveEnumMeta):
9494
QUESTION_ANSWERING = "QuestionAnswering"
9595

9696

97+
class MonitorInputDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
98+
#: An input data with a fixed window size.
99+
STATIC = "Static"
100+
#: An input data which trailing relatively to the monitor's current run.
101+
TRAILING = "Trailing"
102+
#: An input data with tabular format which doesn't require preprocessing.
103+
FIXED = "Fixed"
104+
105+
97106
class FADColumnNames(str, Enum, metaclass=CaseInsensitiveEnumMeta):
98107
PREDICTION = "prediction"
99108
PREDICTION_PROBABILITY = "prediction_probability"

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_monitoring/input_data.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
from azure.ai.ml._utils._experimental import experimental
2020
from azure.ai.ml._utils.utils import camel_to_snake, snake_to_camel
21-
from azure.ai.ml.constants._monitoring import MonitorDatasetContext
21+
from azure.ai.ml.constants._monitoring import MonitorDatasetContext, MonitorInputDataType
2222

2323

2424
@experimental
2525
class MonitorInputData(RestTranslatableMixin):
2626
"""Monitor input data.
2727
28+
:keyword type: Specifies the type of monitoring input data.
29+
:paramtype type: MonitorInputDataType
2830
:keyword input_dataset: Input data used by the monitor
2931
:paramtype input_dataset: Optional[~azure.ai.ml.Input]
3032
:keyword dataset_context: The context of the input dataset. Accepted values are "model_inputs",
@@ -40,32 +42,37 @@ class MonitorInputData(RestTranslatableMixin):
4042
def __init__(
4143
self,
4244
*,
43-
input_type: str = None,
45+
type: MonitorInputDataType = None,
4446
data_context: MonitorDatasetContext = None,
4547
target_columns: Dict = None,
4648
job_type: str = None,
4749
uri: str = None,
4850
):
49-
self.input_type = input_type
51+
self.type = type
5052
self.data_context = data_context
5153
self.target_columns = target_columns
5254
self.job_type = job_type
5355
self.uri = uri
5456

5557
@classmethod
5658
def _from_rest_object(cls, obj: RestMonitorInputBase) -> Optional["MonitorInputData"]:
57-
if obj.input_data_type == "Fixed":
59+
if obj.input_data_type == MonitorInputDataType.FIXED:
5860
return FixedInputData._from_rest_object(obj)
59-
if obj.input_data_type == "Trailing":
61+
if obj.input_data_type == MonitorInputDataType.TRAILING:
6062
return TrailingInputData._from_rest_object(obj)
61-
if obj.input_data_type == "Static":
63+
if obj.input_data_type == MonitorInputDataType.STATIC:
6264
return StaticInputData._from_rest_object(obj)
6365

6466
return None
6567

6668

6769
@experimental
6870
class FixedInputData(MonitorInputData):
71+
"""
72+
:ivar type: Specifies the type of monitoring input data. Set automatically to "Fixed" for this class.
73+
:var type: MonitorInputDataType
74+
"""
75+
6976
def __init__(
7077
self,
7178
*,
@@ -75,7 +82,7 @@ def __init__(
7582
uri: str = None,
7683
):
7784
super().__init__(
78-
input_type="Fixed",
85+
type=MonitorInputDataType.FIXED,
7986
data_context=data_context,
8087
target_columns=target_columns,
8188
job_type=job_type,
@@ -102,6 +109,11 @@ def _from_rest_object(cls, obj: RestFixedInputData) -> "FixedInputData":
102109

103110
@experimental
104111
class TrailingInputData(MonitorInputData):
112+
"""
113+
:ivar type: Specifies the type of monitoring input data. Set automatically to "Trailing" for this class.
114+
:var type: MonitorInputDataType
115+
"""
116+
105117
def __init__(
106118
self,
107119
*,
@@ -114,7 +126,7 @@ def __init__(
114126
pre_processing_component_id: str = None,
115127
):
116128
super().__init__(
117-
input_type="Trailing",
129+
type=MonitorInputDataType.TRAILING,
118130
data_context=data_context,
119131
target_columns=target_columns,
120132
job_type=job_type,
@@ -150,6 +162,11 @@ def _from_rest_object(cls, obj: RestTrailingInputData) -> "TrailingInputData":
150162

151163
@experimental
152164
class StaticInputData(MonitorInputData):
165+
"""
166+
:ivar type: Specifies the type of monitoring input data. Set automatically to "Static" for this class.
167+
:var type: MonitorInputDataType
168+
"""
169+
153170
def __init__(
154171
self,
155172
*,
@@ -162,7 +179,7 @@ def __init__(
162179
window_end: str = None,
163180
):
164181
super().__init__(
165-
input_type="Static",
182+
type=MonitorInputDataType.STATIC,
166183
data_context=data_context,
167184
target_columns=target_columns,
168185
job_type=job_type,

0 commit comments

Comments
 (0)