14
14
creation in ModelMonitor.
15
15
"""
16
16
17
- import json
17
+ import json
18
18
from sagemaker .dashboard .dashboard_variables import DashboardVariable
19
19
from sagemaker .dashboard .dashboard_widgets import DashboardWidget , DashboardWidgetProperties
20
20
from sagemaker .model_monitor .model_monitoring import EndpointInput
21
21
22
+
22
23
class AutomaticDataQualityDashboard :
23
24
DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE = (
24
25
"{aws/sagemaker/Endpoints/data-metrics,Endpoint,Feature,MonitoringSchedule}"
@@ -28,11 +29,11 @@ class AutomaticDataQualityDashboard:
28
29
)
29
30
30
31
def __init__ (self , endpoint_name , monitoring_schedule_name , batch_transform_input , region_name ):
31
- if type (endpoint_name ) == EndpointInput :
32
+ if type (endpoint_name ) == EndpointInput :
32
33
self .endpoint = endpoint_name .endpoint_name
33
34
else :
34
35
self .endpoint = endpoint_name
35
-
36
+
36
37
self .monitoring_schedule = monitoring_schedule_name
37
38
self .batch_transform = batch_transform_input
38
39
self .region = region_name
@@ -96,15 +97,15 @@ def _generate_type_counts_widget(self):
96
97
f"%^feature_string_counts_.*% OR "
97
98
f"%^feature_boolean_counts_.*% OR "
98
99
f"%^feature_unknown_counts_.*% "
99
- f" Feature=\" _ \" "
100
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
100
+ f' Feature="_" '
101
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
101
102
f"'Average')"
102
103
)
103
104
}
104
105
]
105
106
],
106
107
region = self .region ,
107
- title = "Type Counts"
108
+ title = "Type Counts" ,
108
109
)
109
110
110
111
else :
@@ -121,16 +122,16 @@ def _generate_type_counts_widget(self):
121
122
f"%^feature_string_counts_.*% OR "
122
123
f"%^feature_boolean_counts_.*% OR "
123
124
f"%^feature_unknown_counts_.*% "
124
- f" Endpoint=\ "{ self .endpoint } \" "
125
- f" Feature=\" _ \" "
126
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
125
+ f' Endpoint="{ self .endpoint } " '
126
+ f' Feature="_" '
127
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
127
128
f"'Average')"
128
129
)
129
130
}
130
131
]
131
132
],
132
133
region = self .region ,
133
- title = "Type Counts"
134
+ title = "Type Counts" ,
134
135
)
135
136
136
137
return DashboardWidget (
@@ -148,15 +149,15 @@ def _generate_null_counts_widget(self):
148
149
"expression" : (
149
150
f"SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_BATCH_NAMESPACE } "
150
151
f"%^feature_null_.*% OR %^feature_non_null_.*% "
151
- f" Feature=\" _ \" "
152
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
152
+ f' Feature="_" '
153
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
153
154
f"'Average')"
154
155
)
155
156
}
156
157
]
157
158
],
158
159
region = self .region ,
159
- title = "Missing Data Counts"
160
+ title = "Missing Data Counts" ,
160
161
)
161
162
162
163
else :
@@ -167,12 +168,12 @@ def _generate_null_counts_widget(self):
167
168
[
168
169
{
169
170
"expression" : (
170
- f' SEARCH( \ '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE } '
171
- f' %^feature_null_.*% OR %^feature_non_null_.*% '
171
+ f" SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE } "
172
+ f" %^feature_null_.*% OR %^feature_non_null_.*% "
172
173
f'Endpoint="{ self .endpoint } " '
173
174
f'Feature="_" '
174
175
f'MonitoringSchedule="{ self .monitoring_schedule } " \' , '
175
- f' \' Average\' )'
176
+ f"' Average')"
176
177
)
177
178
}
178
179
]
@@ -195,15 +196,15 @@ def _generate_estimated_unique_values_widget(self):
195
196
"expression" : (
196
197
f"SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_BATCH_NAMESPACE } "
197
198
f"%^feature_estimated_unique_values_.*% "
198
- f" Feature=\" _ \" "
199
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
199
+ f' Feature="_" '
200
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
200
201
f"'Average')"
201
202
)
202
203
}
203
204
]
204
205
],
205
206
region = self .region ,
206
- title = "Estimated Unique Values"
207
+ title = "Estimated Unique Values" ,
207
208
)
208
209
209
210
else :
@@ -216,16 +217,16 @@ def _generate_estimated_unique_values_widget(self):
216
217
"expression" : (
217
218
f"SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE } "
218
219
f"%^feature_estimated_unique_values_.*% "
219
- f" Endpoint=\ "{ self .endpoint } \" "
220
- f" Feature=\" _ \" "
221
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
220
+ f' Endpoint="{ self .endpoint } " '
221
+ f' Feature="_" '
222
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
222
223
f"'Average')"
223
224
)
224
225
}
225
226
]
226
227
],
227
228
region = self .region ,
228
- title = "Estimated Unique Values"
229
+ title = "Estimated Unique Values" ,
229
230
)
230
231
231
232
return DashboardWidget (
@@ -246,15 +247,15 @@ def _generate_completeness_widget(self):
246
247
"expression" : (
247
248
f"SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_BATCH_NAMESPACE } "
248
249
f"%^feature_completeness_.*% "
249
- f" Feature=\" _ \" "
250
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
250
+ f' Feature="_" '
251
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
251
252
f"'Average')"
252
253
)
253
254
}
254
255
]
255
256
],
256
257
region = self .region ,
257
- title = "Completeness"
258
+ title = "Completeness" ,
258
259
)
259
260
260
261
else :
@@ -267,9 +268,9 @@ def _generate_completeness_widget(self):
267
268
"expression" : (
268
269
f"SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE } "
269
270
f"%^feature_completeness_.*% "
270
- f" Endpoint=\ "{ self .endpoint } \" "
271
- f" Feature=\" _ \" "
272
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
271
+ f' Endpoint="{ self .endpoint } " '
272
+ f' Feature="_" '
273
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
273
274
f"'Average')"
274
275
)
275
276
}
@@ -294,8 +295,8 @@ def _generate_baseline_drift_widget(self):
294
295
"expression" : (
295
296
f"SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_BATCH_NAMESPACE } "
296
297
f"%^feature_baseline_drift_.*% "
297
- f" Feature=\" _ \" "
298
- f" MonitoringSchedule=\ "{ self .monitoring_schedule } \" ', "
298
+ f' Feature="_" '
299
+ f' MonitoringSchedule="{ self .monitoring_schedule } " \ ' , '
299
300
f"'Average')"
300
301
)
301
302
}
@@ -313,12 +314,12 @@ def _generate_baseline_drift_widget(self):
313
314
[
314
315
{
315
316
"expression" : (
316
- f' SEARCH( \ '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE } '
317
- f' %^feature_baseline_drift_.*% '
317
+ f" SEARCH( '{ AutomaticDataQualityDashboard .DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE } "
318
+ f" %^feature_baseline_drift_.*% "
318
319
f'Endpoint="{ self .endpoint } " '
319
320
f'Feature="_" '
320
321
f'MonitoringSchedule="{ self .monitoring_schedule } " \' , '
321
- f' \' Average\' )'
322
+ f"' Average')"
322
323
)
323
324
}
324
325
]
0 commit comments