31
31
32
32
# constants used for testing
33
33
34
+ NOTIFICATION_CHANNEL = "projects/123/notificationChannels/456"
34
35
PERMANENT_CHURN_MODEL_ID = "5295507484113371136"
35
36
CHURN_MODEL_PATH = "gs://mco-mm/churn"
36
37
DEFAULT_INPUT = {
90
91
# global test constants
91
92
sampling_strategy = model_monitoring .RandomSampleConfig (sample_rate = LOG_SAMPLE_RATE )
92
93
93
- alert_config = model_monitoring .EmailAlertConfig (
94
+ email_alert_config = model_monitoring .EmailAlertConfig (
94
95
user_emails = [USER_EMAIL ], enable_logging = True
95
96
)
96
97
98
+ alert_config = model_monitoring .AlertConfig (
99
+ user_emails = [USER_EMAIL ],
100
+ enable_logging = True ,
101
+ notification_channels = [NOTIFICATION_CHANNEL ],
102
+ )
103
+
97
104
schedule_config = model_monitoring .ScheduleConfig (monitor_interval = MONITOR_INTERVAL )
98
105
99
106
skew_config = model_monitoring .SkewDetectionConfig (
@@ -149,7 +156,7 @@ def test_mdm_two_models_one_valid_config(self, shared_state):
149
156
display_name = self ._make_display_name (key = JOB_NAME ),
150
157
logging_sampling_strategy = sampling_strategy ,
151
158
schedule_config = schedule_config ,
152
- alert_config = alert_config ,
159
+ alert_config = email_alert_config ,
153
160
objective_configs = objective_config ,
154
161
create_request_timeout = 3600 ,
155
162
project = e2e_base ._PROJECT ,
@@ -211,7 +218,7 @@ def test_mdm_pause_and_update_config(self, shared_state):
211
218
display_name = self ._make_display_name (key = JOB_NAME ),
212
219
logging_sampling_strategy = sampling_strategy ,
213
220
schedule_config = schedule_config ,
214
- alert_config = alert_config ,
221
+ alert_config = email_alert_config ,
215
222
objective_configs = model_monitoring .ObjectiveConfig (
216
223
drift_detection_config = drift_config
217
224
),
@@ -284,7 +291,7 @@ def test_mdm_two_models_two_valid_configs(self, shared_state):
284
291
display_name = self ._make_display_name (key = JOB_NAME ),
285
292
logging_sampling_strategy = sampling_strategy ,
286
293
schedule_config = schedule_config ,
287
- alert_config = alert_config ,
294
+ alert_config = email_alert_config ,
288
295
objective_configs = all_configs ,
289
296
create_request_timeout = 3600 ,
290
297
project = e2e_base ._PROJECT ,
@@ -338,7 +345,7 @@ def test_mdm_invalid_config_incorrect_model_id(self, shared_state):
338
345
display_name = self ._make_display_name (key = JOB_NAME ),
339
346
logging_sampling_strategy = sampling_strategy ,
340
347
schedule_config = schedule_config ,
341
- alert_config = alert_config ,
348
+ alert_config = email_alert_config ,
342
349
objective_configs = objective_config ,
343
350
create_request_timeout = 3600 ,
344
351
project = e2e_base ._PROJECT ,
@@ -358,7 +365,7 @@ def test_mdm_invalid_config_xai(self, shared_state):
358
365
display_name = self ._make_display_name (key = JOB_NAME ),
359
366
logging_sampling_strategy = sampling_strategy ,
360
367
schedule_config = schedule_config ,
361
- alert_config = alert_config ,
368
+ alert_config = email_alert_config ,
362
369
objective_configs = objective_config ,
363
370
create_request_timeout = 3600 ,
364
371
project = e2e_base ._PROJECT ,
@@ -388,7 +395,7 @@ def test_mdm_two_models_invalid_configs_xai(self, shared_state):
388
395
display_name = self ._make_display_name (key = JOB_NAME ),
389
396
logging_sampling_strategy = sampling_strategy ,
390
397
schedule_config = schedule_config ,
391
- alert_config = alert_config ,
398
+ alert_config = email_alert_config ,
392
399
objective_configs = all_configs ,
393
400
create_request_timeout = 3600 ,
394
401
project = e2e_base ._PROJECT ,
@@ -399,3 +406,31 @@ def test_mdm_two_models_invalid_configs_xai(self, shared_state):
399
406
"`explanation_config` should only be enabled if the model has `explanation_spec populated"
400
407
in str (e .value )
401
408
)
409
+
410
+ def test_mdm_notification_channel_alert_config (self , shared_state ):
411
+ self .endpoint = shared_state ["resources" ][0 ]
412
+ aiplatform .init (project = e2e_base ._PROJECT , location = e2e_base ._LOCATION )
413
+ # test model monitoring configurations
414
+ job = aiplatform .ModelDeploymentMonitoringJob .create (
415
+ display_name = self ._make_display_name (key = JOB_NAME ),
416
+ logging_sampling_strategy = sampling_strategy ,
417
+ schedule_config = schedule_config ,
418
+ alert_config = alert_config ,
419
+ objective_configs = objective_config ,
420
+ create_request_timeout = 3600 ,
421
+ project = e2e_base ._PROJECT ,
422
+ location = e2e_base ._LOCATION ,
423
+ endpoint = self .endpoint ,
424
+ )
425
+
426
+ gapic_job = job ._gca_resource
427
+ assert (
428
+ gapic_job .model_monitoring_alert_config .email_alert_config .user_emails
429
+ == [USER_EMAIL ]
430
+ )
431
+ assert gapic_job .model_monitoring_alert_config .enable_logging
432
+ assert gapic_job .model_monitoring_alert_config .notification_channels == [
433
+ NOTIFICATION_CHANNEL
434
+ ]
435
+
436
+ job .delete ()
0 commit comments