@@ -102,30 +102,30 @@ def run_opts(self) -> runopts:
102102 return opts
103103
104104
105- _CONFIG = """[default.scheduler_args. local_cwd]
105+ _CONFIG = """[default.local_cwd.cfg ]
106106log_dir = /home/bob/logs
107107prepend_cwd = True
108108
109- [test.scheduler_args. local_cwd]
109+ [test.local_cwd.cfg ]
110110log_dir = None
111111prepend_cwd = False
112112
113- [alpha.scheduler_args. local_cwd]
113+ [alpha.local_cwd.cfg ]
114114log_dir = /tmp/logs
115115"""
116116
117- _CONFIG_INVALID = """[default.scheduler_args. test]
117+ _CONFIG_INVALID = """[default.test.cfg ]
118118a_run_opt_that = does_not_exist
119119s = option_that_exists
120120"""
121121
122- _TEAM_CONFIG = """[default.scheduler_args. test]
122+ _TEAM_CONFIG = """[default.test.cfg ]
123123s = team_default
124124i = 50
125125f = 1.2
126126"""
127127
128- _MY_CONFIG = """[default.scheduler_args. test]
128+ _MY_CONFIG = """[default.test.cfg ]
129129s = my_default
130130i = 100
131131"""
@@ -158,32 +158,30 @@ def _write(self, filename: str, content: str) -> Path:
158158 return f
159159
160160 def test_load (self ) -> None :
161- runcfg = RunConfig ()
162- load (
163- profile = "default" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), runcfg = runcfg
164- )
165- self .assertEqual ("/home/bob/logs" , runcfg .get ("log_dir" ))
166- self .assertEqual (True , runcfg .get ("prepend_cwd" ))
161+ cfg = RunConfig ()
162+ load (profile = "default" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
163+ self .assertEqual ("/home/bob/logs" , cfg .get ("log_dir" ))
164+ self .assertEqual (True , cfg .get ("prepend_cwd" ))
167165
168- runcfg = RunConfig ()
169- load (profile = "test" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), runcfg = runcfg )
170- self .assertEqual (None , runcfg .get ("log_dir" ))
171- self .assertEqual (False , runcfg .get ("prepend_cwd" ))
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" ))
172170
173- runcfg = RunConfig ()
174- load (profile = "alpha" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), runcfg = runcfg )
175- self .assertEqual ("/tmp/logs" , runcfg .get ("log_dir" ))
176- self .assertEqual (None , runcfg .get ("prepend_cwd" ))
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" ))
177175
178176 def test_no_override_load (self ) -> None :
179- runcfg = RunConfig ()
180- runcfg .set ("log_dir" , "/foo/bar" )
181- runcfg .set ("debug" , 1 )
177+ cfg = RunConfig ()
178+ cfg .set ("log_dir" , "/foo/bar" )
179+ cfg .set ("debug" , 1 )
182180
183- load (profile = "test" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), runcfg = runcfg )
184- self .assertEqual ("/foo/bar" , runcfg .get ("log_dir" ))
185- self .assertEqual (1 , runcfg .get ("debug" ))
186- self .assertEqual (False , runcfg .get ("prepend_cwd" ))
181+ load (profile = "test" , scheduler = "local_cwd" , f = StringIO (_CONFIG ), cfg = cfg )
182+ self .assertEqual ("/foo/bar" , cfg .get ("log_dir" ))
183+ self .assertEqual (1 , cfg .get ("debug" ))
184+ self .assertEqual (False , cfg .get ("prepend_cwd" ))
187185
188186 @patch (
189187 TORCHX_GET_SCHEDULERS ,
@@ -192,14 +190,14 @@ def test_no_override_load(self) -> None:
192190 def test_apply (self , _ ) -> None :
193191 with patch (PATH_CWD , return_value = Path (self .test_dir )):
194192 with patch (PATH_HOME , return_value = Path (self .test_dir ) / "home" / "bob" ):
195- runcfg = RunConfig ()
196- runcfg .set ("s" , "runtime_value" )
193+ cfg = RunConfig ()
194+ cfg .set ("s" , "runtime_value" )
197195
198- apply (profile = "default" , scheduler = "test" , runcfg = runcfg )
196+ apply (profile = "default" , scheduler = "test" , cfg = cfg )
199197
200- self .assertEqual ("runtime_value" , runcfg .get ("s" ))
201- self .assertEqual (100 , runcfg .get ("i" ))
202- self .assertEqual (1.2 , runcfg .get ("f" ))
198+ self .assertEqual ("runtime_value" , cfg .get ("s" ))
199+ self .assertEqual (100 , cfg .get ("i" ))
200+ self .assertEqual (1.2 , cfg .get ("f" ))
203201
204202 def test_dump_invalid_scheduler (self ) -> None :
205203 with self .assertRaises (ValueError ):
@@ -215,50 +213,50 @@ def test_dump_only_required(self, _) -> None:
215213 # test scheduler has no required options hence expect empty string
216214 dump (f = sfile , required_only = True )
217215
218- runcfg = RunConfig ()
216+ cfg = RunConfig ()
219217 sfile .seek (0 )
220- load (profile = "default" , scheduler = "test" , f = sfile , runcfg = runcfg )
218+ load (profile = "default" , scheduler = "test" , f = sfile , cfg = cfg )
221219
222- self .assertFalse (runcfg .cfgs )
220+ self .assertFalse (cfg .cfgs )
223221
224222 @patch (
225223 TORCHX_GET_SCHEDULERS ,
226224 return_value = {"test" : TestScheduler ()},
227225 )
228226 def test_load_invalid_runopt (self , _ ) -> None :
229- runcfg = RunConfig ()
227+ cfg = RunConfig ()
230228 load (
231229 profile = "default" ,
232230 scheduler = "test" ,
233231 f = StringIO (_CONFIG_INVALID ),
234- runcfg = runcfg ,
232+ cfg = cfg ,
235233 )
236234 # options in the config file but not in runopts
237235 # should be ignored (we shouldn't throw an error since
238236 # this makes things super hard to guarantee BC - stale config file will fail
239237 # to run, we don't want that)
240238
241- self .assertEquals ("option_that_exists" , runcfg .get ("s" ))
239+ self .assertEquals ("option_that_exists" , cfg .get ("s" ))
242240
243241 def test_load_no_section (self ) -> None :
244- runcfg = RunConfig ()
242+ cfg = RunConfig ()
245243 load (
246244 profile = "default" ,
247245 scheduler = "local_cwd" ,
248246 f = StringIO (),
249- runcfg = runcfg ,
247+ cfg = cfg ,
250248 )
251249 # is empty
252- self .assertFalse (runcfg .cfgs )
250+ self .assertFalse (cfg .cfgs )
253251
254252 load (
255253 profile = "default" ,
256254 scheduler = "local_cwd" ,
257255 f = StringIO ("[default.scheduler_args.local_cwd]\n " ),
258- runcfg = runcfg ,
256+ cfg = cfg ,
259257 )
260258 # still empty
261- self .assertFalse (runcfg .cfgs )
259+ self .assertFalse (cfg .cfgs )
262260
263261 @patch (
264262 TORCHX_GET_SCHEDULERS ,
@@ -270,12 +268,12 @@ def test_dump_and_load_all_runopt_types(self, _) -> None:
270268
271269 sfile .seek (0 )
272270
273- runcfg = RunConfig ()
274- load (profile = "default" , scheduler = "test" , f = sfile , runcfg = runcfg )
271+ cfg = RunConfig ()
272+ load (profile = "default" , scheduler = "test" , f = sfile , cfg = cfg )
275273
276274 # all runopts in the TestScheduler have defaults, just check against those
277275 for opt_name , opt in TestScheduler ().run_opts ():
278- self .assertEqual (runcfg .get (opt_name ), opt .default )
276+ self .assertEqual (cfg .get (opt_name ), opt .default )
279277
280278 def test_dump_and_load_all_registered_schedulers (self ) -> None :
281279 # dump all the runopts for all registered schedulers
@@ -284,11 +282,11 @@ def test_dump_and_load_all_registered_schedulers(self) -> None:
284282
285283 sfile = StringIO ()
286284 dump (sfile )
287-
285+ print ( sfile . getvalue ())
288286 for sched_name , sched in get_schedulers (session_name = "_" ).items ():
289287 sfile .seek (0 ) # reset the file pos
290- runcfg = RunConfig ()
291- load (profile = "default" , scheduler = sched_name , f = sfile , runcfg = runcfg )
288+ cfg = RunConfig ()
289+ load (profile = "default" , scheduler = sched_name , f = sfile , cfg = cfg )
292290
293291 for opt_name , _ in sched .run_opts ():
294- self .assertTrue (opt_name in runcfg .cfgs )
292+ self .assertTrue (opt_name in cfg .cfgs )
0 commit comments