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