Per-piece results are not published for this entry.
';
+ container.innerHTML = tablesOnly
+ ? `
This older version is shown with its tables only. Per-piece results
+ are in its release files.
`
+ : '
Per-piece results are not published for this entry.
';
return;
}
@@ -1499,6 +1526,55 @@
Submitting
return null;
}
+// Published result versions: the latest release at the root, every release
+// under versions//, listed newest first in versions.json at the root.
+// Without that file (a local checkout) the menu stays hidden.
+const IN_VERSION = /\/versions\/v\d+\.\d+\.\d+\/(?:index\.html)?$/.test(location.pathname);
+const SITE_ROOT = IN_VERSION ? "../../" : "./";
+
+async function fetchJson(url) {
+ try {
+ const response = await fetch(url);
+ return response.ok ? await response.json() : null;
+ } catch (error) { return null; }
+}
+
+// This version's release URL when it is shown with its tables only.
+let tablesOnly = null;
+
+async function showVersions() {
+ const [index, release] = await Promise.all([
+ fetchJson(SITE_ROOT + "versions.json"), fetchJson("./release.json"),
+ ]);
+ const versions = (index && index.versions) || [];
+ const current = release && versions.find((v) => v.tag === release.tag);
+ if (!current) return;
+ const newest = versions[0];
+ const date = (v) => v.published_at.slice(0, 10);
+ const select = el("version-select");
+ select.innerHTML = versions.map((v) => ``).join("");
+ select.addEventListener("change", () => {
+ location.href = SITE_ROOT + (select.value === newest.tag ? "" : `versions/${select.value}/`);
+ });
+ el("version-release").href = current.url;
+ if (!current.full) tablesOnly = current.url;
+ el("versions").hidden = false;
+
+ const note = el("version-note");
+ if (current !== newest) {
+ note.innerHTML = `You are viewing ${escapeHtml(current.tag)}, published ${escapeHtml(date(current))}.
+ Newer results exist: see the latest version (${escapeHtml(newest.tag)}).${
+ tablesOnly ? " Per-piece plots for this version are in its release files." : ""}`;
+ } else {
+ const permanent = new URL(`versions/${current.tag}/`, new URL(SITE_ROOT, location.href)).href;
+ note.innerHTML = `To cite these exact numbers, link this version: ${escapeHtml(permanent)}`;
+ note.style.borderLeftColor = "var(--accent)";
+ }
+ note.hidden = false;
+}
+showVersions();
+
loadBoard().then((board) => {
if (!board) {
const empty = el("empty");
diff --git a/docs/maintaining.md b/docs/maintaining.md
index 24fe581..c82a88c 100644
--- a/docs/maintaining.md
+++ b/docs/maintaining.md
@@ -337,8 +337,8 @@ published. `evaluate.yml` runs from `submissions`, so fast-forward it to
- `source_runs`: the completed run IDs, separated by spaces. Later listed
runs replace earlier entries for the same method. Entries not listed are
carried over from the latest release.
- - `release_tag`: a new `benchmark-*` tag. Leave `source_runs` empty to
- redeploy that release, or both empty to redeploy the latest one.
+ - `release_tag`: a new version `vMAJOR.MINOR.PATCH` (see "Older result
+ versions" below). Leave both empty to redeploy the latest release.
The workflow attaches the selected artifacts and a `benchmark-snapshot.zip`
for the site to the release, then deploys it. Actions artifacts
@@ -492,6 +492,28 @@ somewhere else.
files, CSVs and details of a release snapshot, and deploys it to GitHub Pages.
Documentation changes redeploy the latest release.
+### Older result versions
+
+Result releases are numbered `vMAJOR.MINOR.PATCH`:
+
+- **major**: a new evaluation key, e.g. changed scoring, data or matchmaker version
+- **minor**: new entries under the same key
+- **patch**: a fix to already published entries
+
+Every deployment serves the latest release at the root and every release at
+`versions//`, e.g.
+`https://pymatchmaker.github.io/matchmaker_benchmark/versions/v1.0.0/`, with a
+**Results version** menu on the page. Link a paper to its `versions//`
+address so readers see exactly the numbers it cites. Each version is shown with
+the current page code.
+
+Per-piece views take almost all of a version's space (about 25–30 MB, against
+under 1 MB for its tables), and GitHub Pages allows 1 GB. So only the newest
+releases (`NEWEST_FULL_VERSIONS`) and pinned ones (`PINNED_FULL_VERSIONS`, e.g.
+the release a paper cites) keep them, both in `matchmaker_eval/build_site.py`.
+Other versions show their tables, and their per-piece results stay in the
+release files.
+
### What the site can show
`results/leaderboard.json` is the index: one row per entry, small enough to load
diff --git a/matchmaker_eval/build_site.py b/matchmaker_eval/build_site.py
index b44acef..54b153e 100644
--- a/matchmaker_eval/build_site.py
+++ b/matchmaker_eval/build_site.py
@@ -2,12 +2,16 @@
python matchmaker_eval/build_site.py _site # what Pages publishes
python matchmaker_eval/build_site.py --serve # ...and open it locally
+ python matchmaker_eval/build_site.py _site --versions DIR # plus versions//
The site is ``docs/`` plus what the page reads and links to: the leaderboard
JSON and CSV, the same pair per dataset, and the per-entry detail files. Both
the publish workflow and the staging preview call this, so what you look at
before merging is assembled by the same code as what goes live.
+With ``--versions``, every published release is also assembled under
+``versions//`` (see docs/maintaining.md, "Older result versions").
+
The page also reads ``../results/`` when it is served from a checkout, so
``--serve`` from the repository root works without assembling anything; the
assembled form is what Pages uploads.
@@ -23,20 +27,31 @@
sys.path.insert(0, str(_path))
import argparse
+import json
import shutil
from matchmaker_eval.folds import REPO_ROOT, RESULTS_DIR
DOCS_DIR = REPO_ROOT / "docs"
+#: Releases that keep their per-piece views under versions/: the newest few,
+#: plus any pinned ones, such as the release our paper cites.
+NEWEST_FULL_VERSIONS = 3
+PINNED_FULL_VERSIONS = ("v1.0.0",)
+
class SiteError(Exception):
"""Raised when the site cannot be assembled."""
-def build(destination: Path) -> dict:
- """Copy docs/ and the result files into ``destination``. Returns a summary."""
+def build(destination: Path, results_dir: Path = None, details: bool = True) -> dict:
+ """Copy docs/ and the result files into ``destination``. Returns a summary.
+
+ ``details=False`` leaves out the per-piece views, which are almost all of
+ a version's size; the tables and archived keys are always included.
+ """
destination = Path(destination)
+ results_dir = Path(results_dir or RESULTS_DIR)
if destination.exists():
shutil.rmtree(destination)
if not DOCS_DIR.is_dir():
@@ -44,29 +59,29 @@ def build(destination: Path) -> dict:
shutil.copytree(DOCS_DIR, destination)
summary = {"boards": [], "details": 0, "archives": 0, "missing": []}
- for name in ("leaderboard.json", "leaderboard.csv"):
- source = RESULTS_DIR / name
+ for name in ("leaderboard.json", "leaderboard.csv", "release.json"):
+ source = results_dir / name
if source.exists():
shutil.copy2(source, destination / name)
else:
summary["missing"].append(name)
# leaderboard-.json/.csv: the page links to them for download.
- for source in sorted(RESULTS_DIR.glob("leaderboard-*.*")):
+ for source in sorted(results_dir.glob("leaderboard-*.*")):
if source.suffix in (".json", ".csv"):
shutil.copy2(source, destination / source.name)
summary["boards"].append(source.name)
- details = RESULTS_DIR / "details"
- if details.is_dir():
+ details_dir = results_dir / "details"
+ if details and details_dir.is_dir():
target = destination / "details"
target.mkdir(exist_ok=True)
- for path in sorted(details.glob("*.json")):
+ for path in sorted(details_dir.glob("*.json")):
shutil.copy2(path, target / path.name)
summary["details"] += 1
# Every leaderboard ever published under an evaluation key, so a key cited
# in a paper resolves to archive//leaderboard.json on the site.
- archive = RESULTS_DIR / "archive"
+ archive = results_dir / "archive"
if archive.is_dir():
shutil.copytree(archive, destination / "archive")
summary["archives"] = sum(1 for path in archive.iterdir() if path.is_dir())
@@ -79,6 +94,22 @@ def build(destination: Path) -> dict:
return summary
+def add_versions(destination: Path, versions_dir: Path) -> list:
+ """Assemble each release in ``versions_dir/versions.json`` under ``versions//``.
+
+ The newest ``NEWEST_FULL_VERSIONS`` and the ``PINNED_FULL_VERSIONS`` keep
+ their per-piece views; the others keep their tables only. The list is also written to ``versions.json``.
+ """
+ destination, versions_dir = Path(destination), Path(versions_dir)
+ listed = json.loads((versions_dir / "versions.json").read_text())["versions"]
+ for index, version in enumerate(listed):
+ version["full"] = index < NEWEST_FULL_VERSIONS or version["tag"] in PINNED_FULL_VERSIONS
+ build(destination / "versions" / version["tag"], versions_dir / version["tag"],
+ details=version["full"])
+ (destination / "versions.json").write_text(json.dumps({"versions": listed}, indent=2) + "\n")
+ return listed
+
+
def serve(directory: Path, port: int) -> None:
import functools
import http.server
@@ -115,10 +146,18 @@ def main():
help="serve the assembled site over HTTP and keep running",
)
parser.add_argument("--port", type=int, default=8000, help="port for --serve")
+ parser.add_argument(
+ "--versions",
+ type=Path,
+ default=None,
+ help="folder of downloaded releases (release_results.py --versions-dir); "
+ "each is added under versions//",
+ )
args = parser.parse_args()
try:
summary = build(Path(args.destination))
+ versions = add_versions(Path(args.destination), args.versions) if args.versions else []
except SiteError as e:
print(f"\n{e}", file=sys.stderr)
return 1
@@ -129,6 +168,10 @@ def main():
f"per-dataset file(s), {summary['details']} detail file(s), "
f"{summary['archives']} archived key(s)"
)
+ if args.versions:
+ print(f" {len(versions)} published version(s) under versions/: "
+ + (", ".join(v["tag"] + ("" if v["full"] else " (tables only)") for v in versions)
+ or "none"))
for name in summary["missing"]:
print(f" note: results/{name} was not there")
if args.serve:
diff --git a/matchmaker_eval/release_results.py b/matchmaker_eval/release_results.py
index 9860c30..5d45f98 100644
--- a/matchmaker_eval/release_results.py
+++ b/matchmaker_eval/release_results.py
@@ -8,6 +8,7 @@
import json
import os
from pathlib import Path
+import re
import shutil
import subprocess
import sys
@@ -19,6 +20,9 @@
SNAPSHOT = "benchmark-snapshot.zip"
+#: Result release tags, vMAJOR.MINOR.PATCH (see docs/maintaining.md).
+TAG = re.compile(r"v\d+\.\d+\.\d+")
+
def gh(*args):
return subprocess.check_output(["gh", *args], text=True).strip()
@@ -33,9 +37,16 @@ def releases(repo):
return [release for page in pages for release in page]
+def published(records):
+ """Published result releases with a website snapshot, newest first."""
+ candidates = [r for r in records if TAG.fullmatch(r["tag_name"])
+ and not r["draft"] and not r["prerelease"]
+ and any(a["name"] == SNAPSHOT for a in r["assets"])]
+ return sorted(candidates, key=lambda r: r["published_at"], reverse=True)
+
+
def latest(records):
- candidates = [r for r in records if r["tag_name"].startswith("benchmark-")]
- return max(candidates, key=lambda r: r["published_at"], default=None)
+ return next(iter(published(records)), None)
def extract(archive, destination):
@@ -78,6 +89,8 @@ def snapshot(results, output):
def publish(repo, tag, run_ids, records, destination):
+ if not TAG.fullmatch(tag):
+ raise ValueError(f"Release tag must look like v1.0.0, not {tag!r}")
runs = [api(f"repos/{repo}/actions/runs/{run}") for run in run_ids]
if any(run["conclusion"] != "success" for run in runs):
raise ValueError("Only successful runs can be published")
@@ -139,24 +152,49 @@ def publish(repo, tag, run_ids, records, destination):
return tag
+def fetch_versions(repo, records, destination):
+ """Download every published snapshot to ``destination//`` for the site.
+
+ ``versions.json`` lists them newest first, for the page's version menu.
+ """
+ destination = Path(destination)
+ destination.mkdir(parents=True, exist_ok=True)
+ versions = []
+ for release in published(records):
+ tag = release["tag_name"]
+ fetch(repo, release, destination / tag)
+ manifest = json.loads((destination / tag / "release.json").read_text())
+ versions.append({"tag": tag, "published_at": release["published_at"],
+ "url": release["html_url"],
+ "evaluation_keys": manifest.get("evaluation_keys", {})})
+ (destination / "versions.json").write_text(json.dumps({"versions": versions}, indent=2) + "\n")
+ return versions
+
+
def main():
parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
parser.add_argument("--repo", default=os.environ.get("GITHUB_REPOSITORY"))
parser.add_argument("--tag", default="")
parser.add_argument("--source-runs", default="", help="space-separated completed CI run IDs")
+ parser.add_argument("--versions-dir", type=Path, default=None,
+ help="also download every published release here, for the site's version menu")
args = parser.parse_args()
records = releases(args.repo)
if args.source_runs:
tag = publish(args.repo, args.tag, args.source_runs.split(), records, RESULTS_DIR)
else:
+ # Without new runs, redeploy the latest release; older ones stay at versions//.
if args.tag:
- release = next(r for r in records if r["tag_name"] == args.tag)
- else:
- release = latest(records)
+ parser.error("--tag needs --source-runs; an older release is served at versions//")
+ release = latest(records)
tag = release["tag_name"] if release else ""
if release:
fetch(args.repo, release, RESULTS_DIR)
+ if tag and args.versions_dir:
+ # Listed again: a release created just now is not in `records`.
+ versions = fetch_versions(args.repo, releases(args.repo), args.versions_dir)
+ print(f"Versions for the site: {', '.join(v['tag'] for v in versions)}")
if os.environ.get("GITHUB_OUTPUT"):
with open(os.environ["GITHUB_OUTPUT"], "a") as stream:
stream.write(f"ready={'true' if tag else 'false'}\ntag={tag}\n")
diff --git a/tests/test_workflows.py b/tests/test_workflows.py
index 6d276ac..41d20ef 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -149,6 +149,87 @@ def test_it_assembles_what_the_page_reads(self, tmp_path):
assert (site / "leaderboard.json").exists()
assert summary["details"] >= 0
+ @staticmethod
+ def _downloaded_versions(root, tags):
+ """Release snapshots as release_results.py --versions-dir leaves them."""
+ import json
+
+ for tag in tags:
+ (root / tag / "details").mkdir(parents=True)
+ (root / tag / "details" / "m-midi.json").write_text("{}")
+ (root / tag / "leaderboard.json").write_text(json.dumps({"tag": tag}))
+ (root / tag / "release.json").write_text(json.dumps({"tag": tag}))
+ (root / "versions.json").write_text(json.dumps({"versions": [
+ {"tag": tag, "published_at": "2026-12-01T00:00:00Z", "url": f"u/{tag}"}
+ for tag in tags]}))
+
+ def test_every_published_version_gets_its_own_path(self, tmp_path):
+ """A cited release stays viewable after newer results are published."""
+ import json
+ import build_site
+
+ self._downloaded_versions(tmp_path / "versions", ["v1.1.0", "v1.0.0"])
+ site = tmp_path / "site"
+ build_site.build(site)
+ listed = build_site.add_versions(site, tmp_path / "versions")
+
+ assert [v["tag"] for v in listed] == ["v1.1.0", "v1.0.0"]
+ assert json.loads((site / "versions.json").read_text())["versions"] == listed
+ for tag in ("v1.1.0", "v1.0.0"):
+ assert (site / "versions" / tag / "index.html").exists()
+ assert json.loads((site / "versions" / tag / "leaderboard.json").read_text()) == {"tag": tag}
+ assert (site / "leaderboard.json").exists() # the root keeps the current results
+
+ def test_only_the_newest_and_pinned_versions_keep_per_piece_views(self, tmp_path, monkeypatch):
+ """Older versions shrink to their tables, keeping the site under the Pages
+ limit, while a pinned version (e.g. the one a paper cites) stays complete."""
+ import build_site
+
+ monkeypatch.setattr(build_site, "NEWEST_FULL_VERSIONS", 2)
+ monkeypatch.setattr(build_site, "PINNED_FULL_VERSIONS", ("v1.0.0",))
+ tags = ["v3.0.0", "v2.1.0", "v2.0.0", "v1.0.0"] # newest first
+ self._downloaded_versions(tmp_path / "versions", tags)
+ site = tmp_path / "site"
+ build_site.build(site)
+ listed = build_site.add_versions(site, tmp_path / "versions")
+
+ assert [v["full"] for v in listed] == [True, True, False, True]
+ for version in listed:
+ folder = site / "versions" / version["tag"]
+ assert (folder / "details" / "m-midi.json").exists() is version["full"]
+ assert (folder / "leaderboard.json").exists()
+
+ def test_release_versions_are_filtered_and_newest_first(self, tmp_path, monkeypatch):
+ import json
+ from matchmaker_eval import release_results as R
+
+ def release(tag, published, draft=False, snapshot=True):
+ return {"tag_name": tag, "published_at": published, "draft": draft,
+ "prerelease": False, "html_url": f"https://example/{tag}",
+ "assets": [{"name": R.SNAPSHOT}] if snapshot else []}
+
+ records = [
+ release("v1.0.0", "2026-11-20T00:00:00Z"),
+ release("v1.1.0", "2026-12-01T00:00:00Z"),
+ release("v1.2.0", "2026-12-05T00:00:00Z", draft=True),
+ release("v1.3.0", "2026-12-06T00:00:00Z", snapshot=False),
+ release("benchmark-v9", "2026-12-07T00:00:00Z"),
+ ]
+ fetched = []
+
+ def fake_fetch(repo, rel, destination):
+ fetched.append(rel["tag_name"])
+ destination.mkdir(parents=True)
+ (destination / "release.json").write_text(json.dumps({"evaluation_keys": {}}))
+
+ monkeypatch.setattr(R, "fetch", fake_fetch)
+ versions = R.fetch_versions("owner/repo", records, tmp_path / "versions")
+
+ assert fetched == ["v1.1.0", "v1.0.0"]
+ assert [v["tag"] for v in versions] == ["v1.1.0", "v1.0.0"]
+ assert versions[0]["url"] == "https://example/v1.1.0"
+ assert R.latest(records)["tag_name"] == "v1.1.0"
+
def test_it_refuses_to_build_without_a_leaderboard(self, tmp_path, monkeypatch):
import build_site
@@ -418,4 +499,4 @@ def test_unfinished_or_failed_run_is_not_published(self, tmp_path, monkeypatch,
from matchmaker_eval import release_results
monkeypatch.setattr(release_results, "api", lambda path: {"status": status, "conclusion": conclusion})
with pytest.raises(ValueError, match="successful runs"):
- release_results.publish("test/repo", "benchmark-test", ["1"], [], tmp_path)
+ release_results.publish("test/repo", "v1.0.0", ["1"], [], tmp_path)