Coverage for orchestrant/smoke/__main__.py: 0%

31 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-19 11:22 +0000

1"""Command-line entry point: ``python -m orchestrant.smoke``. 

2 

3Runs the wheel smoke checks (see :mod:`orchestrant.smoke.checks`) and prints 

4a report. Exits non-zero when any non-skipped check fails, so it can gate a 

5container build, a CI job, or a post-install verification step. 

6""" 

7 

8from __future__ import annotations 

9 

10import argparse 

11import dataclasses 

12import json 

13import sys 

14from typing import TYPE_CHECKING 

15 

16from orchestrant.smoke.checks import run_all 

17 

18 

19if TYPE_CHECKING: 

20 from orchestrant.smoke.checks import CheckResult 

21 

22 

23def _status(result: CheckResult) -> str: 

24 """Return the four-letter status token for a result.""" 

25 if result.ok: 

26 return "PASS" 

27 return "WARN" if result.optional else "FAIL" 

28 

29 

30def _format_line(result: CheckResult) -> str: 

31 """Render one result as an aligned report line.""" 

32 return f" [{_status(result):<4}] {result.name:<16} {result.detail}" 

33 

34 

35def main(argv: list[str] | None = None) -> int: 

36 """Run the wheel smoke suite and return a process exit code. 

37 

38 Args: 

39 argv: Optional argument vector (defaults to ``sys.argv``). 

40 

41 Returns: 

42 ``0`` when every non-skipped check passed, otherwise ``1``. 

43 """ 

44 parser = argparse.ArgumentParser( 

45 prog="python -m orchestrant.smoke", 

46 description="Exercise the installed ML wheels (torch, torchvision, " 

47 "onnxruntime, onnxruntime-genai, opencv, pillow, pyav, tvm, litert) " 

48 "with real work.", 

49 ) 

50 parser.add_argument( 

51 "--json", 

52 action="store_true", 

53 help="emit machine-readable JSON instead of the text report", 

54 ) 

55 args = parser.parse_args(argv) 

56 

57 results = run_all() 

58 failures = [r for r in results if not r.ok and not r.optional] 

59 warnings = [r for r in results if not r.ok and r.optional] 

60 

61 if args.json: 

62 payload = { 

63 "ok": not failures, 

64 "results": [dataclasses.asdict(r) for r in results], 

65 } 

66 print(json.dumps(payload, indent=2)) 

67 else: 

68 print("=== OrchestrANT wheel smoke ===") 

69 for result in results: 

70 print(_format_line(result)) 

71 passed = sum(1 for r in results if r.ok) 

72 print( 

73 f"=== {passed}/{len(results)} ok, " 

74 f"{len(failures)} failure(s), {len(warnings)} warning(s) ===" 

75 ) 

76 

77 return 1 if failures else 0 

78 

79 

80if __name__ == "__main__": 

81 sys.exit(main())