@@ -281,7 +281,6 @@ def updated_output_kms_key(sagemaker_session):
281
281
tests .integ .test_region () in tests .integ .NO_MODEL_MONITORING_REGIONS ,
282
282
reason = "ModelMonitoring is not yet supported in this region." ,
283
283
)
284
- @pytest .mark .release
285
284
def test_default_monitoring_batch_transform_schedule_name (
286
285
sagemaker_session , output_kms_key , volume_kms_key
287
286
):
@@ -359,7 +358,6 @@ def test_default_monitoring_batch_transform_schedule_name(
359
358
tests .integ .test_region () in tests .integ .NO_MODEL_MONITORING_REGIONS ,
360
359
reason = "ModelMonitoring is not yet supported in this region." ,
361
360
)
362
- @pytest .mark .release
363
361
def test_default_monitor_suggest_baseline_and_create_monitoring_schedule_with_customizations (
364
362
sagemaker_session , output_kms_key , volume_kms_key , predictor
365
363
):
@@ -1852,3 +1850,195 @@ def _verify_default_monitoring_schedule_with_batch_transform(
1852
1850
)
1853
1851
else :
1854
1852
assert network_config is None
1853
+
1854
+
1855
+ def test_default_update_monitoring_batch_transform (
1856
+ sagemaker_session , output_kms_key , volume_kms_key
1857
+ ):
1858
+ my_default_monitor = DefaultModelMonitor (
1859
+ role = ROLE ,
1860
+ instance_count = INSTANCE_COUNT ,
1861
+ instance_type = INSTANCE_TYPE ,
1862
+ volume_size_in_gb = VOLUME_SIZE_IN_GB ,
1863
+ volume_kms_key = volume_kms_key ,
1864
+ output_kms_key = output_kms_key ,
1865
+ max_runtime_in_seconds = MAX_RUNTIME_IN_SECONDS ,
1866
+ sagemaker_session = sagemaker_session ,
1867
+ env = ENVIRONMENT ,
1868
+ tags = TAGS ,
1869
+ network_config = NETWORK_CONFIG ,
1870
+ )
1871
+
1872
+ output_s3_uri = os .path .join (
1873
+ "s3://" ,
1874
+ sagemaker_session .default_bucket (),
1875
+ "integ-test-monitoring-output-bucket" ,
1876
+ str (uuid .uuid4 ()),
1877
+ )
1878
+
1879
+ data_captured_destination_s3_uri = os .path .join (
1880
+ "s3://" ,
1881
+ sagemaker_session .default_bucket (),
1882
+ "sagemaker-serving-batch-transform" ,
1883
+ str (uuid .uuid4 ()),
1884
+ )
1885
+
1886
+ batch_transform_input = BatchTransformInput (
1887
+ data_captured_destination_s3_uri = data_captured_destination_s3_uri ,
1888
+ destination = "/opt/ml/processing/output" ,
1889
+ dataset_format = MonitoringDatasetFormat .csv (header = False ),
1890
+ )
1891
+
1892
+ statistics = Statistics .from_file_path (
1893
+ statistics_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/statistics.json" ),
1894
+ sagemaker_session = sagemaker_session ,
1895
+ )
1896
+
1897
+ constraints = Constraints .from_file_path (
1898
+ constraints_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/constraints.json" ),
1899
+ sagemaker_session = sagemaker_session ,
1900
+ )
1901
+
1902
+ my_default_monitor .create_monitoring_schedule (
1903
+ batch_transform_input = batch_transform_input ,
1904
+ output_s3_uri = output_s3_uri ,
1905
+ statistics = statistics ,
1906
+ constraints = constraints ,
1907
+ schedule_cron_expression = HOURLY_CRON_EXPRESSION ,
1908
+ enable_cloudwatch_metrics = ENABLE_CLOUDWATCH_METRICS ,
1909
+ )
1910
+
1911
+ _wait_for_schedule_changes_to_apply (monitor = my_default_monitor )
1912
+
1913
+ data_captured_destination_s3_uri = os .path .join (
1914
+ "s3://" ,
1915
+ sagemaker_session .default_bucket (),
1916
+ "sagemaker-tensorflow-serving-batch-transform" ,
1917
+ str (uuid .uuid4 ()),
1918
+ )
1919
+
1920
+ batch_transform_input = BatchTransformInput (
1921
+ data_captured_destination_s3_uri = data_captured_destination_s3_uri ,
1922
+ destination = "/opt/ml/processing/output" ,
1923
+ dataset_format = MonitoringDatasetFormat .csv (header = False ),
1924
+ )
1925
+
1926
+ my_default_monitor .update_monitoring_schedule (
1927
+ batch_transform_input = batch_transform_input ,
1928
+ )
1929
+
1930
+ _wait_for_schedule_changes_to_apply (monitor = my_default_monitor )
1931
+
1932
+ schedule_description = my_default_monitor .describe_schedule ()
1933
+
1934
+ _verify_default_monitoring_schedule_with_batch_transform (
1935
+ sagemaker_session = sagemaker_session ,
1936
+ schedule_description = schedule_description ,
1937
+ cron_expression = HOURLY_CRON_EXPRESSION ,
1938
+ statistics = statistics ,
1939
+ constraints = constraints ,
1940
+ output_kms_key = output_kms_key ,
1941
+ volume_kms_key = volume_kms_key ,
1942
+ network_config = NETWORK_CONFIG ,
1943
+ )
1944
+
1945
+ my_default_monitor .stop_monitoring_schedule ()
1946
+ my_default_monitor .delete_monitoring_schedule ()
1947
+
1948
+
1949
+ def test_byoc_monitoring_schedule_name_update_batch (
1950
+ sagemaker_session , output_kms_key , volume_kms_key
1951
+ ):
1952
+ byoc_env = ENVIRONMENT .copy ()
1953
+ byoc_env ["dataset_format" ] = json .dumps (DatasetFormat .csv (header = False ))
1954
+ byoc_env ["dataset_source" ] = "/opt/ml/processing/input/baseline_dataset_input"
1955
+ byoc_env ["output_path" ] = os .path .join ("/opt/ml/processing/output" )
1956
+ byoc_env ["publish_cloudwatch_metrics" ] = "Disabled"
1957
+
1958
+ my_byoc_monitor = ModelMonitor (
1959
+ role = ROLE ,
1960
+ image_uri = DefaultModelMonitor ._get_default_image_uri (
1961
+ sagemaker_session .boto_session .region_name
1962
+ ),
1963
+ instance_count = INSTANCE_COUNT ,
1964
+ instance_type = INSTANCE_TYPE ,
1965
+ volume_size_in_gb = VOLUME_SIZE_IN_GB ,
1966
+ volume_kms_key = volume_kms_key ,
1967
+ output_kms_key = output_kms_key ,
1968
+ max_runtime_in_seconds = MAX_RUNTIME_IN_SECONDS ,
1969
+ sagemaker_session = sagemaker_session ,
1970
+ env = byoc_env ,
1971
+ tags = TAGS ,
1972
+ network_config = NETWORK_CONFIG ,
1973
+ )
1974
+
1975
+ output_s3_uri = os .path .join (
1976
+ "s3://" ,
1977
+ sagemaker_session .default_bucket (),
1978
+ "integ-test-monitoring-output-bucket" ,
1979
+ str (uuid .uuid4 ()),
1980
+ )
1981
+
1982
+ statistics = Statistics .from_file_path (
1983
+ statistics_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/statistics.json" ),
1984
+ sagemaker_session = sagemaker_session ,
1985
+ )
1986
+
1987
+ constraints = Constraints .from_file_path (
1988
+ constraints_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/constraints.json" ),
1989
+ sagemaker_session = sagemaker_session ,
1990
+ )
1991
+
1992
+ data_captured_destination_s3_uri = os .path .join (
1993
+ "s3://" ,
1994
+ sagemaker_session .default_bucket (),
1995
+ "sagemaker-serving-batch-transform" ,
1996
+ str (uuid .uuid4 ()),
1997
+ )
1998
+
1999
+ batch_transform_input = BatchTransformInput (
2000
+ data_captured_destination_s3_uri = data_captured_destination_s3_uri ,
2001
+ destination = "/opt/ml/processing/output" ,
2002
+ dataset_format = MonitoringDatasetFormat .csv (header = False ),
2003
+ )
2004
+
2005
+ my_byoc_monitor .create_monitoring_schedule (
2006
+ endpoint_input = batch_transform_input ,
2007
+ output = MonitoringOutput (source = "/opt/ml/processing/output" , destination = output_s3_uri ),
2008
+ statistics = statistics ,
2009
+ constraints = constraints ,
2010
+ schedule_cron_expression = HOURLY_CRON_EXPRESSION ,
2011
+ )
2012
+
2013
+ _wait_for_schedule_changes_to_apply (monitor = my_byoc_monitor )
2014
+
2015
+ data_captured_destination_s3_uri = os .path .join (
2016
+ "s3://" ,
2017
+ sagemaker_session .default_bucket (),
2018
+ "sagemaker-tensorflow-serving-batch-transform" ,
2019
+ str (uuid .uuid4 ()),
2020
+ )
2021
+
2022
+ batch_transform_input = BatchTransformInput (
2023
+ data_captured_destination_s3_uri = data_captured_destination_s3_uri ,
2024
+ destination = "/opt/ml/processing/output" ,
2025
+ dataset_format = MonitoringDatasetFormat .csv (header = False ),
2026
+ )
2027
+
2028
+ my_byoc_monitor .update_monitoring_schedule (
2029
+ batch_transform_input = batch_transform_input ,
2030
+ )
2031
+
2032
+ _wait_for_schedule_changes_to_apply (monitor = my_byoc_monitor )
2033
+
2034
+ schedule_description = my_byoc_monitor .describe_schedule ()
2035
+
2036
+ assert (
2037
+ data_captured_destination_s3_uri
2038
+ == schedule_description ["MonitoringScheduleConfig" ]["MonitoringJobDefinition" ][
2039
+ "MonitoringInputs"
2040
+ ][0 ]["BatchTransformInput" ]["DataCapturedDestinationS3Uri" ]
2041
+ )
2042
+
2043
+ my_byoc_monitor .stop_monitoring_schedule ()
2044
+ my_byoc_monitor .delete_monitoring_schedule ()
0 commit comments