1313from pathlib import Path
1414
1515TOOLING_INCOMPATIBLE_EXIT_CODE = 86
16+ _BENCHMARK_API_ALTERNATIVES = (
17+ ("isaaclab.benchmark" , "isaaclab.benchmark.schema" ),
18+ ("isaaclab.test.benchmark" , "isaaclab.test.benchmark.schema" ),
19+ )
1620
1721
1822def _parse_args () -> argparse .Namespace :
@@ -21,27 +25,36 @@ def _parse_args() -> argparse.Namespace:
2125 return parser .parse_args ()
2226
2327
28+ def _check_module (module_name : str , names : tuple [str , ...]) -> list [str ]:
29+ """Return missing names or an import failure for one module."""
30+ missing : list [str ] = []
31+ try :
32+ module = __import__ (module_name , fromlist = list (names ))
33+ except Exception as exc : # noqa: BLE001 - the compatibility report records the exact import failure
34+ return [f"{ module_name } : { type (exc ).__name__ } : { exc } " ]
35+ for name in names :
36+ if not hasattr (module , name ):
37+ missing .append (f"{ module_name } .{ name } " )
38+ return missing
39+
40+
2441def check_capabilities () -> list [str ]:
2542 """Return missing API descriptions required by ``perf_runtime.py``."""
26- missing : list [str ] = []
27- checks = (
28- ("isaaclab.app" , ("AppLauncher" , "launch_simulation" )),
29- (
30- "isaaclab.test.benchmark" ,
43+ missing = _check_module ("isaaclab.app" , ("AppLauncher" , "launch_simulation" ))
44+ missing .extend (_check_module ("isaaclab_tasks.utils" , ("setup_preset_cli" , "resolve_task_config" )))
45+
46+ benchmark_failures : list [str ] = []
47+ for benchmark_module , schema_module in _BENCHMARK_API_ALTERNATIVES :
48+ alternative_missing = _check_module (
49+ benchmark_module ,
3150 ("BaseIsaacLabBenchmark" , "BenchmarkMonitor" , "builders" , "capture" , "stepping" ),
32- ),
33- ("isaaclab.test.benchmark.schema" , ("StartupTime" ,)),
34- ("isaaclab_tasks.utils" , ("setup_preset_cli" , "resolve_task_config" )),
35- )
36- for module_name , names in checks :
37- try :
38- module = __import__ (module_name , fromlist = list (names ))
39- except Exception as exc : # noqa: BLE001 - the compatibility report records the exact import failure
40- missing .append (f"{ module_name } : { type (exc ).__name__ } : { exc } " )
41- continue
42- for name in names :
43- if not hasattr (module , name ):
44- missing .append (f"{ module_name } .{ name } " )
51+ )
52+ alternative_missing .extend (_check_module (schema_module , ("StartupTime" ,)))
53+ if not alternative_missing :
54+ break
55+ benchmark_failures .extend (alternative_missing )
56+ else :
57+ missing .extend (benchmark_failures )
4558 return missing
4659
4760
0 commit comments