Skip to content

Commit f985a05

Browse files
author
Sushanth Sathish Kumar
committed
fix: Added additional filtering to dashboard variable in data quality so that only features from the specific monitoring schedule and endpoint are loaded
1 parent 50c13de commit f985a05

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

src/sagemaker/dashboard/data_quality_dashboard.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def _generate_variables(self):
119119
inputType="select",
120120
variable_id="Feature",
121121
label="Feature",
122-
search=AutomaticDataQualityDashboard.DATA_QUALITY_METRICS_BATCH_NAMESPACE,
122+
search=self.DATA_QUALITY_METRICS_BATCH_NAMESPACE
123+
+ f'MonitoringSchedule="{self.monitoring_schedule}" ',
123124
populateFrom="Feature",
124125
)
125126
]
@@ -131,7 +132,9 @@ def _generate_variables(self):
131132
inputType="select",
132133
variable_id="Feature",
133134
label="Feature",
134-
search=AutomaticDataQualityDashboard.DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE,
135+
search=self.DATA_QUALITY_METRICS_ENDPOINT_NAMESPACE
136+
+ f'Endpoint="{self.endpoint}" '
137+
+ f'MonitoringSchedule="{self.monitoring_schedule}" ',
135138
populateFrom="Feature",
136139
)
137140
]

src/sagemaker/dashboard/model_quality_dashboard.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,11 @@ def _generate_widgets(self):
135135
list_of_widgets = []
136136
metrics_to_graph = None
137137
if self.problem_type == "Regression":
138-
metrics_to_graph = AutomaticModelQualityDashboard.REGRESSION_MODEL_QUALITY_METRICS
138+
metrics_to_graph = self.REGRESSION_MODEL_QUALITY_METRICS
139139
elif self.problem_type == "BinaryClassification":
140-
metrics_to_graph = (
141-
AutomaticModelQualityDashboard.BINARY_CLASSIFICATION_MODEL_QUALITY_METRICS
142-
)
140+
metrics_to_graph = self.BINARY_CLASSIFICATION_MODEL_QUALITY_METRICS
143141
elif self.problem_type == "MulticlassClassification":
144-
metrics_to_graph = (
145-
AutomaticModelQualityDashboard.MULTICLASS_CLASSIFICATION_MODEL_QUALITY_METRICS
146-
)
142+
metrics_to_graph = self.MULTICLASS_CLASSIFICATION_MODEL_QUALITY_METRICS
147143
else:
148144
raise ValueError(
149145
"Parameter problem_type is invalid. Valid options are "

tests/integ/test_model_monitor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ def test_default_monitor_create_stop_and_start_monitoring_schedule_with_customiz
961961

962962
_wait_for_schedule_changes_to_apply(monitor=my_default_monitor)
963963

964+
964965
@pytest.mark.skipif(
965966
tests.integ.test_region() in tests.integ.NO_MODEL_MONITORING_REGIONS,
966967
reason="ModelMonitoring is not yet supported in this region.",
@@ -1082,6 +1083,7 @@ def test_default_monitor_create_and_update_schedule_config_with_customizations(
10821083

10831084
assert len(predictor.list_monitors()) > 0
10841085

1086+
10851087
@pytest.mark.skipif(
10861088
tests.integ.test_region() in tests.integ.NO_MODEL_MONITORING_REGIONS,
10871089
reason="ModelMonitoring is not yet supported in this region.",

tests/integ/test_model_quality_monitor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def scheduled_model_quality_monitor(
175175
)
176176
return model_quality_monitor
177177

178+
178179
@pytest.fixture
179180
def scheduled_model_quality_monitor_with_dashboard(
180181
sagemaker_session, model_quality_monitor, endpoint_name, ground_truth_input
@@ -260,14 +261,17 @@ def test_model_quality_monitor(
260261

261262
# delete schedule
262263
monitor.delete_monitoring_schedule()
263-
264+
264265

265266
@pytest.mark.skipif(
266267
tests.integ.test_region() in tests.integ.NO_MODEL_MONITORING_REGIONS,
267268
reason="ModelMonitoring is not yet supported in this region.",
268269
)
269270
def test_model_quality_monitor_with_dashboard(
270-
sagemaker_session, scheduled_model_quality_monitor_with_dashboard, endpoint_name, ground_truth_input
271+
sagemaker_session,
272+
scheduled_model_quality_monitor_with_dashboard,
273+
endpoint_name,
274+
ground_truth_input,
271275
):
272276
monitor = scheduled_model_quality_monitor_with_dashboard
273277
monitor._wait_for_schedule_changes_to_apply()
@@ -297,7 +301,7 @@ def test_model_quality_monitor_with_dashboard(
297301

298302
# update schedule
299303
monitor.update_monitoring_schedule(
300-
max_runtime_in_seconds=UPDATED_MAX_RUNTIME_IN_SECONDS,
304+
max_runtime_in_seconds=UPDATED_MAX_RUNTIME_IN_SECONDS,
301305
schedule_cron_expression=UPDATED_CRON,
302306
enable_automatic_dashboards=True,
303307
)

0 commit comments

Comments
 (0)