17
17
import yaml
18
18
from mock import Mock , MagicMock
19
19
20
- from sagemaker .config .config import fetch_sagemaker_config
20
+ from sagemaker .config .config import load_sagemaker_config
21
21
from jsonschema import exceptions
22
22
from yaml .constructor import ConstructorError
23
23
@@ -37,14 +37,14 @@ def expected_merged_config(get_data_dir):
37
37
38
38
39
39
def test_config_when_default_config_file_and_user_config_file_is_not_found ():
40
- assert fetch_sagemaker_config () == {}
40
+ assert load_sagemaker_config () == {}
41
41
42
42
43
43
def test_config_when_overriden_default_config_file_is_not_found (get_data_dir ):
44
44
fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
45
45
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = fake_config_file_path
46
46
with pytest .raises (ValueError ):
47
- fetch_sagemaker_config ()
47
+ load_sagemaker_config ()
48
48
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
49
49
50
50
@@ -55,14 +55,14 @@ def test_invalid_config_file_which_has_python_code(get_data_dir):
55
55
# PyYAML will throw exceptions for yaml.safe_load. SageMaker Config is using
56
56
# yaml.safe_load internally
57
57
with pytest .raises (ConstructorError ) as exception_info :
58
- fetch_sagemaker_config (additional_config_paths = [invalid_config_file_path ])
58
+ load_sagemaker_config (additional_config_paths = [invalid_config_file_path ])
59
59
assert "python/object/apply:eval" in str (exception_info .value )
60
60
61
61
62
62
def test_config_when_additional_config_file_path_is_not_found (get_data_dir ):
63
63
fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
64
64
with pytest .raises (ValueError ):
65
- fetch_sagemaker_config (additional_config_paths = [fake_config_file_path ])
65
+ load_sagemaker_config (additional_config_paths = [fake_config_file_path ])
66
66
67
67
68
68
def test_config_factory_when_override_user_config_file_is_not_found (get_data_dir ):
@@ -71,15 +71,15 @@ def test_config_factory_when_override_user_config_file_is_not_found(get_data_dir
71
71
)
72
72
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = fake_additional_override_config_file_path
73
73
with pytest .raises (ValueError ):
74
- fetch_sagemaker_config ()
74
+ load_sagemaker_config ()
75
75
del os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ]
76
76
77
77
78
78
def test_default_config_file_with_invalid_schema (get_data_dir ):
79
79
config_file_path = os .path .join (get_data_dir , "invalid_config_file.yaml" )
80
80
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = config_file_path
81
81
with pytest .raises (exceptions .ValidationError ):
82
- fetch_sagemaker_config ()
82
+ load_sagemaker_config ()
83
83
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
84
84
85
85
@@ -90,7 +90,7 @@ def test_default_config_file_when_directory_is_provided_as_the_path(
90
90
expected_config = base_config_with_schema
91
91
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
92
92
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = get_data_dir
93
- assert expected_config == fetch_sagemaker_config ()
93
+ assert expected_config == load_sagemaker_config ()
94
94
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
95
95
96
96
@@ -100,7 +100,7 @@ def test_additional_config_paths_when_directory_is_provided(
100
100
# This will try to load config.yaml file from that directory if present.
101
101
expected_config = base_config_with_schema
102
102
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
103
- assert expected_config == fetch_sagemaker_config (additional_config_paths = [get_data_dir ])
103
+ assert expected_config == load_sagemaker_config (additional_config_paths = [get_data_dir ])
104
104
105
105
106
106
def test_default_config_file_when_path_is_provided_as_environment_variable (
@@ -110,7 +110,7 @@ def test_default_config_file_when_path_is_provided_as_environment_variable(
110
110
# This will try to load config.yaml file from that directory if present.
111
111
expected_config = base_config_with_schema
112
112
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
113
- assert expected_config == fetch_sagemaker_config ()
113
+ assert expected_config == load_sagemaker_config ()
114
114
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
115
115
116
116
@@ -123,7 +123,7 @@ def test_merge_behavior_when_additional_config_file_path_is_not_found(
123
123
)
124
124
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = valid_config_file_path
125
125
with pytest .raises (ValueError ):
126
- fetch_sagemaker_config (additional_config_paths = [fake_additional_override_config_file_path ])
126
+ load_sagemaker_config (additional_config_paths = [fake_additional_override_config_file_path ])
127
127
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
128
128
129
129
@@ -133,11 +133,11 @@ def test_merge_behavior(get_data_dir, expected_merged_config):
133
133
get_data_dir , "sample_additional_config_for_merge.yaml"
134
134
)
135
135
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = valid_config_file_path
136
- assert expected_merged_config == fetch_sagemaker_config (
136
+ assert expected_merged_config == load_sagemaker_config (
137
137
additional_config_paths = [additional_override_config_file_path ]
138
138
)
139
139
os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = additional_override_config_file_path
140
- assert expected_merged_config == fetch_sagemaker_config ()
140
+ assert expected_merged_config == load_sagemaker_config ()
141
141
del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
142
142
del os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ]
143
143
@@ -160,7 +160,7 @@ def test_s3_config_file(
160
160
config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
161
161
expected_config = base_config_with_schema
162
162
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
163
- assert expected_config == fetch_sagemaker_config (
163
+ assert expected_config == load_sagemaker_config (
164
164
additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
165
165
)
166
166
@@ -174,7 +174,7 @@ def test_config_factory_when_default_s3_config_file_is_not_found(s3_resource_moc
174
174
).all .return_value = []
175
175
config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
176
176
with pytest .raises (ValueError ):
177
- fetch_sagemaker_config (
177
+ load_sagemaker_config (
178
178
additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
179
179
)
180
180
@@ -204,7 +204,7 @@ def test_s3_config_file_when_uri_provided_corresponds_to_a_path(
204
204
config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
205
205
expected_config = base_config_with_schema
206
206
expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
207
- assert expected_config == fetch_sagemaker_config (
207
+ assert expected_config == load_sagemaker_config (
208
208
additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
209
209
)
210
210
@@ -231,7 +231,7 @@ def test_merge_of_s3_default_config_file_and_regular_config_file(
231
231
get_data_dir , "sample_additional_config_for_merge.yaml"
232
232
)
233
233
os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = config_file_s3_uri
234
- assert expected_merged_config == fetch_sagemaker_config (
234
+ assert expected_merged_config == load_sagemaker_config (
235
235
additional_config_paths = [additional_override_config_file_path ],
236
236
s3_resource = s3_resource_mock ,
237
237
)
0 commit comments