@@ -81,7 +81,7 @@ def test_get_config_as_dict(self):
8181 _config = {}
8282 _config ["api_version" ] = APIVersion .V1
8383 _config ["fallback_api_version" ] = None
84- _config ["servers" ] = openml .config .get_servers ( "test" )
84+ _config ["servers" ] = openml .config .get_test_servers ( )
8585 _config ["cachedir" ] = self .workdir
8686 _config ["avoid_duplicate_runs" ] = False
8787 _config ["connection_n_retries" ] = 20
@@ -96,7 +96,7 @@ def test_setup_with_config(self):
9696 _config = {}
9797 _config ["api_version" ] = APIVersion .V1
9898 _config ["fallback_api_version" ] = None
99- _config ["servers" ] = openml .config .get_servers ( "test" )
99+ _config ["servers" ] = openml .config .get_test_servers ( )
100100 _config ["cachedir" ] = self .workdir
101101 _config ["avoid_duplicate_runs" ] = True
102102 _config ["retry_policy" ] = "human"
@@ -113,21 +113,22 @@ class TestConfigurationForExamples(openml.testing.TestBase):
113113 @pytest .mark .production_server ()
114114 def test_switch_to_example_configuration (self ):
115115 """Verifies the test configuration is loaded properly."""
116- openml .config .set_servers ( "production" )
116+ openml .config .use_production_servers ( )
117117
118118 openml .config .start_using_configuration_for_example ()
119119
120- openml .config .servers = openml .config .get_servers ( "test" )
120+ assert openml .config .servers == openml .config .get_test_servers ( )
121121
122122 @pytest .mark .production_server ()
123123 def test_switch_from_example_configuration (self ):
124124 """Verifies the previous configuration is loaded after stopping."""
125125 # Below is the default test key which would be used anyway, but just for clarity:
126- openml .config .set_servers ( "production" )
126+ openml .config .use_production_servers ( )
127127
128128 openml .config .start_using_configuration_for_example ()
129129 openml .config .stop_using_configuration_for_example ()
130- openml .config .servers = openml .config .get_servers ("production" )
130+
131+ assert openml .config .servers == openml .config .get_production_servers ()
131132
132133 def test_example_configuration_stop_before_start (self ):
133134 """Verifies an error is raised if `stop_...` is called before `start_...`."""
@@ -144,13 +145,13 @@ def test_example_configuration_stop_before_start(self):
144145 @pytest .mark .production_server ()
145146 def test_example_configuration_start_twice (self ):
146147 """Checks that the original config can be returned to if `start..` is called twice."""
147- openml .config .set_servers ( "production" )
148+ openml .config .use_production_servers ( )
148149
149150 openml .config .start_using_configuration_for_example ()
150151 openml .config .start_using_configuration_for_example ()
151152 openml .config .stop_using_configuration_for_example ()
152153
153- assert openml .config .servers == openml .config .get_servers ( "production" )
154+ assert openml .config .servers == openml .config .get_production_servers ( )
154155
155156
156157def test_configuration_file_not_overwritten_on_load ():
@@ -192,28 +193,28 @@ def test_openml_cache_dir_env_var(tmp_path: Path) -> None:
192193 assert openml .config .get_cache_directory () == str (expected_path / "org" / "openml" / "www" )
193194
194195
195- @pytest .mark .parametrize ("mode" , ["production" , "test" , "local" ])
196+ @pytest .mark .parametrize ("mode" , ["production" , "test" ])
196197@pytest .mark .parametrize ("api_version" , [APIVersion .V1 , APIVersion .V2 ])
197198def test_get_servers (mode , api_version ):
198- orig_servers = openml .config .get_servers (mode )
199+ orig_servers = openml .config ._get_servers (mode )
199200
200- openml .config .set_servers (mode )
201+ openml .config ._set_servers (mode )
201202 openml .config .set_api_version (api_version )
202203 openml .config .server = "temp-server1"
203204 openml .config .apikey = "temp-apikey1"
204- openml .config .get_servers (mode )["server" ] = 'temp-server2'
205- openml .config .get_servers (mode )["apikey" ] = 'temp-server2'
205+ openml .config ._get_servers (mode )["server" ] = 'temp-server2'
206+ openml .config ._get_servers (mode )["apikey" ] = 'temp-server2'
206207
207- assert openml .config .get_servers (mode ) == orig_servers
208+ assert openml .config ._get_servers (mode ) == orig_servers
208209
209210
210- @pytest .mark .parametrize ("mode" , ["production" , "test" , "local" ])
211+ @pytest .mark .parametrize ("mode" , ["production" , "test" ])
211212@pytest .mark .parametrize ("api_version" , [APIVersion .V1 , APIVersion .V2 ])
212213def test_set_servers (mode , api_version ):
213- openml .config .set_servers (mode )
214+ openml .config ._set_servers (mode )
214215 openml .config .set_api_version (api_version )
215216
216- assert openml .config .servers == openml .config .get_servers (mode )
217+ assert openml .config .servers == openml .config ._get_servers (mode )
217218 assert openml .config .api_version == api_version
218219
219220 openml .config .server = "temp-server"
@@ -224,6 +225,34 @@ def test_set_servers(mode, api_version):
224225
225226 for version , servers in openml .config .servers .items ():
226227 if version == api_version :
227- assert servers != openml .config .get_servers (mode )[version ]
228+ assert servers != openml .config ._get_servers (mode )[version ]
228229 else :
229- assert servers == openml .config .get_servers (mode )[version ]
230+ assert servers == openml .config ._get_servers (mode )[version ]
231+
232+
233+ def test_get_production_servers ():
234+ assert openml .config .get_production_servers () == openml .config ._get_servers ("production" )
235+
236+
237+ def test_get_test_servers ():
238+ assert openml .config .get_test_servers () == openml .config ._get_servers ("test" )
239+
240+
241+ def test_use_production_servers ():
242+ openml .config .use_production_servers ()
243+ servers_1 = openml .config .servers
244+
245+ openml .config ._set_servers ("production" )
246+ servers_2 = openml .config .servers
247+
248+ assert servers_1 == servers_2
249+
250+
251+ def test_use_test_servers ():
252+ openml .config .use_test_servers ()
253+ servers_1 = openml .config .servers
254+
255+ openml .config ._set_servers ("test" )
256+ servers_2 = openml .config .servers
257+
258+ assert servers_1 == servers_2
0 commit comments