@@ -486,6 +486,38 @@ def test_default_monitor_suggest_baseline_and_create_monitoring_schedule_with_cu
486
486
assert len (summary ["MonitoringScheduleSummaries" ]) > 0
487
487
488
488
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
+
489
521
@pytest .mark .skipif (
490
522
tests .integ .test_region () in tests .integ .NO_MODEL_MONITORING_REGIONS ,
491
523
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
1643
1675
output_kms_key ,
1644
1676
updated_volume_kms_key ,
1645
1677
updated_output_kms_key ,
1678
+ capfd ,
1646
1679
):
1647
1680
baseline_dataset = os .path .join (DATA_DIR , "monitor/baseline_dataset.csv" )
1648
1681
@@ -1771,6 +1804,10 @@ def test_byoc_monitor_attach_followed_by_baseline_and_update_monitoring_schedule
1771
1804
1772
1805
_wait_for_schedule_changes_to_apply (monitor = my_attached_monitor )
1773
1806
1807
+ _check_processing_logs_generated (
1808
+ monitor = my_attached_monitor , schedule_description = schedule_description , capfd = capfd
1809
+ )
1810
+
1774
1811
my_attached_monitor .stop_monitoring_schedule ()
1775
1812
1776
1813
_wait_for_schedule_changes_to_apply (monitor = my_attached_monitor )
@@ -1877,6 +1914,13 @@ def test_default_monitor_monitoring_alerts(sagemaker_session, predictor):
1877
1914
my_default_monitor .delete_monitoring_schedule ()
1878
1915
1879
1916
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
+
1880
1924
def _wait_for_schedule_changes_to_apply (monitor ):
1881
1925
"""Waits for the monitor to no longer be in the 'Pending' state. Updates take under a minute
1882
1926
to apply.
0 commit comments