From 4af9ee441bef583b4e3835b9aecb873faf2c0b18 Mon Sep 17 00:00:00 2001 From: nej1gotnochill Date: Sat, 5 Dec 2026 14:36:39 +0530 Subject: [PATCH 1/2] feat: add OpenMS benchmark dashboard Add a standard-library-only view over the stored benchmark result JSONs, so the latest results, their history and every run can be inspected without reading the report or the raw files. - Latest: one card per (benchmark, dataset, runtime source) series with provenance, identification yield first, then verdict/correctness, then runtime and peak RSS as supporting context. - History: small multiples of wall time, peak RSS and the most relevant recorded benchmark metric, positioned at the real run timestamps; missing values stay gaps and are never interpolated. - All runs: every OpenMS run plus the ProteoBench reference results, with benchmark and dataset filters and a visible row counter. SOURCE builds and PACKAGE .deb runs are separate series and are never merged or ranked against each other, no cross-tool ranking is computed, and a hardware/load/cache disclaimer is shown on the page. Identification yield is rendered only when a result records it; otherwise it says "unavailable" and never 0. Smoke-benchmark yield is deliberately out of scope until Percolator output and the metric definitions are validated. The Pages workflow renders site/dashboard.html from site-results, the landing page links the dashboard first, and the new tests are wired into PR CI. --- .github/workflows/pages.yml | 6 +- .github/workflows/pr-checks.yml | 3 +- benchmark/dashboard_generate.py | 915 +++++++++++++++++++++++++++ benchmark/pages_generate.py | 25 +- benchmark/test_dashboard_generate.py | 302 +++++++++ 5 files changed, 1243 insertions(+), 8 deletions(-) create mode 100644 benchmark/dashboard_generate.py create mode 100644 benchmark/test_dashboard_generate.py diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 4a7c50c..d36c77d 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -185,7 +185,7 @@ jobs: echo "assembled $smoke smoke run(s), $openswath openswath run(s), $(find "$OUT_DIR/tools" -name '*.json' | wc -l | tr -d ' ') tool reference(s)" echo "sources: main history=$history_total file(s), benchmark-results=$generated_total file(s), identical duplicate(s) collapsed=$duplicates_identical" - - name: Generate site (pinned reference view + optional latest view) + - name: Generate site (dashboard + pinned reference view + optional latest view) run: | ARGS=(--site-dir site) if [ -d upstream ]; then @@ -198,6 +198,10 @@ jobs: # main's tool-reference JSONs. Same renderer the CI report uses. python benchmark/report/report_generate.py render \ --results-dir site-results --out site/report.html + # Benchmark dashboard: the primary view over the same results tree + # (latest cards, history charts, filterable table). + python benchmark/dashboard_generate.py \ + --results-dir site-results --out site/dashboard.html - name: Upload Pages artifact uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index a1bc7af..589643b 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -60,7 +60,8 @@ jobs: benchmark/test_recover_nightly_results.py \ benchmark/test_runner_timestamps.py \ benchmark/report/test_generic_renderer.py \ - benchmark/report/test_v2_schema.py; do + benchmark/report/test_v2_schema.py \ + benchmark/test_dashboard_generate.py; do echo "== python $f" python "$f" done diff --git a/benchmark/dashboard_generate.py b/benchmark/dashboard_generate.py new file mode 100644 index 0000000..b6ad4dc --- /dev/null +++ b/benchmark/dashboard_generate.py @@ -0,0 +1,915 @@ +#!/usr/bin/env python3 +"""Generate the static OpenMS benchmark dashboard. + + benchmark run -> JSON result -> dashboard_generate.py -> dashboard.html + +The dashboard is the primary way to explore the stored benchmark results. It +is a *view* over the same result tree the report renderer reads; it never +maintains data of its own. + +Sections (mirroring the Sage CI/Benchmarks page, without copying its data): + + Latest one card per (benchmark, dataset, runtime source) series showing + the latest run: provenance, identification-yield metrics first, + then verdict/correctness, then runtime and peak RSS as supporting + measurements. + History small-multiple SVG line charts per series: wall time, peak RSS and + the most relevant available benchmark metric (identification yield + when the stored results carry it). X positions come from the real + run timestamps; missing values are left as gaps, never + interpolated. + Table every stored run with benchmark/dataset filters (vanilla JS). + +Design rules enforced here: + + * Identification yield (PSMs / peptides / proteins / features @ 1% FDR or + equivalent) is visually first-class whenever a result records it. A run + that does not record it says "unavailable" -- it never shows a 0. + * Runtime and peak RSS are labelled as performance/context measurements and + are not presented as benchmark quality. + * SOURCE and PACKAGE runs are distinct series and are never merged, so the + page cannot imply that runs with different provenance are comparable. + * No cross-tool ranking is computed or rendered. + +Stdlib only, like the rest of the benchmarking repository. +""" + +import argparse +import datetime as _dt +import html +import json +import os +import re +import sys +import importlib.util + +_HERE = os.path.dirname(os.path.abspath(__file__)) +_REPORT_DIR = os.path.join(_HERE, "report") +_REPORT_PATH = os.path.join(_REPORT_DIR, "report_generate.py") +_spec = importlib.util.spec_from_file_location("report_generate", _REPORT_PATH) +rg = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(rg) + + +# --------------------------------------------------------------------------- +# identification-yield registry +# +# Only metrics actually written by the runners/normalizers are listed. The +# registry decides *presentation* (what is shown first, how it is formatted); +# it never derives a value that a result does not contain. +# +# Keys with an arm suffix (e.g. target_psms_at_1pct_fdr_baseline from the +# ProSE+PeptDeep normalizer) match by prefix and keep the suffix as a label. +# --------------------------------------------------------------------------- + +YIELD_METRICS = ( + {"key": "target_psms_at_1pct_fdr", "label": "PSMs @ 1% FDR", "kind": "count"}, + {"key": "target_peptides_at_1pct_fdr", "label": "Peptides @ 1% FDR", "kind": "count"}, + {"key": "psms_total", "label": "PSMs scored (all q)", "kind": "count"}, + {"key": "identified_peptides", "label": "Identified peptides", "kind": "count"}, + {"key": "identified_proteins", "label": "Identified proteins", "kind": "count"}, + {"key": "identified_features", "label": "Identified features", "kind": "count"}, + {"key": "quantified_precursors", "label": "Quantified precursors", "kind": "count"}, +) + +# Yield metrics that are diagnostics, not identification yield: shown with the +# supporting metrics, never in the yield block. +YIELD_DIAGNOSTICS = ( + "entrapment_psms_at_1pct_fdr", + "entrapment_peptides_at_1pct_fdr", + "library_coverage", +) + +PERFORMANCE_KEYS = ("wall_time_s", "peak_rss_kb", "cpu_time_s") + +# Readable labels for the supporting (non-yield) metrics actually recorded by +# the stored results. Unknown keys fall back to "snake_case -> Sentence case". +SUPPORTING_LABELS = { + "feature_quality_sum": "Feature quality sum", + "total_intensity": "Total intensity", + "library_coverage": "Library coverage", + "library_peptides": "Library peptides", + "library_peptides_identifiable": "Library peptides (identifiable)", + "library_peptides_orphan": "Library peptides (orphan)", + "library_precursor_mz": "Library precursors (m/z)", + "library_transitions": "Library transitions", + "identified_precursor_mz": "Identified precursors (m/z)", + "transitions_used": "Transitions used", + "entrapment_psms_at_1pct_fdr": "Entrapment PSMs @ 1% FDR", + "entrapment_peptides_at_1pct_fdr": "Entrapment peptides @ 1% FDR", + "cv_median": "CV median", + "median_abs_epsilon": "Median |epsilon|", + "mean_abs_epsilon": "Mean |epsilon|", + "roc_auc": "ROC AUC", +} + + +def _metric_label(name): + if name in SUPPORTING_LABELS: + return SUPPORTING_LABELS[name] + label = name.replace("_", " ").strip() + return label[:1].upper() + label[1:] + + +def _yield_match(metric_name): + """(label, kind) when metric_name is an identification-yield metric.""" + for spec in YIELD_METRICS: + if metric_name == spec["key"]: + return spec["label"], spec["kind"] + prefix = spec["key"] + "_" + if metric_name.startswith(prefix) and metric_name[len(prefix):]: + suffix = metric_name[len(prefix):].replace("_", " ") + return f"{spec['label']} ({suffix})", spec["kind"] + return None + + +def _is_numeric(value): + return isinstance(value, (int, float)) and not isinstance(value, bool) + + +def _fmt_count(value): + if isinstance(value, float) and not value.is_integer(): + return f"{value:,.3f}" + return f"{int(value):,}" + + +def _fmt_performance(name, value): + """Formatting for the supporting performance metrics.""" + if value is None: + return "unavailable" + if name == "wall_time_s": + return rg.fmt_seconds(value) + if name == "peak_rss_kb": + return rg.fmt_bytes(float(value) * 1024) + if name == "cpu_time_s": + return f"{value:.2f} s" + return str(value) + + +def _fmt_value(name, value): + """Format one metric value for a table cell or chart point.""" + if value is None: + return "unavailable" + match = _yield_match(name) + if name == "library_coverage" and _is_numeric(value): + return f"{value * 100:.1f}%" + if match and match[1] == "count": + return _fmt_count(value) + if name in PERFORMANCE_KEYS: + return _fmt_performance(name, value) + if _is_numeric(value): + return _fmt_count(value) + return str(value) + + +def _fmt_run_at(value): + """'2026-11-06T03:21:53Z' -> '2026-11-06 03:21 UTC' (raw text when odd).""" + if not value: + return "unknown time" + text = str(value).strip() + if text.endswith("Z"): + text = text[:-1] + " UTC" + # Replace only the date/time separator, never the 'T' inside "UTC". + head, sep, tail = text.partition("T") + return f"{head} {tail}" if sep else text + + +def _parse_timestamp(value): + """Aware/naive datetime for an ISO-8601 run_at, or None.""" + if not value: + return None + try: + return _dt.datetime.fromisoformat(str(value).replace("Z", "+00:00")) + except (TypeError, ValueError): + return None + + +def _commit_url(sha): + if sha and re.fullmatch(r"[0-9a-fA-F]{7,40}", str(sha)): + return f"https://github.com/OpenMS/OpenMS/commit/{sha}" + return None + + +def _series_key(result): + """One dashboard series per benchmark/dataset/runtime source.""" + return (rg._benchmark_name(result), rg._dataset(result), rg._runtime_source(result)) + + +def _latest_per_series(openms_runs): + """The most recent run of every series, as (key, run) sorted by key.""" + latest = {} + for run in openms_runs: + key = _series_key(run) + current = latest.get(key) + if current is None or rg._run_at(run) >= rg._run_at(current): + latest[key] = run + return sorted(latest.items()) + + +def _yield_metrics(result): + """[(metric_name, label, value)] for the identification-yield block.""" + found = [] + for name, value in (rg._metrics(result) or {}).items(): + if name == "verdict" or name in YIELD_DIAGNOSTICS: + continue + match = _yield_match(name) + if match is None or not _is_numeric(value): + continue + found.append((name, match[0], value)) + # Registry order (PSMs, peptides, ...), then any other matched key. + order = {spec["key"]: i for i, spec in enumerate(YIELD_METRICS)} + + def rank(item): + name = item[0] + for spec in YIELD_METRICS: + if name == spec["key"]: + return (order[spec["key"]], name) + if name.startswith(spec["key"] + "_"): + return (order[spec["key"]], name) + return (len(order), name) + + return sorted(found, key=rank) + + +def _supporting_metrics(result): + """Non-yield, non-verdict metric pairs (diagnostics included).""" + pairs = [] + for name, value in sorted((rg._metrics(result) or {}).items()): + if name == "verdict": + continue + if _yield_match(name) is not None: + continue + if not _is_numeric(value) and not isinstance(value, (str, bool)): + continue + pairs.append((name, value)) + return pairs + + +# --------------------------------------------------------------------------- +# correctness +# --------------------------------------------------------------------------- + +def _correctness_items(result): + """[(text, ok|None)] describing the run's correctness section.""" + corr = result.get("correctness") or {} + items = [] + if "expected_features" in corr and "actual_features" in corr: + expected, actual = corr["expected_features"], corr["actual_features"] + items.append((f"{actual} / {expected} expected features", expected == actual)) + for name in sorted(corr): + value = corr[name] + if isinstance(value, bool): + label = name.replace("_", " ") + items.append((f"{label}: {'yes' if value else 'no'}", value)) + if not items and corr: + items.append((f"{len(corr)} correctness field(s) recorded", None)) + return items + + +# --------------------------------------------------------------------------- +# tiny SVG line charts (no JS chart library, no interpolation) +# --------------------------------------------------------------------------- + +_CHART_W = 360 +_CHART_H = 150 +_PAD_L = 48 +_PAD_R = 12 +_PAD_T = 12 +_PAD_B = 26 + + +def _chart_geometry(points): + """x/y pixel mappers for a list of (index, timestamp|None, value|None). + + X uses the real timestamps when every point has one and there are at + least two distinct instants; otherwise points are evenly spaced. Y is + linear over the observed values (baseline_zero pins the bottom to 0). + """ + stamps = [stamp for _, stamp, _ in points] + use_time = all(stamp is not None for stamp in stamps) and len( + {stamp for stamp in stamps}) > 1 + if use_time: + epochs = [stamp.timestamp() for stamp in stamps] + x_lo, x_hi = min(epochs), max(epochs) + else: + x_lo, x_hi = 0.0, float(max(1, len(points) - 1)) + + def x_at(i): + if use_time: + position = (points[i][1].timestamp() - x_lo) / (x_hi - x_lo) + else: + position = i / (x_hi - x_lo) if x_hi else 0.0 + return _PAD_L + position * (_CHART_W - _PAD_L - _PAD_R) + + return x_at + + +def _svg_line_chart(points, title, unit, baseline_zero=False): + """A small multiple SVG chart. + + points: [{"run_at": str, "value": number|None, "label": str}] + Missing values break the line (a gap), never drawn as zero. + """ + plotted = [ + (i, _parse_timestamp(p["run_at"]), p["value"], p) + for i, p in enumerate(points) + ] + values = [v for _, _, v, _ in plotted if v is not None] + if not values: + return "" + x_at = _chart_geometry([(i, stamp, v) for i, stamp, v, _ in plotted]) + lo, hi = min(values), max(values) + if baseline_zero: + lo = 0.0 + if hi == lo: + hi = lo + 1.0 if lo == 0 else lo * 1.1 + if hi == lo: + hi = lo + 1.0 + plot_h = _CHART_H - _PAD_T - _PAD_B + + def y_at(value): + return _PAD_T + (hi - value) / (hi - lo) * plot_h + + parts = [ + f'' + ] + for tick in (0.0, 0.5, 1.0): + value = lo + tick * (hi - lo) + y = y_at(value) + parts.append( + f'' + ) + parts.append( + f'{html.escape(unit(value))}' + ) + + # One polyline per run of consecutive recorded values (gaps stay gaps). + segment = [] + segments = [] + for index, _, value, _ in plotted: + if value is None: + if segment: + segments.append(segment) + segment = [] + else: + segment.append((index, value)) + if segment: + segments.append(segment) + for segment in segments: + if len(segment) < 2: + continue + coords = " ".join(f"{x_at(i):.1f},{y_at(v):.1f}" for i, v in segment) + parts.append(f'') + for index, _, value, point in plotted: + if value is None: + continue + title_text = f"{point['label']} · {_fmt_run_at(point['run_at'])} · {_fmt_value(point['name'], value)}" + parts.append( + f'' + f"{html.escape(title_text)}" + ) + + first_ts = plotted[0][1] + last_ts = plotted[-1][1] + first_label = first_ts.strftime("%Y-%m-%d") if first_ts else "run 1" + last_label = last_ts.strftime("%Y-%m-%d") if last_ts else f"run {len(plotted)}" + parts.append( + f'{html.escape(first_label)}' + ) + if len(plotted) > 1: + parts.append( + f'{html.escape(last_label)}' + ) + parts.append("") + return "".join(parts) + + +def _history_metric_choice(series): + """The most relevant benchmark metric of a history series. + + Identification yield wins; otherwise the first numeric non-performance + metric recorded for the series. Returns (name, label, unit_fn, zero_base) + or None. + """ + numeric = [col for col in series["columns"] + if col["kind"] == "numeric" + and series["values"].get(col["name"]) + and any(v is not None for v in series["values"][col["name"]])] + with_yield = [col for col in numeric if _yield_match(col["name"])] + if with_yield: + name = with_yield[0]["name"] + return (name, _yield_match(name)[0], _fmt_count, True) + for col in numeric: + name = col["name"] + if name.startswith("performance."): + continue + return (name, name, _fmt_count, False) + return None + + +def _history_card(series): + """One small-multiple card (3 charts) for a history series.""" + runs = series["runs"] + esc = html.escape + bench, dataset, runtime = series["key"] + charts = [] + + def add_chart(name, label, unit_fn, zero_base): + values = series["values"].get(name) + if not values or not any(v is not None for v in values): + return + points = [ + {"run_at": rg._run_at(run), "value": value, "label": rg._run_id(run), + "name": name} + for run, value in zip(runs, values) + ] + svg = _svg_line_chart(points, label, unit_fn, zero_base) + if svg: + charts.append( + f'
{esc(label)}
' + f"{svg}
" + ) + + add_chart("performance.wall_time_s", "Wall time", rg.fmt_seconds, False) + add_chart( + "performance.peak_rss_kb", "Peak RSS", + lambda v: rg.fmt_bytes(float(v) * 1024), False, + ) + choice = _history_metric_choice(series) + if choice: + name, label, unit_fn, zero_base = choice + add_chart(name, f"{label} (benchmark metric)", unit_fn, zero_base) + + missing = [label for label in ("Wall time", "Peak RSS") if not any( + label in chart for chart in charts)] + note = "" + if missing: + note += (f'
Not recorded for this series: ' + f'{esc(", ".join(missing))}.
') + if not choice: + note += ('
No identification-yield metric is recorded ' + 'for this series, so no benchmark-metric chart is drawn.
') + if not charts: + return "" + recorded = sum(1 for run in runs if rg._run_at(run)) + return f""" +
+

{esc(bench)} · {esc(dataset)} + {esc(runtime.upper())}

+
{''.join(charts)}
+
{len(runs)} run(s) in this series, {recorded} with a + recorded timestamp. Points are actual runs at their real timestamps; a + gap means the value was not recorded and is not interpolated.
+ {note} +
""" + + +# --------------------------------------------------------------------------- +# Latest cards +# --------------------------------------------------------------------------- + +def _provenance(result): + """(chip_html, detail_html) describing where the binaries came from.""" + runtime = rg._runtime_source(result) + if runtime == "package": + package = (result.get("identity", {}).get("runtime", {}) or {}).get("package", {}) or {} + detail = [] + if package.get("filename"): + detail.append(f'{html.escape(package["filename"])}') + if package.get("date"): + detail.append(f'build night {html.escape(str(package["date"]))}') + return (rg._chip("PACKAGE · nightly .deb", "warn"), + " · ".join(detail)) + return rg._chip("SOURCE · exact-SHA build", "ok"), "" + + +def _commit_html(result): + sha = rg._software_version(result) + if not sha or sha == "unknown": + return 'commit not recorded' + url = _commit_url(sha) + short = rg.short_sha(sha) + if url: + return f'{html.escape(short)}' + return f'{html.escape(short)}' + + +def _yield_block(result): + metrics = _yield_metrics(result) + if not metrics: + return ( + '
' + '
Identification yield
' + '

Unavailable — this run does not record ' + 'identification-yield metrics.

' + ) + tiles = "".join( + f'
{html.escape(_fmt_value(name, value))}
' + f'
{html.escape(label)}
' + for name, label, value in metrics + ) + return ( + '
Identification yield
' + f'
{tiles}
' + ) + + +def _latest_card(key, run): + esc = html.escape + bench, dataset, runtime = key + chip, provenance_detail = _provenance(run) + verdict = rg._verdict(run) + correctness = _correctness_items(run) + correctness_html = "".join( + rg._chip(text, "ok" if ok is True else "bad" if ok is False else "neutral") + for text, ok in correctness + ) or 'no correctness section' + supporting = "".join( + f'
{esc(_metric_label(name))}
' + f'
{esc(_fmt_value(name, value))}
' + for name, value in _supporting_metrics(run) + ) + perf_rows = "".join( + f'
{esc(label)}
{esc(_fmt_value(name, (rg._performance(run) or {}).get(name)))}
' + for name, label in ( + ("wall_time_s", "Wall time"), + ("peak_rss_kb", "Peak RSS"), + ("cpu_time_s", "CPU time"), + ) + ) + return f""" +
+

{esc(bench)}

+

{esc(dataset)} + {esc(runtime.upper())}

+

{chip} {provenance_detail}

+ {_yield_block(run)} +
+
{perf_rows}
+

Verdict {rg._chip(verdict, rg.status_class(verdict))} + · correctness {correctness_html}

+

Run {esc(rg._run_id(run))} · + {esc(_fmt_run_at(rg._run_at(run)))} · {_commit_html(run)}

+ {f'
{supporting}
' if supporting else ''} +
+
""" + + +# --------------------------------------------------------------------------- +# Table of all runs +# --------------------------------------------------------------------------- + +def _table_rows(openms_runs, tool_results): + """(yield_columns, rows_html) for every stored run/result row.""" + entries = [] + for run in openms_runs: + entries.append(("run", run)) + for tool in tool_results: + entries.append(("reference", tool)) + + yield_columns = [] + for _, entry in entries: + for name, label, _ in _yield_metrics(entry): + if name not in yield_columns: + yield_columns.append(name) + + esc = html.escape + rows = [] + for kind, entry in entries: + bench = rg._benchmark_name(entry) + dataset = rg._dataset(entry) + runtime = rg._runtime_source(entry) if kind == "run" else "reference" + perf = rg._performance(entry) or {} + verdict = rg._verdict(entry) + correctness = _correctness_items(entry) + correctness_html = " ".join( + rg._chip(text, "ok" if ok is True else "bad" if ok is False else "neutral") + for text, ok in correctness + ) or 'unavailable' + yield_cells = "".join( + f'{esc(_fmt_value(name, (rg._metrics(entry) or {}).get(name)))}' + for name in yield_columns + ) + rows.append( + f'' + f'{esc(_fmt_run_at(rg._run_at(entry)))}' + f'{esc(bench)}' + f'{esc(dataset)}' + f'{esc(runtime.upper())}' + f'{_commit_html(entry)}' + f'{rg._chip(verdict, rg.status_class(verdict))}' + f'{esc(_fmt_value("wall_time_s", perf.get("wall_time_s")))}' + f'{esc(_fmt_value("peak_rss_kb", perf.get("peak_rss_kb")))}' + f'{yield_cells}' + f'{correctness_html}' + f'{esc(rg._run_id(entry) or "?")}' + f"" + ) + return yield_columns, "".join(rows) + + +# --------------------------------------------------------------------------- +# page +# --------------------------------------------------------------------------- + +CSS = """ +:root { + --ink: #1f2430; --muted: #6b7280; --line: #e5e7eb; --bg: #ffffff; + --accent: #1a56db; --ok: #047857; --ok-bg: #ecfdf5; --bad: #b91c1c; + --bad-bg: #fef2f2; --warn: #b45309; --warn-bg: #fffbeb; + --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; + --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; +} +* { box-sizing: border-box; } +body { margin: 0; background: #f3f4f6; color: var(--ink); + font: 14px/1.55 var(--sans); } +.page { max-width: 1180px; margin: 24px auto; padding: 0 16px; } +header.top { margin-bottom: 18px; } +h1 { font-size: 24px; margin: 0 0 4px; } +.lede { color: var(--muted); max-width: 60rem; margin: 6px 0; } +nav.topnav a { margin-right: 1rem; } +h2.section-title { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; + color: var(--muted); margin: 26px 0 10px; } +.card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; + padding: 14px 16px; margin-bottom: 16px; } +.card h3 { margin: 0 0 2px; font-size: 16px; } +.grid { display: grid; gap: 16px; + grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); } +.identity { margin: 0 0 8px; color: #374151; } +.provenance { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; } +.badge { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 11px; + font-weight: 700; letter-spacing: .04em; vertical-align: 2px; } +.runtime-source { background: var(--ok-bg); color: var(--ok); border: 1px solid #a7f3d0; } +.runtime-package { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; } +.runtime-reference { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; } +.yield { border: 1px solid #c7d2fe; background: #f8faff; border-radius: 8px; + padding: 10px 12px; margin: 10px 0; } +.yield-heading { font-size: 11px; font-weight: 700; letter-spacing: .08em; + text-transform: uppercase; color: #3730a3; margin-bottom: 6px; } +.tiles { display: grid; gap: 10px; + grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); } +.tile-value { font-size: 26px; font-weight: 700; line-height: 1.1; } +.tile-label { font-size: 11.5px; color: var(--muted); } +.unavailable-block { border-color: var(--line); background: #fafafa; } +.unavailable { color: #92400e; font-style: italic; } +.supporting { margin-top: 8px; } +.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + gap: 4px 18px; margin: 8px 0; padding: 0; } +.meta div { display: flex; justify-content: space-between; gap: 12px; + border-bottom: 1px dashed var(--line); padding: 2px 0; } +.meta dt { color: var(--muted); } +.meta dd { margin: 0; font-family: var(--mono); font-size: 12.5px; text-align: right; } +.verdict-line, .runref { margin: 6px 0 0; font-size: 12.5px; color: #374151; } +.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; + font-size: 12px; font-weight: 600; vertical-align: 2px; } +.chip.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #a7f3d0; } +.chip.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecaca; } +.chip.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; } +.chip.neutral { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; } +.chart-grid { display: grid; gap: 10px; + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); + margin-top: 8px; } +.chart-figure { margin: 0; } +.chart-figure figcaption { font-size: 11.5px; font-weight: 600; color: #374151; } +svg.chart { width: 100%; height: auto; display: block; } +svg.chart .grid { stroke: #e5e7eb; stroke-width: 1; } +svg.chart .axis { fill: var(--muted); font-size: 9px; font-family: var(--mono); } +svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; } +svg.chart .dot { fill: var(--accent); } +.note { color: var(--muted); font-size: 12px; margin-top: 8px; } +.dim { color: var(--muted); font-weight: 400; } +code, .mono { font-family: var(--mono); font-size: 12px; } +code { background: #f3f4f6; padding: 0 4px; border-radius: 4px; } +.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; + margin-bottom: 10px; } +.controls label { font-size: 12.5px; color: var(--muted); } +.controls select { font: inherit; padding: 4px 6px; border: 1px solid #d1d5db; + border-radius: 6px; background: #fff; } +.table-scroll { overflow-x: auto; } +table { border-collapse: collapse; width: max-content; min-width: 100%; + font-size: 12.5px; } +th, td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; + vertical-align: top; } +thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; + color: var(--muted); background: #fafafa; white-space: nowrap; } +td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; } +td.nowrap { white-space: nowrap; } +tbody tr:nth-child(even) { background: #fcfcfd; } +.disclaimer { border: 1px solid #fde68a; background: #fffbeb; border-radius: 8px; + padding: 10px 14px; font-size: 12.5px; margin-top: 18px; } +footer { color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0 26px; } +.empty { background: #fff; border: 1px solid var(--line); border-radius: 10px; + padding: 18px; } +""" + +_SCRIPT = """ +(function () { + var benchmark = document.getElementById("filter-benchmark"); + var dataset = document.getElementById("filter-dataset"); + var rows = Array.prototype.slice.call( + document.querySelectorAll("#runs-table tbody tr")); + var counter = document.getElementById("visible-count"); + if (!benchmark || !dataset || rows.length === 0) { return; } + + function matches(row) { + var b = row.getAttribute("data-benchmark"); + var d = row.getAttribute("data-dataset"); + return (benchmark.value === "all" || benchmark.value === b) + && (dataset.value === "all" || dataset.value === d); + } + + function apply() { + var visible = 0; + rows.forEach(function (row) { + var show = matches(row); + row.style.display = show ? "" : "none"; + if (show) { visible += 1; } + }); + if (counter) { counter.textContent = String(visible); } + } + + benchmark.addEventListener("change", apply); + dataset.addEventListener("change", apply); + apply(); +})(); +""" + + +def _page_title(): + return "OpenMS Benchmark Dashboard" + + +def render(openms_runs, tool_results, generated=None): + """Render the dashboard HTML for the loaded results.""" + generated = generated or _dt.datetime.now(_dt.timezone.utc) + esc = html.escape + + latest = _latest_per_series(openms_runs) + latest_html = "".join(_latest_card(key, run) for key, run in latest) + if not latest_html: + latest_html = ('
No benchmark runs were found in the ' + 'results tree.
') + + history_cards = "".join( + _history_card(series) for series in rg.build_history_series(openms_runs) + ) + if not history_cards: + history_cards = ('
No run history is available yet: ' + 'history charts need at least one recorded run per ' + 'series.
') + + yield_columns, table_rows = _table_rows(openms_runs, tool_results) + benchmarks = sorted({rg._benchmark_name(r) for r in openms_runs} + | {rg._benchmark_name(t) for t in tool_results}) + datasets = sorted({rg._dataset(r) for r in openms_runs} + | {rg._dataset(t) for t in tool_results}) + bench_options = "".join( + f'' + for b in benchmarks + ) + dataset_options = "".join( + f'' + for d in datasets + ) + yield_headers = "".join( + f'{esc(_yield_match(name)[0])}' for name in yield_columns + ) + n_rows = len(openms_runs) + len(tool_results) + n_runs = len(openms_runs) + + table_html = f""" +
+ + + {n_rows} of {n_rows} row(s) shown +
+
+ + + + + + {yield_headers} + + + {table_rows} +
Run atBenchmarkDatasetRuntimeCommitVerdictWallPeak RSSCorrectnessRun / label
+
+
Identification-yield columns appear before the correctness + column; a run that does not record one shows unavailable, never 0. + Rows marked REFERENCE are + ProteoBench-scorer reference results stored under + benchmark/results/tools/; they are not OpenMS runs and carry no + performance measurements.
""" + + return f""" + + +{esc(_page_title())} + +
+
+

{esc(_page_title())}

+

Every stored benchmark run in one place: latest results per + benchmark series, run history, and a filterable table. Identification yield + is shown first wherever the stored results record it; runtime and memory are + supporting performance measurements, not a measure of benchmark quality.

+ +
+ +

Latest — one card per benchmark / dataset / runtime source ({len(latest)} series)

+
{latest_html}
+ +

History — small multiples per series

+{history_cards} + +

All runs — {n_runs} OpenMS run(s) and {len(tool_results)} reference result(s)

+
{table_html}
+ +
+ Reading these numbers. Wall time, CPU time, peak RSS and + throughput are affected by runner hardware, background load, cache state and + the package/source runtime, so small differences are not meaningful + benchmark improvements. Series are separated by benchmark, dataset and + runtime source: results from different series (or a SOURCE build vs a + PACKAGE .deb) are not directly comparable and no cross-tool ranking + is implied. Identification-yield metrics are recorded only where the runner + reports them; where a series shows none, the dashboard states + “unavailable” rather than inferring a value. +
+ +
Generated from the stored result JSONs by +benchmark/dashboard_generate.py +({esc(generated.strftime('%Y-%m-%d %H:%M %Z'))}) · results schema +{esc(rg.SCHEMA)} · regenerate with +python3 benchmark/dashboard_generate.py --results-dir benchmark/results
+
+ + +""" + + +def generate(results_dir, out_path, generated=None): + """Load results_dir and write the dashboard to out_path. Returns stats.""" + openms_runs, tool_results = rg.load_results(results_dir) + doc = render(openms_runs, tool_results, generated=generated) + os.makedirs(os.path.dirname(out_path) or ".", exist_ok=True) + with open(out_path, "w", encoding="utf-8", newline="\n") as fh: + fh.write(doc) + return {"runs": len(openms_runs), "reference": len(tool_results), + "series": len(_latest_per_series(openms_runs))} + + +def main(argv=None): + if hasattr(sys.stdout, "reconfigure"): + sys.stdout.reconfigure(encoding="utf-8") + sys.stderr.reconfigure(encoding="utf-8") + parser = argparse.ArgumentParser( + description="Generate the static OpenMS benchmark dashboard.") + parser.add_argument("--results-dir", default=os.path.join(_HERE, "results"), + help="results tree to read (JSON results only)") + parser.add_argument("--out", default=os.path.join(_HERE, "reports", "dashboard.html"), + help="output HTML path") + parser.add_argument("--generated", default="", + help="ISO-8601 timestamp to record as the generation time " + "(default: now, UTC)") + args = parser.parse_args(argv) + + generated = None + if args.generated: + generated = _parse_timestamp(args.generated) + if generated is None: + sys.exit(f"--generated {args.generated!r} is not an ISO-8601 timestamp") + + if not os.path.isdir(args.results_dir): + sys.exit(f"results directory not found: {args.results_dir}") + stats = generate(args.results_dir, args.out, generated=generated) + print(f"dashboard written to {args.out} " + f"({stats['runs']} run(s), {stats['reference']} reference result(s), " + f"{stats['series']} series)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/benchmark/pages_generate.py b/benchmark/pages_generate.py index cf02bfa..4326a2f 100644 --- a/benchmark/pages_generate.py +++ b/benchmark/pages_generate.py @@ -75,6 +75,7 @@ def _nav(active): latest_label = "[Latest view]" if active == "latest" else "Latest view (optional)" return ( '