-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathbenchmark_report.py
More file actions
51 lines (38 loc) · 1.46 KB
/
benchmark_report.py
File metadata and controls
51 lines (38 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Summarize verification report and exit non-zero on verification failure."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
def parse_args() -> argparse.Namespace:
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument(
"--report-path",
type=Path,
default=Path("artifacts/report.json"),
help="Path to report generated by the ServerApp.",
)
return parser.parse_args()
def main() -> int:
"""Print benchmark-ready verification summary."""
args = parse_args()
report = json.loads(args.report_path.read_text(encoding="utf-8"))
verification_rounds = report.get("verification_rounds", [])
if not verification_rounds:
print("No verification rounds found in report.")
return 1
failed = [item for item in verification_rounds if not item.get("passed", False)]
print("round\tnum_replies\tmax_abs_diff\tpassed")
for item in verification_rounds:
print(
f"{item['round']}\t{item['num_replies']}\t"
f"{item['max_abs_diff']:.8e}\t{int(item['passed'])}"
)
if failed:
print(f"Verification failed in {len(failed)} rounds.")
return 2
max_diff = max(float(item["max_abs_diff"]) for item in verification_rounds)
print(f"All rounds verified. Max observed absolute difference: {max_diff:.8e}")
return 0
if __name__ == "__main__":
raise SystemExit(main())