@@ -102,35 +102,27 @@ def run_opts(self) -> runopts:
102102 return opts
103103
104104
105- _CONFIG = """[default. local_cwd.cfg ]
105+ _CONFIG = """[local_cwd]
106106log_dir = /home/bob/logs
107107prepend_cwd = True
108-
109- [test.local_cwd.cfg]
110- log_dir = None
111- prepend_cwd = False
112-
113- [alpha.local_cwd.cfg]
114- log_dir = /tmp/logs
115108"""
116109
117- _CONFIG_INVALID = """[default. test.cfg ]
110+ _CONFIG_INVALID = """[test]
118111a_run_opt_that = does_not_exist
119112s = option_that_exists
120113"""
121114
122- _TEAM_CONFIG = """[default. test.cfg ]
115+ _TEAM_CONFIG = """[test]
123116s = team_default
124117i = 50
125118f = 1.2
126119"""
127120
128- _MY_CONFIG = """[default. test.cfg ]
121+ _MY_CONFIG = """[test]
129122s = my_default
130123i = 100
131124"""
132125
133- PATH_HOME = "torchx.runner.config.Path.home"
134126PATH_CWD = "torchx.runner.config.Path.cwd"
135127TORCHX_GET_SCHEDULERS = "torchx.runner.config.get_schedulers"
136128
@@ -159,45 +151,50 @@ def _write(self, filename: str, content: str) -> Path:
159151
160152 def test_load (self ) -> None :
161153 cfg = RunConfig ()
162- load (profile = "default" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
154+ load (scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
163155 self .assertEqual ("/home/bob/logs" , cfg .get ("log_dir" ))
164156 self .assertEqual (True , cfg .get ("prepend_cwd" ))
165157
166- cfg = RunConfig ()
167- load (profile = "test" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
168- self .assertEqual (None , cfg .get ("log_dir" ))
169- self .assertEqual (False , cfg .get ("prepend_cwd" ))
170-
171- cfg = RunConfig ()
172- load (profile = "alpha" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
173- self .assertEqual ("/tmp/logs" , cfg .get ("log_dir" ))
174- self .assertEqual (None , cfg .get ("prepend_cwd" ))
175-
176158 def test_no_override_load (self ) -> None :
177159 cfg = RunConfig ()
178160 cfg .set ("log_dir" , "/foo/bar" )
179161 cfg .set ("debug" , 1 )
180162
181- load (profile = "test" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
163+ load (scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
182164 self .assertEqual ("/foo/bar" , cfg .get ("log_dir" ))
183165 self .assertEqual (1 , cfg .get ("debug" ))
184- self .assertEqual (False , cfg .get ("prepend_cwd" ))
166+ self .assertEqual (True , cfg .get ("prepend_cwd" ))
185167
186168 @patch (
187169 TORCHX_GET_SCHEDULERS ,
188170 return_value = {"test" : TestScheduler ()},
189171 )
190- def test_apply (self , _ ) -> None :
172+ def test_apply_default (self , _ ) -> None :
191173 with patch (PATH_CWD , return_value = Path (self .test_dir )):
192- with patch (PATH_HOME , return_value = Path (self .test_dir ) / "home" / "bob" ):
193- cfg = RunConfig ()
194- cfg .set ("s" , "runtime_value" )
174+ cfg = RunConfig ()
175+ cfg .set ("s" , "runtime_value" )
176+
177+ apply (scheduler = "test" , cfg = cfg )
195178
196- apply (profile = "default" , scheduler = "test" , cfg = cfg )
179+ self .assertEqual ("runtime_value" , cfg .get ("s" ))
180+ self .assertEqual (50 , cfg .get ("i" ))
181+ self .assertEqual (1.2 , cfg .get ("f" ))
197182
198- self .assertEqual ("runtime_value" , cfg .get ("s" ))
199- self .assertEqual (100 , cfg .get ("i" ))
200- self .assertEqual (1.2 , cfg .get ("f" ))
183+ @patch (
184+ TORCHX_GET_SCHEDULERS ,
185+ return_value = {"test" : TestScheduler ()},
186+ )
187+ def test_apply_dirs (self , _ ) -> None :
188+ cfg = RunConfig ()
189+ cfg .set ("s" , "runtime_value" )
190+ apply (
191+ scheduler = "test" ,
192+ cfg = cfg ,
193+ dirs = [str (Path (self .test_dir ) / "home" / "bob" ), self .test_dir ],
194+ )
195+ self .assertEqual ("runtime_value" , cfg .get ("s" ))
196+ self .assertEqual (100 , cfg .get ("i" ))
197+ self .assertEqual (1.2 , cfg .get ("f" ))
201198
202199 def test_dump_invalid_scheduler (self ) -> None :
203200 with self .assertRaises (ValueError ):
@@ -215,7 +212,7 @@ def test_dump_only_required(self, _) -> None:
215212
216213 cfg = RunConfig ()
217214 sfile .seek (0 )
218- load (profile = "default" , scheduler = "test" , f = sfile , cfg = cfg )
215+ load (scheduler = "test" , f = sfile , cfg = cfg )
219216
220217 self .assertFalse (cfg .cfgs )
221218
@@ -226,7 +223,6 @@ def test_dump_only_required(self, _) -> None:
226223 def test_load_invalid_runopt (self , _ ) -> None :
227224 cfg = RunConfig ()
228225 load (
229- profile = "default" ,
230226 scheduler = "test" ,
231227 f = StringIO (_CONFIG_INVALID ),
232228 cfg = cfg ,
@@ -241,7 +237,6 @@ def test_load_invalid_runopt(self, _) -> None:
241237 def test_load_no_section (self ) -> None :
242238 cfg = RunConfig ()
243239 load (
244- profile = "default" ,
245240 scheduler = "local_cwd" ,
246241 f = StringIO (),
247242 cfg = cfg ,
@@ -250,9 +245,8 @@ def test_load_no_section(self) -> None:
250245 self .assertFalse (cfg .cfgs )
251246
252247 load (
253- profile = "default" ,
254248 scheduler = "local_cwd" ,
255- f = StringIO ("[default. scheduler_args.local_cwd]\n " ),
249+ f = StringIO ("[scheduler_args.local_cwd]\n " ),
256250 cfg = cfg ,
257251 )
258252 # still empty
@@ -269,7 +263,7 @@ def test_dump_and_load_all_runopt_types(self, _) -> None:
269263 sfile .seek (0 )
270264
271265 cfg = RunConfig ()
272- load (profile = "default" , scheduler = "test" , f = sfile , cfg = cfg )
266+ load (scheduler = "test" , f = sfile , cfg = cfg )
273267
274268 # all runopts in the TestScheduler have defaults, just check against those
275269 for opt_name , opt in TestScheduler ().run_opts ():
@@ -282,11 +276,11 @@ def test_dump_and_load_all_registered_schedulers(self) -> None:
282276
283277 sfile = StringIO ()
284278 dump (sfile )
285- print ( sfile . getvalue ())
279+
286280 for sched_name , sched in get_schedulers (session_name = "_" ).items ():
287281 sfile .seek (0 ) # reset the file pos
288282 cfg = RunConfig ()
289- load (profile = "default" , scheduler = sched_name , f = sfile , cfg = cfg )
283+ load (scheduler = sched_name , f = sfile , cfg = cfg )
290284
291285 for opt_name , _ in sched .run_opts ():
292286 self .assertTrue (opt_name in cfg .cfgs )
0 commit comments