@@ -486,6 +486,38 @@ def test_default_monitor_suggest_baseline_and_create_monitoring_schedule_with_cu
486486 assert len (summary ["MonitoringScheduleSummaries" ]) > 0
487487
488488
489+ def test_default_monitor_display_logs_errors (sagemaker_session ):
490+ my_default_monitor = DefaultModelMonitor (role = ROLE , sagemaker_session = sagemaker_session )
491+
492+ data_captured_destination_s3_uri = os .path .join (
493+ "s3://" ,
494+ sagemaker_session .default_bucket (),
495+ "sagemaker-serving-batch-transform" ,
496+ str (uuid .uuid4 ()),
497+ )
498+
499+ batch_transform_input = BatchTransformInput (
500+ data_captured_destination_s3_uri = data_captured_destination_s3_uri ,
501+ destination = "/opt/ml/processing/output" ,
502+ dataset_format = MonitoringDatasetFormat .csv (header = False ),
503+ )
504+
505+ my_default_monitor .create_monitoring_schedule (
506+ batch_transform_input = batch_transform_input ,
507+ schedule_cron_expression = CronExpressionGenerator .hourly (),
508+ )
509+
510+ _wait_for_schedule_changes_to_apply (monitor = my_default_monitor )
511+
512+ try :
513+ my_default_monitor .get_latest_execution_logs (wait = False )
514+ except ValueError as ve :
515+ assert "No execution jobs were kicked off." in str (ve )
516+
517+ my_default_monitor .stop_monitoring_schedule ()
518+ my_default_monitor .delete_monitoring_schedule ()
519+
520+
489521@pytest .mark .skipif (
490522 tests .integ .test_region () in tests .integ .NO_MODEL_MONITORING_REGIONS ,
491523 reason = "ModelMonitoring is not yet supported in this region." ,
@@ -1643,6 +1675,7 @@ def test_byoc_monitor_attach_followed_by_baseline_and_update_monitoring_schedule
16431675 output_kms_key ,
16441676 updated_volume_kms_key ,
16451677 updated_output_kms_key ,
1678+ capfd ,
16461679):
16471680 baseline_dataset = os .path .join (DATA_DIR , "monitor/baseline_dataset.csv" )
16481681
@@ -1771,6 +1804,10 @@ def test_byoc_monitor_attach_followed_by_baseline_and_update_monitoring_schedule
17711804
17721805 _wait_for_schedule_changes_to_apply (monitor = my_attached_monitor )
17731806
1807+ _check_processing_logs_generated (
1808+ monitor = my_attached_monitor , schedule_description = schedule_description , capfd = capfd
1809+ )
1810+
17741811 my_attached_monitor .stop_monitoring_schedule ()
17751812
17761813 _wait_for_schedule_changes_to_apply (monitor = my_attached_monitor )
@@ -1877,6 +1914,13 @@ def test_default_monitor_monitoring_alerts(sagemaker_session, predictor):
18771914 my_default_monitor .delete_monitoring_schedule ()
18781915
18791916
1917+ def _check_processing_logs_generated (monitor , schedule_description , capfd ):
1918+ monitor .get_latest_execution_logs (wait = False )
1919+ out , _ = capfd .readouterr ()
1920+ assert len (out ) > 0
1921+ assert schedule_description .get ("LastMonitoringExecutionSummary" )["ProcessingJobArn" ] in out
1922+
1923+
18801924def _wait_for_schedule_changes_to_apply (monitor ):
18811925 """Waits for the monitor to no longer be in the 'Pending' state. Updates take under a minute
18821926 to apply.
0 commit comments