1818from dataclasses import dataclass , field
1919from pathlib import Path
2020from typing import Dict , Iterable , List , Optional , Sequence , Tuple
21-
22- try :
23- import yaml
24- except ImportError as exc : # pragma: no cover - import guard
25- sys .stderr .write (
26- "PyYAML is required to run compile_check.py. "
27- "Install it with `pip install pyyaml`.\n "
28- )
29- raise
21+
22+ import yaml
3023
3124try :
3225 from packaging .specifiers import SpecifierSet
@@ -72,7 +65,9 @@ def add_warning(self, message: str) -> None:
7265
7366
7467def parse_args (argv : Optional [Sequence [str ]] = None ) -> argparse .Namespace :
75- parser = argparse .ArgumentParser (description = "Compile Kubeflow components and pipelines." )
68+ parser = argparse .ArgumentParser (
69+ description = "Compile Kubeflow components and pipelines."
70+ )
7671 parser .add_argument (
7772 "--tier" ,
7873 choices = ["core" , "all" ],
@@ -164,7 +159,9 @@ def create_targets(
164159 for metadata_path , tier , target_kind in discovered :
165160 if normalized_filters :
166161 absolute_metadata_dir = metadata_path .parent .resolve ()
167- if not any (absolute_metadata_dir .is_relative_to (f ) for f in normalized_filters ):
162+ if not any (
163+ absolute_metadata_dir .is_relative_to (f ) for f in normalized_filters
164+ ):
168165 continue
169166
170167 try :
@@ -177,10 +174,16 @@ def create_targets(
177174 logging .debug ("Skipping %s (compile_check disabled)." , metadata_path )
178175 continue
179176
180- module_filename = "component.py" if target_kind == "component" else "pipeline.py"
177+ module_filename = (
178+ "component.py" if target_kind == "component" else "pipeline.py"
179+ )
181180 module_path = metadata_path .with_name (module_filename )
182181 if not module_path .exists ():
183- logging .error ("Expected module %s not found for metadata %s" , module_path , metadata_path )
182+ logging .error (
183+ "Expected module %s not found for metadata %s" ,
184+ module_path ,
185+ metadata_path ,
186+ )
184187 continue
185188
186189 module_import = build_module_import_path (module_path )
@@ -197,7 +200,9 @@ def create_targets(
197200 return targets
198201
199202
200- def find_objects (module , target_kind : str ) -> List [Tuple [str , base_component .BaseComponent ]]:
203+ def find_objects (
204+ module , target_kind : str
205+ ) -> List [Tuple [str , base_component .BaseComponent ]]:
201206 found : List [Tuple [str , base_component .BaseComponent ]] = []
202207 for attr_name in dir (module ):
203208 attr = getattr (module , attr_name )
@@ -239,7 +244,9 @@ def validate_dependencies(metadata: Dict, result: ValidationResult) -> None:
239244 if not name :
240245 result .add_error (f"{ label } is missing a `name` field." )
241246 if not version :
242- result .add_error (f"{ label } for { name or '<unknown>' } is missing a `version` field." )
247+ result .add_error (
248+ f"{ label } for { name or '<unknown>' } is missing a `version` field."
249+ )
243250 elif SpecifierSet is not None :
244251 try :
245252 SpecifierSet (str (version ))
@@ -347,7 +354,9 @@ def run_validation(args: argparse.Namespace) -> int:
347354 logging .info (
348355 "✓ %s compiled successfully (%s)" ,
349356 target .metadata .get ("name" , target .module_import ),
350- ", " .join (result .compiled_objects ) if result .compiled_objects else "no output" ,
357+ ", " .join (result .compiled_objects )
358+ if result .compiled_objects
359+ else "no output" ,
351360 )
352361 else :
353362 logging .error (
@@ -359,7 +368,11 @@ def run_validation(args: argparse.Namespace) -> int:
359368 break
360369
361370 failed = [res for res in results if not res .success ]
362- logging .info ("Validation complete: %d succeeded, %d failed." , len (results ) - len (failed ), len (failed ))
371+ logging .info (
372+ "Validation complete: %d succeeded, %d failed." ,
373+ len (results ) - len (failed ),
374+ len (failed ),
375+ )
363376
364377 if failed :
365378 logging .error ("Compile check failed for the targets listed above." )
@@ -379,4 +392,3 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
379392
380393if __name__ == "__main__" : # pragma: no cover - CLI entry point
381394 sys .exit (main ())
382-
0 commit comments