Skip to content

Commit 1408356

Browse files
oharboeclaude
andcommitted
util: syn-dashboard — local markdown TL;DR of the OpenROAD-SYN signal
bazelisk run //flow/designs:syn-dashboard prints a GitHub-flavored markdown status table over the forced-engine QoR tests already built in this workspace: per design, pass/fail for the fast synthesis tier and the full flow under each engine, the failing rule fields harvested from checkMetadata.py output, and the age of the newest result. It reads bazel-testlogs only — builds nothing, so it is instant — and the output pastes into a PR or issue as-is: the local TL;DR counterpart of https://dashboard.precisioninno.com/. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent a498113 commit 1408356

3 files changed

Lines changed: 193 additions & 1 deletion

File tree

‎flow/designs/BUILD‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
exports_files(["BUILD"])
2+
3+
# Local TL;DR of https://dashboard.precisioninno.com/: a GitHub-markdown
4+
# status table over the forced-engine OpenROAD-SYN QoR tests already
5+
# built in this workspace (see flow/designs/design.bzl). Reads
6+
# bazel-testlogs only — builds nothing, instant.
7+
#
8+
# bazelisk run //flow/designs:syn-dashboard
9+
alias(
10+
name = "syn-dashboard",
11+
actual = "//flow/util:synDashboard",
12+
)

‎flow/util/BUILD‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_python//python:defs.bzl", "py_library", "py_test")
1+
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
22
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
33

44
exports_files(["open_plots.sh"])
@@ -33,6 +33,14 @@ filegroup(
3333
visibility = ["//visibility:public"],
3434
)
3535

36+
# TL;DR markdown dashboard over locally built OpenROAD-SYN QoR tests;
37+
# run via the //flow/designs:syn-dashboard alias.
38+
py_binary(
39+
name = "synDashboard",
40+
srcs = ["synDashboard.py"],
41+
visibility = ["//flow/designs:__pkg__"],
42+
)
43+
3644
py_library(
3745
name = "genMetrics_lib",
3846
srcs = ["genMetrics.py"],

‎flow/util/synDashboard.py‎

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#!/usr/bin/env python3
2+
3+
"""TL;DR dashboard over locally built OpenROAD-SYN QoR test results.
4+
5+
The local counterpart of https://dashboard.precisioninno.com/: scans
6+
bazel-testlogs for the forced-engine QoR tests emitted by
7+
flow/designs/design.bzl (<name>_{syn,yosys}[_synth]_test) and prints a
8+
GitHub-flavored markdown status table, so the output can be pasted
9+
into a PR or issue as-is. Reads only what previous `bazelisk test`
10+
runs left behind — it never builds anything, so it is instant.
11+
12+
Run it via:
13+
bazelisk run //flow/designs:syn-dashboard
14+
"""
15+
16+
import os
17+
import re
18+
import sys
19+
import time
20+
import xml.etree.ElementTree as ET
21+
from pathlib import Path
22+
23+
# <design>_{syn,yosys}[_synth]_test, as emitted by design.bzl's
24+
# forced-engine variants. "_synth" marks the fast synthesis-only tier.
25+
TARGET_RE = re.compile(r"^(?P<base>.+)_(?P<engine>syn|yosys)(?P<fast>_synth)?_test$")
26+
27+
FAIL_RULE_RE = re.compile(r"^\[ERROR\] (\S+) fail test: (.*)$")
28+
MISSING_RULE_RE = re.compile(r"^\[ERROR\] Value not found for (\S+)\.$")
29+
30+
# (engine, fast) -> table column, in display order.
31+
COLUMNS = [
32+
("syn", True, "SYN synth"),
33+
("syn", False, "SYN flow"),
34+
("yosys", True, "yosys synth"),
35+
("yosys", False, "yosys flow"),
36+
]
37+
38+
39+
def workspace_root():
40+
"""The bazel workspace root: BUILD_WORKSPACE_DIRECTORY under
41+
`bazel run`, else the nearest ancestor holding MODULE.bazel."""
42+
env = os.environ.get("BUILD_WORKSPACE_DIRECTORY")
43+
if env:
44+
return Path(env)
45+
for path in [Path.cwd()] + list(Path.cwd().parents):
46+
if (path / "MODULE.bazel").is_file():
47+
return path
48+
sys.exit("error: not inside a bazel workspace (no MODULE.bazel found)")
49+
50+
51+
def test_status(test_dir):
52+
"""(passed, mtime) for one bazel-testlogs test dir, or None if the
53+
test never produced a result. The test.xml duration is just the
54+
metadata-check action, not the flow build, so it is not reported."""
55+
xml_file = test_dir / "test.xml"
56+
if not xml_file.is_file():
57+
return None
58+
try:
59+
root = ET.parse(xml_file).getroot()
60+
except ET.ParseError:
61+
return None
62+
failures = 0
63+
for suite in root.iter("testsuite"):
64+
failures += int(suite.get("failures", 0)) + int(suite.get("errors", 0))
65+
return failures == 0, xml_file.stat().st_mtime
66+
67+
68+
def failing_rules(test_dir):
69+
"""Failed rule fields harvested from checkMetadata.py output in
70+
test.log."""
71+
log_file = test_dir / "test.log"
72+
if not log_file.is_file():
73+
return []
74+
fields = []
75+
for line in log_file.read_text(errors="replace").splitlines():
76+
match = FAIL_RULE_RE.match(line)
77+
if match:
78+
fields.append(match.group(1))
79+
continue
80+
match = MISSING_RULE_RE.match(line)
81+
if match:
82+
fields.append(match.group(1) + " (missing)")
83+
return fields
84+
85+
86+
def age(mtime):
87+
seconds = max(0, time.time() - mtime)
88+
if seconds >= 86400:
89+
return f"{seconds / 86400:.0f}d ago"
90+
if seconds >= 3600:
91+
return f"{seconds / 3600:.0f}h ago"
92+
if seconds >= 60:
93+
return f"{seconds / 60:.0f}m ago"
94+
return "just now"
95+
96+
97+
def collect(root):
98+
"""{(platform, design_pkg): {(engine, fast): result}} from
99+
bazel-testlogs, where result adds the failed-rule fields."""
100+
designs = {}
101+
testlogs = root / "bazel-testlogs" / "flow" / "designs"
102+
if not testlogs.is_dir():
103+
return designs
104+
for xml_file in testlogs.glob("*/*/*/test.xml"):
105+
target_dir = xml_file.parent
106+
match = TARGET_RE.match(target_dir.name)
107+
if not match:
108+
continue
109+
status = test_status(target_dir)
110+
if status is None:
111+
continue
112+
passed, mtime = status
113+
key = (target_dir.parent.parent.name, target_dir.parent.name)
114+
designs.setdefault(key, {})[
115+
(match.group("engine"), bool(match.group("fast")))
116+
] = {
117+
"passed": passed,
118+
"mtime": mtime,
119+
"failing": [] if passed else failing_rules(target_dir),
120+
}
121+
return designs
122+
123+
124+
def format_rules(fields, limit=3):
125+
if len(fields) > limit:
126+
fields = fields[:limit] + [f"+{len(fields) - limit} more"]
127+
return ", ".join(fields)
128+
129+
130+
def main():
131+
designs = collect(workspace_root())
132+
print("# OpenROAD-SYN local status")
133+
print()
134+
if not designs:
135+
print("No forced-engine test results under bazel-testlogs yet. Build some:")
136+
print()
137+
print(" bazelisk test --keep_going //flow/designs/asap7:syn_synth_test")
138+
print(" bazelisk test --keep_going //flow/designs/asap7:syn_test")
139+
return
140+
header = (
141+
["design"] + [title for _, _, title in COLUMNS] + ["failing rules", "last run"]
142+
)
143+
print("| " + " | ".join(header) + " |")
144+
print("|" + "|".join(["---"] * len(header)) + "|")
145+
for (platform, pkg), results in sorted(designs.items()):
146+
cells = []
147+
for engine, fast, _ in COLUMNS:
148+
result = results.get((engine, fast))
149+
if result is None:
150+
cells.append("—")
151+
else:
152+
cells.append("✅" if result["passed"] else "❌")
153+
# The most meaningful failure detail: the full SYN flow if it
154+
# failed, else the fast SYN tier, else any failing variant.
155+
failing = []
156+
for key in [("syn", False), ("syn", True), ("yosys", False), ("yosys", True)]:
157+
result = results.get(key)
158+
if result and not result["passed"] and result["failing"]:
159+
failing = result["failing"]
160+
break
161+
newest = max(result["mtime"] for result in results.values())
162+
row = [f"{platform}/{pkg}"] + cells + [format_rules(failing), age(newest)]
163+
print("| " + " | ".join(row) + " |")
164+
print()
165+
print("Each cell reflects its own last `bazelisk test` run; `last run` is the")
166+
print("newest across the row. `—` = no local result: never run, or its build")
167+
print("failed outright (e.g. synthesis died) — bazel records no test result")
168+
print("for build failures, so run the suites with `--keep_going` and check")
169+
print("their output for `FAILED TO BUILD`.")
170+
171+
172+
if __name__ == "__main__":
173+
main()

0 commit comments

Comments
 (0)