1717import yaml
1818from mock import Mock , MagicMock
1919
20- from sagemaker .config .config import fetch_sagemaker_config
20+ from sagemaker .config .config import load_sagemaker_config
2121from jsonschema import exceptions
2222from yaml .constructor import ConstructorError
2323
@@ -37,14 +37,14 @@ def expected_merged_config(get_data_dir):
3737
3838
3939def test_config_when_default_config_file_and_user_config_file_is_not_found ():
40- assert fetch_sagemaker_config () == {}
40+ assert load_sagemaker_config () == {}
4141
4242
4343def test_config_when_overriden_default_config_file_is_not_found (get_data_dir ):
4444 fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
4545 os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = fake_config_file_path
4646 with pytest .raises (ValueError ):
47- fetch_sagemaker_config ()
47+ load_sagemaker_config ()
4848 del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
4949
5050
@@ -55,14 +55,14 @@ def test_invalid_config_file_which_has_python_code(get_data_dir):
5555 # PyYAML will throw exceptions for yaml.safe_load. SageMaker Config is using
5656 # yaml.safe_load internally
5757 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 ])
5959 assert "python/object/apply:eval" in str (exception_info .value )
6060
6161
6262def test_config_when_additional_config_file_path_is_not_found (get_data_dir ):
6363 fake_config_file_path = os .path .join (get_data_dir , "config-not-found.yaml" )
6464 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 ])
6666
6767
6868def 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
7171 )
7272 os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ] = fake_additional_override_config_file_path
7373 with pytest .raises (ValueError ):
74- fetch_sagemaker_config ()
74+ load_sagemaker_config ()
7575 del os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ]
7676
7777
7878def test_default_config_file_with_invalid_schema (get_data_dir ):
7979 config_file_path = os .path .join (get_data_dir , "invalid_config_file.yaml" )
8080 os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = config_file_path
8181 with pytest .raises (exceptions .ValidationError ):
82- fetch_sagemaker_config ()
82+ load_sagemaker_config ()
8383 del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
8484
8585
@@ -90,7 +90,7 @@ def test_default_config_file_when_directory_is_provided_as_the_path(
9090 expected_config = base_config_with_schema
9191 expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
9292 os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = get_data_dir
93- assert expected_config == fetch_sagemaker_config ()
93+ assert expected_config == load_sagemaker_config ()
9494 del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
9595
9696
@@ -100,7 +100,7 @@ def test_additional_config_paths_when_directory_is_provided(
100100 # This will try to load config.yaml file from that directory if present.
101101 expected_config = base_config_with_schema
102102 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 ])
104104
105105
106106def 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(
110110 # This will try to load config.yaml file from that directory if present.
111111 expected_config = base_config_with_schema
112112 expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
113- assert expected_config == fetch_sagemaker_config ()
113+ assert expected_config == load_sagemaker_config ()
114114 del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
115115
116116
@@ -123,7 +123,7 @@ def test_merge_behavior_when_additional_config_file_path_is_not_found(
123123 )
124124 os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ] = valid_config_file_path
125125 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 ])
127127 del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
128128
129129
@@ -133,11 +133,11 @@ def test_merge_behavior(get_data_dir, expected_merged_config):
133133 get_data_dir , "sample_additional_config_for_merge.yaml"
134134 )
135135 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 (
137137 additional_config_paths = [additional_override_config_file_path ]
138138 )
139139 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 ()
141141 del os .environ ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE" ]
142142 del os .environ ["SAGEMAKER_USER_CONFIG_OVERRIDE" ]
143143
@@ -160,7 +160,7 @@ def test_s3_config_file(
160160 config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
161161 expected_config = base_config_with_schema
162162 expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
163- assert expected_config == fetch_sagemaker_config (
163+ assert expected_config == load_sagemaker_config (
164164 additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
165165 )
166166
@@ -174,7 +174,7 @@ def test_config_factory_when_default_s3_config_file_is_not_found(s3_resource_moc
174174 ).all .return_value = []
175175 config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
176176 with pytest .raises (ValueError ):
177- fetch_sagemaker_config (
177+ load_sagemaker_config (
178178 additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
179179 )
180180
@@ -204,7 +204,7 @@ def test_s3_config_file_when_uri_provided_corresponds_to_a_path(
204204 config_file_s3_uri = "s3://{}/{}" .format (config_file_bucket , config_file_s3_prefix )
205205 expected_config = base_config_with_schema
206206 expected_config ["SageMaker" ] = valid_config_with_all_the_scopes
207- assert expected_config == fetch_sagemaker_config (
207+ assert expected_config == load_sagemaker_config (
208208 additional_config_paths = [config_file_s3_uri ], s3_resource = s3_resource_mock
209209 )
210210
@@ -231,7 +231,7 @@ def test_merge_of_s3_default_config_file_and_regular_config_file(
231231 get_data_dir , "sample_additional_config_for_merge.yaml"
232232 )
233233 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 (
235235 additional_config_paths = [additional_override_config_file_path ],
236236 s3_resource = s3_resource_mock ,
237237 )
0 commit comments