@@ -44,9 +44,10 @@ def test_statistics_object_creation_from_file_path_with_customizations(
44
44
assert statistics .body_dict ["dataset" ]["item_count" ] == 418
45
45
46
46
47
- def test_statistics_object_creation_from_file_path_without_customizations ():
47
+ def test_statistics_object_creation_from_file_path_without_customizations (sagemaker_session ):
48
48
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 ,
50
51
)
51
52
52
53
assert statistics .file_s3_uri .startswith ("s3://" )
@@ -74,11 +75,13 @@ def test_statistics_object_creation_from_string_with_customizations(
74
75
assert statistics .body_dict ["dataset" ]["item_count" ] == 418
75
76
76
77
77
- def test_statistics_object_creation_from_string_without_customizations ():
78
+ def test_statistics_object_creation_from_string_without_customizations (sagemaker_session ):
78
79
with open (os .path .join (tests .integ .DATA_DIR , "monitor/statistics.json" ), "r" ) as f :
79
80
file_body = f .read ()
80
81
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
+ )
82
85
83
86
assert statistics .file_s3_uri .startswith ("s3://" )
84
87
assert statistics .file_s3_uri .endswith ("statistics.json" )
@@ -133,9 +136,13 @@ def test_statistics_object_creation_from_s3_uri_without_customizations(sagemaker
133
136
file_name ,
134
137
)
135
138
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
+ )
137
142
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
+ )
139
146
140
147
assert statistics .file_s3_uri .startswith ("s3://" )
141
148
assert statistics .file_s3_uri .endswith ("statistics.json" )
@@ -181,14 +188,17 @@ def test_constraints_object_creation_from_file_path_with_customizations(
181
188
182
189
constraints .save ()
183
190
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
+ )
185
194
186
195
assert new_constraints .body_dict ["monitoring_config" ]["evaluate_constraints" ] == "Disabled"
187
196
188
197
189
- def test_constraints_object_creation_from_file_path_without_customizations ():
198
+ def test_constraints_object_creation_from_file_path_without_customizations (sagemaker_session ):
190
199
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 ,
192
202
)
193
203
194
204
assert constraints .file_s3_uri .startswith ("s3://" )
@@ -216,11 +226,13 @@ def test_constraints_object_creation_from_string_with_customizations(
216
226
assert constraints .body_dict ["monitoring_config" ]["evaluate_constraints" ] == "Enabled"
217
227
218
228
219
- def test_constraints_object_creation_from_string_without_customizations ():
229
+ def test_constraints_object_creation_from_string_without_customizations (sagemaker_session ):
220
230
with open (os .path .join (tests .integ .DATA_DIR , "monitor/constraints.json" ), "r" ) as f :
221
231
file_body = f .read ()
222
232
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
+ )
224
236
225
237
assert constraints .file_s3_uri .startswith ("s3://" )
226
238
assert constraints .file_s3_uri .endswith ("constraints.json" )
@@ -275,9 +287,13 @@ def test_constraints_object_creation_from_s3_uri_without_customizations(sagemake
275
287
file_name ,
276
288
)
277
289
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
+ )
279
293
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
+ )
281
297
282
298
assert constraints .file_s3_uri .startswith ("s3://" )
283
299
assert constraints .file_s3_uri .endswith ("constraints.json" )
@@ -302,11 +318,14 @@ def test_constraint_violations_object_creation_from_file_path_with_customization
302
318
assert constraint_violations .body_dict ["violations" ][0 ]["feature_name" ] == "store_and_fwd_flag"
303
319
304
320
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
+ ):
306
324
constraint_violations = ConstraintViolations .from_file_path (
307
325
constraint_violations_file_path = os .path .join (
308
326
tests .integ .DATA_DIR , "monitor/constraint_violations.json"
309
- )
327
+ ),
328
+ sagemaker_session = sagemaker_session ,
310
329
)
311
330
312
331
assert constraint_violations .file_s3_uri .startswith ("s3://" )
@@ -334,12 +353,14 @@ def test_constraint_violations_object_creation_from_string_with_customizations(
334
353
assert constraint_violations .body_dict ["violations" ][0 ]["feature_name" ] == "store_and_fwd_flag"
335
354
336
355
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
+ ):
338
359
with open (os .path .join (tests .integ .DATA_DIR , "monitor/constraint_violations.json" ), "r" ) as f :
339
360
file_body = f .read ()
340
361
341
362
constraint_violations = ConstraintViolations .from_string (
342
- constraint_violations_file_string = file_body
363
+ constraint_violations_file_string = file_body , sagemaker_session = sagemaker_session
343
364
)
344
365
345
366
assert constraint_violations .file_s3_uri .startswith ("s3://" )
@@ -397,10 +418,12 @@ def test_constraint_violations_object_creation_from_s3_uri_without_customization
397
418
file_name ,
398
419
)
399
420
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
+ )
401
424
402
425
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
404
427
)
405
428
406
429
assert constraint_violations .file_s3_uri .startswith ("s3://" )
0 commit comments