3131 BaseInstaller ,
3232 CloudAIGymEnv ,
3333 Installable ,
34+ MissingTestError ,
3435 Parser ,
3536 Registry ,
3637 Runner ,
@@ -195,34 +196,47 @@ def register_signal_handlers(signal_handler: Callable) -> None:
195196 signal .signal (sig , signal_handler )
196197
197198
198- def handle_dry_run_and_run (args : argparse .Namespace ) -> int :
199+ def _setup_system_and_scenario (
200+ args : argparse .Namespace ,
201+ ) -> tuple [Optional [System ], Optional [TestScenario ], Optional [list [Test ]]]:
199202 parser = Parser (args .system_config )
200- system , tests , test_scenario = parser .parse (args .tests_dir , args .test_scenario )
203+ try :
204+ system , tests , test_scenario = parser .parse (args .tests_dir , args .test_scenario )
205+ except MissingTestError as e :
206+ logging .error (e .message )
207+ return None , None , None
201208
202209 assert test_scenario is not None
203210
204211 if args .output_dir :
205212 system .output_path = args .output_dir .absolute ()
206213
207214 if not prepare_output_dir (system .output_path ):
208- return 1
215+ return None , None , None
216+
209217 if args .mode == "dry-run" :
210218 system .monitor_interval = 1
211219 system .update ()
212220
213- if args .single_sbatch :
214- if not isinstance (system , SlurmSystem ):
215- logging .error ("Single sbatch is only supported for Slurm systems." )
216- return 1
221+ return system , test_scenario , tests
217222
218- Registry ().update_runner ("slurm" , SingleSbatchRunner )
219223
220- logging . info ( f"System Name: { system . name } " )
221- logging . info ( f"Scheduler: { system . scheduler } " )
222- logging . info ( f"Test Scenario Name: { test_scenario . name } " )
224+ def _handle_single_sbatch ( args : argparse . Namespace , system : System ) -> bool :
225+ if not args . single_sbatch :
226+ return True
223227
224- logging .info ("Checking if test templates are installed." )
228+ if not isinstance (system , SlurmSystem ):
229+ logging .error ("Single sbatch is only supported for Slurm systems." )
230+ return False
225231
232+ Registry ().update_runner ("slurm" , SingleSbatchRunner )
233+ return True
234+
235+
236+ def _check_installation (
237+ args : argparse .Namespace , system : System , tests : list [Test ], test_scenario : TestScenario
238+ ) -> bool :
239+ logging .info ("Checking if test templates are installed." )
226240 installables , installer = prepare_installation (system , tests , test_scenario )
227241
228242 if args .enable_cache_without_check :
@@ -233,6 +247,29 @@ def handle_dry_run_and_run(args: argparse.Namespace) -> int:
233247 if args .mode == "run" and not result .success :
234248 logging .error ("CloudAI has not been installed. Please run install mode first." )
235249 logging .error (result .message )
250+ return False
251+
252+ return True
253+
254+
255+ def handle_dry_run_and_run (args : argparse .Namespace ) -> int :
256+ setup_result = _setup_system_and_scenario (args )
257+ if setup_result == (None , None , None ):
258+ return 1
259+
260+ system , test_scenario , tests = setup_result
261+ assert system is not None
262+ assert test_scenario is not None
263+ assert tests is not None
264+
265+ if not _handle_single_sbatch (args , system ):
266+ return 1
267+
268+ logging .info (f"System Name: { system .name } " )
269+ logging .info (f"Scheduler: { system .scheduler } " )
270+ logging .info (f"Test Scenario Name: { test_scenario .name } " )
271+
272+ if not _check_installation (args , system , tests , test_scenario ):
236273 return 1
237274
238275 logging .info (test_scenario .pretty_print ())
@@ -247,11 +284,10 @@ def handle_dry_run_and_run(args: argparse.Namespace) -> int:
247284
248285 if all (tr .is_dse_job for tr in test_scenario .test_runs ):
249286 handle_dse_job (runner , args )
250- else :
251- logging .error ("Mixing DSE and non-DSE jobs is not allowed." )
252- return 1
287+ return 0
253288
254- return 0
289+ logging .error ("Mixing DSE and non-DSE jobs is not allowed." )
290+ return 1
255291
256292
257293def handle_generate_report (args : argparse .Namespace ) -> int :
0 commit comments