@@ -2198,7 +2198,7 @@ def update_monitoring_schedule(
2198
2198
env = None ,
2199
2199
network_config = None ,
2200
2200
enable_cloudwatch_metrics = None ,
2201
- enable_automatic_dashboard = False ,
2201
+ enable_automatic_dashboard = None ,
2202
2202
dashboard_name = None ,
2203
2203
role = None ,
2204
2204
batch_transform_input = None ,
@@ -2266,6 +2266,15 @@ def update_monitoring_schedule(
2266
2266
)
2267
2267
logger .error (message )
2268
2268
raise ValueError (message )
2269
+
2270
+ # error checking for dashboard
2271
+ if enable_automatic_dashboard :
2272
+ self ._check_dashboard_validity_without_checking_in_use (
2273
+ monitor_schedule_name = self .monitoring_schedule_name ,
2274
+ enable_cloudwatch_metrics = enable_cloudwatch_metrics ,
2275
+ enable_automatic_dashboard = enable_automatic_dashboard ,
2276
+ dashboard_name = dashboard_name ,
2277
+ )
2269
2278
2270
2279
# check if this schedule is in v2 format and update as per v2 format if it is
2271
2280
if self .job_definition_name is not None :
@@ -2396,6 +2405,26 @@ def update_monitoring_schedule(
2396
2405
)
2397
2406
2398
2407
self ._wait_for_schedule_changes_to_apply ()
2408
+
2409
+ if enable_automatic_dashboard :
2410
+ if dashboard_name is None :
2411
+ dashboard_name = self .monitoring_schedule_name
2412
+ if isinstance (endpoint_input , EndpointInput ):
2413
+ endpoint_name = endpoint_input .endpoint_name
2414
+ else :
2415
+ endpoint_name = endpoint_input
2416
+
2417
+ cw_client = self .sagemaker_session .boto_session .client ("cloudwatch" )
2418
+ cw_client .put_dashboard (
2419
+ DashboardName = dashboard_name ,
2420
+ DashboardBody = AutomaticDataQualityDashboard (
2421
+ endpoint_name = endpoint_name ,
2422
+ monitoring_schedule_name = self .monitoring_schedule_name ,
2423
+ batch_transform_input = batch_transform_input ,
2424
+ region_name = self .sagemaker_session .boto_region_name ,
2425
+ ).to_json (),
2426
+ )
2427
+
2399
2428
2400
2429
def _update_data_quality_monitoring_schedule (
2401
2430
self ,
@@ -2443,10 +2472,6 @@ def _update_data_quality_monitoring_schedule(
2443
2472
expressions. Default: Daily.
2444
2473
enable_cloudwatch_metrics (bool): Whether to publish cloudwatch metrics as part of
2445
2474
the baselining or monitoring jobs.
2446
- enable_automatic_dashboard (bool): Whether to publish an automatic dashboard as part of
2447
- the baselining or monitoring jobs.
2448
- dashboard_name (str): Name to use for the published dashboard. When not provided,
2449
- defaults to monitoring schedule name.
2450
2475
role (str): An AWS IAM role. The Amazon SageMaker jobs use this role.
2451
2476
instance_count (int): The number of instances to run
2452
2477
the jobs with.
@@ -2503,15 +2528,6 @@ def _update_data_quality_monitoring_schedule(
2503
2528
"ScheduleExpression"
2504
2529
]
2505
2530
2506
- # error checking for dashboard
2507
- # if enable_automatic_dashboard:
2508
- # self._check_dashboard_validity_without_checking_in_use(
2509
- # monitor_schedule_name=self.monitoring_schedule_name,
2510
- # enable_cloudwatch_metrics=enable_cloudwatch_metrics,
2511
- # enable_automatic_dashboard=enable_automatic_dashboard,
2512
- # dashboard_name=dashboard_name,
2513
- # )
2514
-
2515
2531
# Need to update schedule with a new job definition
2516
2532
job_desc = self .sagemaker_session .sagemaker_client .describe_data_quality_job_definition (
2517
2533
JobDefinitionName = self .job_definition_name
@@ -2575,24 +2591,6 @@ def _update_data_quality_monitoring_schedule(
2575
2591
logger .exception (message )
2576
2592
raise
2577
2593
2578
- # if enable_automatic_dashboard:
2579
- # if dashboard_name is None:
2580
- # dashboard_name = self.monitoring_schedule_name
2581
- # if isinstance(endpoint_input, EndpointInput):
2582
- # endpoint_name = endpoint_input.endpoint_name
2583
- # else:
2584
- # endpoint_name = endpoint_input
2585
-
2586
- # cw_client = self.sagemaker_session.boto_session.client("cloudwatch")
2587
- # cw_client.put_dashboard(
2588
- # DashboardName=dashboard_name,
2589
- # DashboardBody=AutomaticDataQualityDashboard(
2590
- # endpoint_name=endpoint_name,
2591
- # monitoring_schedule_name=self.monitoring_schedule_name,
2592
- # batch_transform_input=batch_transform_input,
2593
- # region_name=self.sagemaker_session.boto_region_name,
2594
- # ).to_json(),
2595
- # )
2596
2594
2597
2595
def delete_monitoring_schedule (self ):
2598
2596
"""Deletes the monitoring schedule and its job definition."""
@@ -3381,6 +3379,8 @@ def update_monitoring_schedule(
3381
3379
constraints = None ,
3382
3380
schedule_cron_expression = None ,
3383
3381
enable_cloudwatch_metrics = None ,
3382
+ enable_automatic_dashboard = None ,
3383
+ dashboard_name = None ,
3384
3384
role = None ,
3385
3385
instance_count = None ,
3386
3386
instance_type = None ,
@@ -3472,13 +3472,13 @@ def update_monitoring_schedule(
3472
3472
logger .error (message )
3473
3473
raise ValueError (message )
3474
3474
3475
- # if enable_automatic_dashboard:
3476
- # self._check_dashboard_validity_without_checking_in_use(
3477
- # monitor_schedule_name=self.monitoring_schedule_name,
3478
- # enable_cloudwatch_metrics=enable_cloudwatch_metrics,
3479
- # enable_automatic_dashboard=enable_automatic_dashboard,
3480
- # dashboard_name=dashboard_name,
3481
- # )
3475
+ if enable_automatic_dashboard :
3476
+ self ._check_dashboard_validity_without_checking_in_use (
3477
+ monitor_schedule_name = self .monitoring_schedule_name ,
3478
+ enable_cloudwatch_metrics = enable_cloudwatch_metrics ,
3479
+ enable_automatic_dashboard = enable_automatic_dashboard ,
3480
+ dashboard_name = dashboard_name ,
3481
+ )
3482
3482
3483
3483
# Need to update schedule with a new job definition
3484
3484
job_desc = self .sagemaker_session .sagemaker_client .describe_model_quality_job_definition (
@@ -3549,24 +3549,24 @@ def update_monitoring_schedule(
3549
3549
logger .exception (message )
3550
3550
raise
3551
3551
3552
- # if enable_automatic_dashboard:
3553
- # if dashboard_name is None:
3554
- # dashboard_name = self.monitoring_schedule_name
3555
- # if isinstance(endpoint_input, EndpointInput):
3556
- # endpoint_name = endpoint_input.endpoint_name
3557
- # else:
3558
- # endpoint_name = endpoint_input
3559
- # cw_client = self.sagemaker_session.boto_session.client("cloudwatch")
3560
- # cw_client.put_dashboard(
3561
- # DashboardName=dashboard_name,
3562
- # DashboardBody=AutomaticModelQualityDashboard(
3563
- # endpoint_name=endpoint_name,
3564
- # monitoring_schedule_name=self.monitoring_schedule_name,
3565
- # batch_transform_input=batch_transform_input,
3566
- # problem_type=problem_type,
3567
- # region_name=self.sagemaker_session.boto_region_name,
3568
- # ).to_json(),
3569
- # )
3552
+ if enable_automatic_dashboard :
3553
+ if dashboard_name is None :
3554
+ dashboard_name = self .monitoring_schedule_name
3555
+ if isinstance (endpoint_input , EndpointInput ):
3556
+ endpoint_name = endpoint_input .endpoint_name
3557
+ else :
3558
+ endpoint_name = endpoint_input
3559
+ cw_client = self .sagemaker_session .boto_session .client ("cloudwatch" )
3560
+ cw_client .put_dashboard (
3561
+ DashboardName = dashboard_name ,
3562
+ DashboardBody = AutomaticModelQualityDashboard (
3563
+ endpoint_name = endpoint_name ,
3564
+ monitoring_schedule_name = self .monitoring_schedule_name ,
3565
+ batch_transform_input = batch_transform_input ,
3566
+ problem_type = problem_type ,
3567
+ region_name = self .sagemaker_session .boto_region_name ,
3568
+ ).to_json (),
3569
+ )
3570
3570
3571
3571
def delete_monitoring_schedule (self ):
3572
3572
"""Deletes the monitoring schedule and its job definition."""
0 commit comments