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
« 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``.
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"""
8from __future__ import annotations
10import argparse
11import dataclasses
12import json
13import sys
14from typing import TYPE_CHECKING
16from orchestrant.smoke.checks import run_all
19if TYPE_CHECKING:
20 from orchestrant.smoke.checks import CheckResult
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"
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}"
35def main(argv: list[str] | None = None) -> int:
36 """Run the wheel smoke suite and return a process exit code.
38 Args:
39 argv: Optional argument vector (defaults to ``sys.argv``).
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)
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]
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 )
77 return 1 if failures else 0
80if __name__ == "__main__":
81 sys.exit(main())