@@ -146,21 +146,20 @@ def _block(path: Path) -> dict[str, Any]:
146146 return block
147147
148148
149- def _check_setup_scripts (recipe : Mapping [str , Any ], source : Path , root : Path ) -> None :
150- """Fail where srtctl would only warn: a setup_script in none of the configs/ it stages."""
151- blocks = [block for name , block in recipe .items () if name != "schema" ]
152- for block in blocks if "base" in recipe else [recipe ]:
153- scripts = block .get ("setup_script" ) if isinstance (block , Mapping ) else None
154- for script in scripts if isinstance (scripts , list ) else [scripts ]:
155- if isinstance (script , str ) and not any (
156- (root / directory / sub / script ).is_file ()
157- for directory in SETUP_SCRIPT_DIRS
158- for sub in ("" , "patches" )
159- ):
160- raise ValueError (
161- f"{ source } : setup_script { script } is in none of "
162- f"{ ', ' .join (map (str , SETUP_SCRIPT_DIRS ))} or their patches/"
163- )
149+ def check_setup_script (recipe : Mapping [str , Any ], source : Path , root : Path ) -> None :
150+ """Fail where srtctl would only warn: a bound recipe's setup_script in none of the
151+ configs/ it stages. Launch and ``infx generate`` only: planner snapshots lack the
152+ srt-slurm submodule."""
153+ script = recipe .get ("setup_script" )
154+ if isinstance (script , str ) and not any (
155+ (root / directory / sub / script ).is_file ()
156+ for directory in SETUP_SCRIPT_DIRS
157+ for sub in ("" , "patches" )
158+ ):
159+ raise ValueError (
160+ f"{ source } : setup_script { script } is in none of "
161+ f"{ ', ' .join (map (str , SETUP_SCRIPT_DIRS ))} or their patches/"
162+ )
164163
165164
166165def compose_recipe (
@@ -179,11 +178,8 @@ def compose_recipe(
179178 exporter = {"telemetry" : {"dcgm_exporter" : {"port" : power_port }}}
180179 shared = merge_blocks (shared , merge_blocks (_block (root / TELEMETRY_BLOCK ), exporter ))
181180 if "base" in raw :
182- composed = {** raw , "base" : merge_blocks (shared , raw ["base" ])}
183- else :
184- composed = merge_blocks (shared , raw )
185- _check_setup_scripts (composed , path , root )
186- return composed
181+ return {** raw , "base" : merge_blocks (shared , raw ["base" ])}
182+ return merge_blocks (shared , raw )
187183
188184
189185def _required (environment : Mapping [str , str ], name : str ) -> str :
@@ -375,12 +371,9 @@ def main(argv: list[str] | None = None) -> None:
375371 path , _ , selector = args .recipe .partition (":" )
376372 agentic = os .environ .get ("IS_AGENTIC" ) == "1"
377373 try :
374+ root = repository_root ()
378375 composed = compose_recipe (
379- Path (path ),
380- agentic = agentic ,
381- multinode = True ,
382- root = repository_root (),
383- power_port = args .power_port ,
376+ Path (path ), agentic = agentic , multinode = True , root = root , power_port = args .power_port
384377 )
385378 variants = selected_recipes (composed , selector or None )
386379 if len (variants ) != 1 :
@@ -394,6 +387,7 @@ def main(argv: list[str] | None = None) -> None:
394387 source = Path (path ),
395388 )
396389 bound = resolve_fabric (bound , args .fabric )
390+ check_setup_script (bound , Path (path ), root )
397391 except (OSError , ValueError , KeyError , TypeError , yaml .YAMLError ) as error :
398392 parser .error (str (error ))
399393 args .output .write_text (yaml .safe_dump (bound , sort_keys = False ))
0 commit comments