Skip to content

Commit fa73601

Browse files
authored
Merge branch 'master' into feat/s3-prefix-model-data-for-jumpstart-model
2 parents b7b4b3f + d960e49 commit fa73601

File tree

8 files changed

+681
-12
lines changed

8 files changed

+681
-12
lines changed

src/sagemaker/model_monitor/clarify_model_monitoring.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ def create_monitoring_schedule(
561561
schedule_cron_expression=None,
562562
enable_cloudwatch_metrics=True,
563563
batch_transform_input=None,
564+
data_analysis_start_time=None,
565+
data_analysis_end_time=None,
564566
):
565567
"""Creates a monitoring schedule.
566568
@@ -586,6 +588,10 @@ def create_monitoring_schedule(
586588
the baselining or monitoring jobs. (default: True)
587589
batch_transform_input (sagemaker.model_monitor.BatchTransformInput): Inputs to run
588590
the monitoring schedule on the batch transform (default: None)
591+
data_analysis_start_time (str): Start time for the data analysis window
592+
for the one time monitoring schedule (NOW), e.g. "-PT1H" (default: None)
593+
data_analysis_end_time (str): End time for the data analysis window
594+
for the one time monitoring schedule (NOW), e.g. "-PT1H" (default: None)
589595
"""
590596
# we default ground_truth_input to None in the function signature
591597
# but verify they are giving here for positional argument
@@ -610,6 +616,12 @@ def create_monitoring_schedule(
610616
_LOGGER.error(message)
611617
raise ValueError(message)
612618

619+
self._check_monitoring_schedule_cron_validity(
620+
schedule_cron_expression=schedule_cron_expression,
621+
data_analysis_start_time=data_analysis_start_time,
622+
data_analysis_end_time=data_analysis_end_time,
623+
)
624+
613625
# create job definition
614626
monitor_schedule_name = self._generate_monitoring_schedule_name(
615627
schedule_name=monitor_schedule_name
@@ -649,6 +661,8 @@ def create_monitoring_schedule(
649661
monitor_schedule_name=monitor_schedule_name,
650662
job_definition_name=new_job_definition_name,
651663
schedule_cron_expression=schedule_cron_expression,
664+
data_analysis_start_time=data_analysis_start_time,
665+
data_analysis_end_time=data_analysis_end_time,
652666
)
653667
self.job_definition_name = new_job_definition_name
654668
self.monitoring_schedule_name = monitor_schedule_name
@@ -684,6 +698,8 @@ def update_monitoring_schedule(
684698
env=None,
685699
network_config=None,
686700
batch_transform_input=None,
701+
data_analysis_start_time=None,
702+
data_analysis_end_time=None,
687703
):
688704
"""Updates the existing monitoring schedule.
689705
@@ -778,7 +794,12 @@ def update_monitoring_schedule(
778794
)
779795
self.sagemaker_session.sagemaker_client.create_model_bias_job_definition(**request_dict)
780796
try:
781-
self._update_monitoring_schedule(new_job_definition_name, schedule_cron_expression)
797+
self._update_monitoring_schedule(
798+
new_job_definition_name,
799+
schedule_cron_expression,
800+
data_analysis_start_time=data_analysis_start_time,
801+
data_analysis_end_time=data_analysis_end_time,
802+
)
782803
self.job_definition_name = new_job_definition_name
783804
if role is not None:
784805
self.role = role
@@ -988,6 +1009,8 @@ def create_monitoring_schedule(
9881009
schedule_cron_expression=None,
9891010
enable_cloudwatch_metrics=True,
9901011
batch_transform_input=None,
1012+
data_analysis_start_time=None,
1013+
data_analysis_end_time=None,
9911014
):
9921015
"""Creates a monitoring schedule.
9931016
@@ -1011,6 +1034,10 @@ def create_monitoring_schedule(
10111034
the baselining or monitoring jobs.
10121035
batch_transform_input (sagemaker.model_monitor.BatchTransformInput): Inputs to
10131036
run the monitoring schedule on the batch transform
1037+
data_analysis_start_time (str): Start time for the data analysis window
1038+
for the one time monitoring schedule (NOW), e.g. "-PT1H" (default: None)
1039+
data_analysis_end_time (str): End time for the data analysis window
1040+
for the one time monitoring schedule (NOW), e.g. "-PT1H" (default: None)
10141041
"""
10151042
if self.job_definition_name is not None or self.monitoring_schedule_name is not None:
10161043
message = (
@@ -1030,6 +1057,12 @@ def create_monitoring_schedule(
10301057
_LOGGER.error(message)
10311058
raise ValueError(message)
10321059

1060+
self._check_monitoring_schedule_cron_validity(
1061+
schedule_cron_expression=schedule_cron_expression,
1062+
data_analysis_start_time=data_analysis_start_time,
1063+
data_analysis_end_time=data_analysis_end_time,
1064+
)
1065+
10331066
# create job definition
10341067
monitor_schedule_name = self._generate_monitoring_schedule_name(
10351068
schedule_name=monitor_schedule_name
@@ -1104,6 +1137,8 @@ def update_monitoring_schedule(
11041137
env=None,
11051138
network_config=None,
11061139
batch_transform_input=None,
1140+
data_analysis_start_time=None,
1141+
data_analysis_end_time=None,
11071142
):
11081143
"""Updates the existing monitoring schedule.
11091144
@@ -1144,6 +1179,10 @@ def update_monitoring_schedule(
11441179
inter-container traffic, security group IDs, and subnets.
11451180
batch_transform_input (sagemaker.model_monitor.BatchTransformInput): Inputs to
11461181
run the monitoring schedule on the batch transform
1182+
data_analysis_start_time (str): Start time for the data analysis window
1183+
for the one time monitoring schedule (NOW), e.g. "-PT1H" (default: None)
1184+
data_analysis_end_time (str): End time for the data analysis window
1185+
for the one time monitoring schedule (NOW), e.g. "-PT1H" (default: None)
11471186
"""
11481187
valid_args = {
11491188
arg: value for arg, value in locals().items() if arg != "self" and value is not None
@@ -1200,7 +1239,12 @@ def update_monitoring_schedule(
12001239
**request_dict
12011240
)
12021241
try:
1203-
self._update_monitoring_schedule(new_job_definition_name, schedule_cron_expression)
1242+
self._update_monitoring_schedule(
1243+
new_job_definition_name,
1244+
schedule_cron_expression,
1245+
data_analysis_start_time=data_analysis_start_time,
1246+
data_analysis_end_time=data_analysis_end_time,
1247+
)
12041248
self.job_definition_name = new_job_definition_name
12051249
if role is not None:
12061250
self.role = role

src/sagemaker/model_monitor/cron_expression_generator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ def daily_every_x_hours(hour_interval, starting_hour=0):
7575
7676
"""
7777
return "cron(0 {}/{} ? * * *)".format(starting_hour, hour_interval)
78+
79+
@staticmethod
80+
def now():
81+
"""Returns the string used to depict the one-time schedule"""
82+
return "NOW"

0 commit comments

Comments
 (0)