@@ -45,14 +45,14 @@ def expected_merged_config(get_data_dir):
45
45
46
46
47
47
def test_config_when_default_config_file_and_user_config_file_is_not_found ():
48
- assert load_sagemaker_config () == {}
48
+ assert load_sagemaker_config (repeat_log = True ) == {}
49
49
50
50
51
51
def test_config_when_overriden_default_config_file_is_not_found (get_data_dir ):
52
52
fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
53
53
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = fake_config_file_path
54
54
with pytest .raises (ValueError ):
55
- load_sagemaker_config ()
55
+ load_sagemaker_config (repeat_log = True )
56
56
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
57
57
58
58
@@ -63,14 +63,14 @@ def test_invalid_config_file_which_has_python_code(get_data_dir):
63
63
# PyYAML will throw exceptions for yaml.safe_load. SageMaker Config is using
64
64
# yaml.safe_load internally
65
65
with pytest .raises (ConstructorError ) as exception_info :
66
- load_sagemaker_config (additional_config_paths = [invalid_config_file_path ])
66
+ load_sagemaker_config (additional_config_paths = [invalid_config_file_path ], repeat_log = True )
67
67
assert "python/object/apply:eval" in str (exception_info .value )
68
68
69
69
70
70
def test_config_when_additional_config_file_path_is_not_found (get_data_dir ):
71
71
fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
72
72
with pytest .raises (ValueError ):
73
- load_sagemaker_config (additional_config_paths = [fake_config_file_path ])
73
+ load_sagemaker_config (additional_config_paths = [fake_config_file_path ], repeat_log = True )
74
74
75
75
76
76
def test_config_factory_when_override_user_config_file_is_not_found (get_data_dir ):
@@ -79,15 +79,15 @@ def test_config_factory_when_override_user_config_file_is_not_found(get_data_dir
79
79
)
80
80
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = fake_additional_override_config_file_path
81
81
with pytest .raises (ValueError ):
82
- load_sagemaker_config ()
82
+ load_sagemaker_config (repeat_log = True )
83
83
del os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ]
84
84
85
85
86
86
def test_default_config_file_with_invalid_schema (get_data_dir ):
87
87
config_file_path = os .path .join (get_data_dir , "invalid_config_file.yaml" )
88
88
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = config_file_path
89
89
with pytest .raises (exceptions .ValidationError ):
90
- load_sagemaker_config ()
90
+ load_sagemaker_config (repeat_log = True )
91
91
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
92
92
93
93
@@ -98,7 +98,7 @@ def test_default_config_file_when_directory_is_provided_as_the_path(
98
98
expected_config = base_config_with_schema
99
99
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
100
100
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = get_data_dir
101
- assert expected_config == load_sagemaker_config ()
101
+ assert expected_config == load_sagemaker_config (repeat_log = True )
102
102
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
103
103
104
104
@@ -108,7 +108,9 @@ def test_additional_config_paths_when_directory_is_provided(
108
108
# This will try to load config.yaml file from that directory if present.
109
109
expected_config = base_config_with_schema
110
110
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
111
- assert expected_config == load_sagemaker_config (additional_config_paths = [get_data_dir ])
111
+ assert expected_config == load_sagemaker_config (
112
+ additional_config_paths = [get_data_dir ], repeat_log = True
113
+ )
112
114
113
115
114
116
def test_default_config_file_when_path_is_provided_as_environment_variable (
@@ -118,7 +120,7 @@ def test_default_config_file_when_path_is_provided_as_environment_variable(
118
120
# This will try to load config.yaml file from that directory if present.
119
121
expected_config = base_config_with_schema
120
122
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
121
- assert expected_config == load_sagemaker_config ()
123
+ assert expected_config == load_sagemaker_config (repeat_log = True )
122
124
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
123
125
124
126
@@ -131,7 +133,9 @@ def test_merge_behavior_when_additional_config_file_path_is_not_found(
131
133
)
132
134
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = valid_config_file_path
133
135
with pytest .raises (ValueError ):
134
- load_sagemaker_config (additional_config_paths = [fake_additional_override_config_file_path ])
136
+ load_sagemaker_config (
137
+ additional_config_paths = [fake_additional_override_config_file_path ], repeat_log = True
138
+ )
135
139
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
136
140
137
141
@@ -142,10 +146,10 @@ def test_merge_behavior(get_data_dir, expected_merged_config):
142
146
)
143
147
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = valid_config_file_path
144
148
assert expected_merged_config == load_sagemaker_config (
145
- additional_config_paths = [additional_override_config_file_path ]
149
+ additional_config_paths = [additional_override_config_file_path ], repeat_log = True
146
150
)
147
151
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = additional_override_config_file_path
148
- assert expected_merged_config == load_sagemaker_config ()
152
+ assert expected_merged_config == load_sagemaker_config (repeat_log = True )
149
153
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
150
154
del os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ]
151
155
@@ -169,7 +173,7 @@ def test_s3_config_file(
169
173
expected_config = base_config_with_schema
170
174
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
171
175
assert expected_config == load_sagemaker_config (
172
- additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
176
+ additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock , repeat_log = True
173
177
)
174
178
175
179
@@ -183,7 +187,9 @@ def test_config_factory_when_default_s3_config_file_is_not_found(s3_resource_moc
183
187
config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
184
188
with pytest .raises (ValueError ):
185
189
load_sagemaker_config (
186
- additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
190
+ additional_config_paths = [config_file_s3_uri ],
191
+ s3_resource = s3_resource_mock ,
192
+ repeat_log = True ,
187
193
)
188
194
189
195
@@ -213,7 +219,7 @@ def test_s3_config_file_when_uri_provided_corresponds_to_a_path(
213
219
expected_config = base_config_with_schema
214
220
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
215
221
assert expected_config == load_sagemaker_config (
216
- additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
222
+ additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock , repeat_log = True
217
223
)
218
224
219
225
@@ -242,6 +248,7 @@ def test_merge_of_s3_default_config_file_and_regular_config_file(
242
248
assert expected_merged_config == load_sagemaker_config (
243
249
additional_config_paths = [additional_override_config_file_path ],
244
250
s3_resource = s3_resource_mock ,
251
+ repeat_log = True ,
245
252
)
246
253
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
247
254
@@ -254,7 +261,7 @@ def test_logging_when_overridden_admin_is_found_and_overridden_user_config_is_fo
254
261
255
262
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = get_data_dir
256
263
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = get_data_dir
257
- load_sagemaker_config ()
264
+ load_sagemaker_config (repeat_log = True )
258
265
assert "Fetched defaults config from location: {}" .format (get_data_dir ) in caplog .text
259
266
assert (
260
267
"Not applying SDK defaults from location: {}" .format (_DEFAULT_ADMIN_CONFIG_FILE_PATH )
@@ -275,7 +282,7 @@ def test_logging_when_overridden_admin_is_found_and_default_user_config_not_foun
275
282
logger .propagate = True
276
283
caplog .set_level (logging .DEBUG , logger = logger .name )
277
284
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = get_data_dir
278
- load_sagemaker_config ()
285
+ load_sagemaker_config (repeat_log = True )
279
286
assert "Fetched defaults config from location: {}" .format (get_data_dir ) in caplog .text
280
287
assert (
281
288
"Not applying SDK defaults from location: {}" .format (_DEFAULT_USER_CONFIG_FILE_PATH )
@@ -297,7 +304,7 @@ def test_logging_when_default_admin_not_found_and_overriden_user_config_is_found
297
304
logger .propagate = True
298
305
caplog .set_level (logging .DEBUG , logger = logger .name )
299
306
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = get_data_dir
300
- load_sagemaker_config ()
307
+ load_sagemaker_config (repeat_log = True )
301
308
assert "Fetched defaults config from location: {}" .format (get_data_dir ) in caplog .text
302
309
assert (
303
310
"Not applying SDK defaults from location: {}" .format (_DEFAULT_ADMIN_CONFIG_FILE_PATH )
@@ -318,7 +325,7 @@ def test_logging_when_default_admin_not_found_and_default_user_config_not_found(
318
325
# for admin and user config since both are missing from default location
319
326
logger .propagate = True
320
327
caplog .set_level (logging .DEBUG , logger = logger .name )
321
- load_sagemaker_config ()
328
+ load_sagemaker_config (repeat_log = True )
322
329
assert (
323
330
"Not applying SDK defaults from location: {}" .format (_DEFAULT_ADMIN_CONFIG_FILE_PATH )
324
331
in caplog .text
@@ -351,7 +358,7 @@ def test_logging_when_default_admin_not_found_and_overriden_user_config_not_foun
351
358
fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
352
359
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = fake_config_file_path
353
360
with pytest .raises (ValueError ):
354
- load_sagemaker_config ()
361
+ load_sagemaker_config (repeat_log = True )
355
362
assert (
356
363
"Not applying SDK defaults from location: {}" .format (_DEFAULT_ADMIN_CONFIG_FILE_PATH )
357
364
in caplog .text
@@ -374,7 +381,7 @@ def test_logging_when_overriden_admin_not_found_and_overridden_user_config_not_f
374
381
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = fake_config_file_path
375
382
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = fake_config_file_path
376
383
with pytest .raises (ValueError ):
377
- load_sagemaker_config ()
384
+ load_sagemaker_config (repeat_log = True )
378
385
assert (
379
386
"Not applying SDK defaults from location: {}" .format (_DEFAULT_ADMIN_CONFIG_FILE_PATH )
380
387
not in caplog .text
@@ -394,7 +401,7 @@ def test_logging_with_additional_configs_and_none_are_found(caplog):
394
401
# Should throw exception when config in additional_config_path is missing
395
402
logger .propagate = True
396
403
with pytest .raises (ValueError ):
397
- load_sagemaker_config (additional_config_paths = ["fake-path" ])
404
+ load_sagemaker_config (additional_config_paths = ["fake-path" ], repeat_log = True )
398
405
assert (
399
406
"Not applying SDK defaults from location: {}" .format (_DEFAULT_ADMIN_CONFIG_FILE_PATH )
400
407
in caplog .text
0 commit comments