@@ -415,30 +415,34 @@ def create_monitoring_schedule(
415
415
if arguments is not None :
416
416
self .arguments = arguments
417
417
418
- self .sagemaker_session .create_monitoring_schedule (
419
- monitoring_schedule_name = self .monitoring_schedule_name ,
420
- schedule_expression = schedule_cron_expression ,
421
- statistics_s3_uri = statistics_s3_uri ,
422
- constraints_s3_uri = constraints_s3_uri ,
423
- monitoring_inputs = [normalized_monitoring_input ],
424
- monitoring_output_config = monitoring_output_config ,
425
- instance_count = self .instance_count ,
426
- instance_type = self .instance_type ,
427
- volume_size_in_gb = self .volume_size_in_gb ,
428
- volume_kms_key = self .volume_kms_key ,
429
- image_uri = self .image_uri ,
430
- entrypoint = self .entrypoint ,
431
- arguments = self .arguments ,
432
- record_preprocessor_source_uri = None ,
433
- post_analytics_processor_source_uri = None ,
434
- max_runtime_in_seconds = self .max_runtime_in_seconds ,
435
- environment = self .env ,
436
- network_config = network_config_dict ,
437
- role_arn = self .sagemaker_session .expand_role (self .role ),
438
- tags = self .tags ,
439
- data_analysis_start_time = data_analysis_start_time ,
440
- data_analysis_end_time = data_analysis_end_time ,
441
- )
418
+ try :
419
+ self .sagemaker_session .create_monitoring_schedule (
420
+ monitoring_schedule_name = self .monitoring_schedule_name ,
421
+ schedule_expression = schedule_cron_expression ,
422
+ statistics_s3_uri = statistics_s3_uri ,
423
+ constraints_s3_uri = constraints_s3_uri ,
424
+ monitoring_inputs = [normalized_monitoring_input ],
425
+ monitoring_output_config = monitoring_output_config ,
426
+ instance_count = self .instance_count ,
427
+ instance_type = self .instance_type ,
428
+ volume_size_in_gb = self .volume_size_in_gb ,
429
+ volume_kms_key = self .volume_kms_key ,
430
+ image_uri = self .image_uri ,
431
+ entrypoint = self .entrypoint ,
432
+ arguments = self .arguments ,
433
+ record_preprocessor_source_uri = None ,
434
+ post_analytics_processor_source_uri = None ,
435
+ max_runtime_in_seconds = self .max_runtime_in_seconds ,
436
+ environment = self .env ,
437
+ network_config = network_config_dict ,
438
+ role_arn = self .sagemaker_session .expand_role (self .role ),
439
+ tags = self .tags ,
440
+ data_analysis_start_time = data_analysis_start_time ,
441
+ data_analysis_end_time = data_analysis_end_time ,
442
+ )
443
+ except Exception :
444
+ self .monitoring_schedule_name = None
445
+ raise
442
446
443
447
def update_monitoring_schedule (
444
448
self ,
@@ -2054,6 +2058,7 @@ def create_monitoring_schedule(
2054
2058
self .monitoring_schedule_name = monitor_schedule_name
2055
2059
except Exception :
2056
2060
logger .exception ("Failed to create monitoring schedule." )
2061
+ self .monitoring_schedule_name = None
2057
2062
# noinspection PyBroadException
2058
2063
try :
2059
2064
self .sagemaker_session .sagemaker_client .delete_data_quality_job_definition (
@@ -3173,6 +3178,7 @@ def create_monitoring_schedule(
3173
3178
self .monitoring_schedule_name = monitor_schedule_name
3174
3179
except Exception :
3175
3180
logger .exception ("Failed to create monitoring schedule." )
3181
+ self .monitoring_schedule_name = None
3176
3182
# noinspection PyBroadException
3177
3183
try :
3178
3184
self .sagemaker_session .sagemaker_client .delete_model_quality_job_definition (
0 commit comments