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