@@ -44,9 +44,10 @@ def test_statistics_object_creation_from_file_path_with_customizations(
4444 assert statistics .body_dict ["dataset" ]["item_count" ] == 418
4545
4646
47- def test_statistics_object_creation_from_file_path_without_customizations ():
47+ def test_statistics_object_creation_from_file_path_without_customizations (sagemaker_session ):
4848 statistics = Statistics .from_file_path (
49- statistics_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/statistics.json" )
49+ statistics_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/statistics.json" ),
50+ sagemaker_session = sagemaker_session ,
5051 )
5152
5253 assert statistics .file_s3_uri .startswith ("s3://" )
@@ -74,11 +75,13 @@ def test_statistics_object_creation_from_string_with_customizations(
7475 assert statistics .body_dict ["dataset" ]["item_count" ] == 418
7576
7677
77- def test_statistics_object_creation_from_string_without_customizations ():
78+ def test_statistics_object_creation_from_string_without_customizations (sagemaker_session ):
7879 with open (os .path .join (tests .integ .DATA_DIR , "monitor/statistics.json" ), "r" ) as f :
7980 file_body = f .read ()
8081
81- statistics = Statistics .from_string (statistics_file_string = file_body )
82+ statistics = Statistics .from_string (
83+ statistics_file_string = file_body , sagemaker_session = sagemaker_session
84+ )
8285
8386 assert statistics .file_s3_uri .startswith ("s3://" )
8487 assert statistics .file_s3_uri .endswith ("statistics.json" )
@@ -133,9 +136,13 @@ def test_statistics_object_creation_from_s3_uri_without_customizations(sagemaker
133136 file_name ,
134137 )
135138
136- s3_uri = S3Uploader .upload_string_as_file_body (body = file_body , desired_s3_uri = desired_s3_uri )
139+ s3_uri = S3Uploader .upload_string_as_file_body (
140+ body = file_body , desired_s3_uri = desired_s3_uri , session = sagemaker_session
141+ )
137142
138- statistics = Statistics .from_s3_uri (statistics_file_s3_uri = s3_uri )
143+ statistics = Statistics .from_s3_uri (
144+ statistics_file_s3_uri = s3_uri , sagemaker_session = sagemaker_session
145+ )
139146
140147 assert statistics .file_s3_uri .startswith ("s3://" )
141148 assert statistics .file_s3_uri .endswith ("statistics.json" )
@@ -181,14 +188,17 @@ def test_constraints_object_creation_from_file_path_with_customizations(
181188
182189 constraints .save ()
183190
184- new_constraints = Constraints .from_s3_uri (constraints .file_s3_uri )
191+ new_constraints = Constraints .from_s3_uri (
192+ constraints .file_s3_uri , sagemaker_session = sagemaker_session
193+ )
185194
186195 assert new_constraints .body_dict ["monitoring_config" ]["evaluate_constraints" ] == "Disabled"
187196
188197
189- def test_constraints_object_creation_from_file_path_without_customizations ():
198+ def test_constraints_object_creation_from_file_path_without_customizations (sagemaker_session ):
190199 constraints = Constraints .from_file_path (
191- constraints_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/constraints.json" )
200+ constraints_file_path = os .path .join (tests .integ .DATA_DIR , "monitor/constraints.json" ),
201+ sagemaker_session = sagemaker_session ,
192202 )
193203
194204 assert constraints .file_s3_uri .startswith ("s3://" )
@@ -216,11 +226,13 @@ def test_constraints_object_creation_from_string_with_customizations(
216226 assert constraints .body_dict ["monitoring_config" ]["evaluate_constraints" ] == "Enabled"
217227
218228
219- def test_constraints_object_creation_from_string_without_customizations ():
229+ def test_constraints_object_creation_from_string_without_customizations (sagemaker_session ):
220230 with open (os .path .join (tests .integ .DATA_DIR , "monitor/constraints.json" ), "r" ) as f :
221231 file_body = f .read ()
222232
223- constraints = Constraints .from_string (constraints_file_string = file_body )
233+ constraints = Constraints .from_string (
234+ constraints_file_string = file_body , sagemaker_session = sagemaker_session
235+ )
224236
225237 assert constraints .file_s3_uri .startswith ("s3://" )
226238 assert constraints .file_s3_uri .endswith ("constraints.json" )
@@ -275,9 +287,13 @@ def test_constraints_object_creation_from_s3_uri_without_customizations(sagemake
275287 file_name ,
276288 )
277289
278- s3_uri = S3Uploader .upload_string_as_file_body (body = file_body , desired_s3_uri = desired_s3_uri )
290+ s3_uri = S3Uploader .upload_string_as_file_body (
291+ body = file_body , desired_s3_uri = desired_s3_uri , session = sagemaker_session
292+ )
279293
280- constraints = Constraints .from_s3_uri (constraints_file_s3_uri = s3_uri )
294+ constraints = Constraints .from_s3_uri (
295+ constraints_file_s3_uri = s3_uri , sagemaker_session = sagemaker_session
296+ )
281297
282298 assert constraints .file_s3_uri .startswith ("s3://" )
283299 assert constraints .file_s3_uri .endswith ("constraints.json" )
@@ -302,11 +318,14 @@ def test_constraint_violations_object_creation_from_file_path_with_customization
302318 assert constraint_violations .body_dict ["violations" ][0 ]["feature_name" ] == "store_and_fwd_flag"
303319
304320
305- def test_constraint_violations_object_creation_from_file_path_without_customizations ():
321+ def test_constraint_violations_object_creation_from_file_path_without_customizations (
322+ sagemaker_session
323+ ):
306324 constraint_violations = ConstraintViolations .from_file_path (
307325 constraint_violations_file_path = os .path .join (
308326 tests .integ .DATA_DIR , "monitor/constraint_violations.json"
309- )
327+ ),
328+ sagemaker_session = sagemaker_session ,
310329 )
311330
312331 assert constraint_violations .file_s3_uri .startswith ("s3://" )
@@ -334,12 +353,14 @@ def test_constraint_violations_object_creation_from_string_with_customizations(
334353 assert constraint_violations .body_dict ["violations" ][0 ]["feature_name" ] == "store_and_fwd_flag"
335354
336355
337- def test_constraint_violations_object_creation_from_string_without_customizations ():
356+ def test_constraint_violations_object_creation_from_string_without_customizations (
357+ sagemaker_session
358+ ):
338359 with open (os .path .join (tests .integ .DATA_DIR , "monitor/constraint_violations.json" ), "r" ) as f :
339360 file_body = f .read ()
340361
341362 constraint_violations = ConstraintViolations .from_string (
342- constraint_violations_file_string = file_body
363+ constraint_violations_file_string = file_body , sagemaker_session = sagemaker_session
343364 )
344365
345366 assert constraint_violations .file_s3_uri .startswith ("s3://" )
@@ -397,10 +418,12 @@ def test_constraint_violations_object_creation_from_s3_uri_without_customization
397418 file_name ,
398419 )
399420
400- s3_uri = S3Uploader .upload_string_as_file_body (body = file_body , desired_s3_uri = desired_s3_uri )
421+ s3_uri = S3Uploader .upload_string_as_file_body (
422+ body = file_body , desired_s3_uri = desired_s3_uri , session = sagemaker_session
423+ )
401424
402425 constraint_violations = ConstraintViolations .from_s3_uri (
403- constraint_violations_file_s3_uri = s3_uri
426+ constraint_violations_file_s3_uri = s3_uri , sagemaker_session = sagemaker_session
404427 )
405428
406429 assert constraint_violations .file_s3_uri .startswith ("s3://" )
0 commit comments