return null;
}
+// Published result versions. Pages serves the latest release at the root and
+// every release under v// (build_site.py --versions); versions.json at
+// the root lists them, newest first. Without it (a local checkout) the menu
+// stays hidden.
+const VERSION_PATH = location.pathname.match(/\/v\/(benchmark-[A-Za-z0-9][A-Za-z0-9._-]*)\/(?:index\.html)?$/);
+const SITE_ROOT = VERSION_PATH ? "../../" : "./";
+
+async function fetchJson(url) {
+ try {
+ const response = await fetch(url);
+ return response.ok ? await response.json() : null;
+ } catch (error) { return null; }
+}
+
+async function showVersions() {
+ const [index, release] = await Promise.all([
+ fetchJson(SITE_ROOT + "versions.json"), fetchJson("./release.json"),
+ ]);
+ const versions = (index && index.versions) || [];
+ const shown = release && release.tag;
+ if (!shown || !versions.length) return;
+ if (!versions.some((v) => v.tag === shown)) versions.unshift({ tag: shown });
+ const newest = versions[0].tag;
+ const date = (v) => (v.published_at || "").slice(0, 10);
+ const select = el("version-select");
+ select.innerHTML = versions.map((v) => ``).join("");
+ select.addEventListener("change", () => {
+ // The newest version lives at the root; every version, newest included,
+ // also has a permanent address under v//.
+ location.href = SITE_ROOT + (select.value === newest ? "" : `v/${encodeURIComponent(select.value)}/`);
+ });
+ const current = versions.find((v) => v.tag === shown);
+ const link = el("version-release");
+ link.href = (current && current.url)
+ || `https://github.com/pymatchmaker/matchmaker_benchmark/releases/tag/${encodeURIComponent(shown)}`;
+ el("versions").hidden = false;
+
+ const note = el("version-note");
+ if (shown !== newest) {
+ note.innerHTML = `You are viewing ${escapeHtml(shown)}${current && date(current) ? `, published ${escapeHtml(date(current))}` : ""}.
+ Newer results exist: see the latest version (${escapeHtml(newest)}).`;
+ note.hidden = false;
+ } else {
+ const permanent = new URL(`v/${encodeURIComponent(shown)}/`, new URL(SITE_ROOT, location.href)).href;
+ note.innerHTML = `To cite these exact numbers, link this version: ${escapeHtml(permanent)}`;
+ note.hidden = false;
+ note.style.borderLeftColor = "var(--accent)";
+ }
+}
+showVersions();
+
loadBoard().then((board) => {
if (!board) {
const empty = el("empty");
diff --git a/docs/maintaining.md b/docs/maintaining.md
index 949a1ee..74c7817 100644
--- a/docs/maintaining.md
+++ b/docs/maintaining.md
@@ -485,6 +485,23 @@ and deploys it to GitHub Pages. A documentation update reuses the latest publish
snapshot. `MATCHMAKER_RESULTS_DIR` points the export and site-building scripts
at a temporary directory outside the code checkout.
+### Older result versions
+
+Every deployment also includes all published releases under their own path,
+`v//` (for example
+`https://pymatchmaker.github.io/matchmaker_benchmark/v/benchmark-v1/`), and the
+page shows a **Results version** menu. The root always shows the latest release;
+older versions show a note that newer results exist. Link a paper to its
+`v//` address so readers see exactly the cited numbers. 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 in total. So only the
+newest versions and those listed in `data/full_versions.yaml` keep them; all
+other versions show their tables, with the per-piece results in their release
+files. **Add every version a paper cites to `keep`** in that file. A listed tag
+that is not published yet only produces a warning in the publish run.
+
### 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 6f56779..861f7bf 100644
--- a/matchmaker_eval/build_site.py
+++ b/matchmaker_eval/build_site.py
@@ -2,12 +2,19 @@
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 v//
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 result release found in DIR (as written
+by ``release_results.py --versions-dir``) is also assembled under
+``v//``, and ``versions.json`` lists them for the page's version menu.
+Each version uses the current page with that release's data, so a link such
+as ``v/benchmark-v1/`` keeps showing the numbers a paper cites.
+
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,6 +30,8 @@
sys.path.insert(0, str(_path))
import argparse
+import json
+import re
import shutil
from matchmaker_eval.load_folds import REPO_ROOT, RESULTS_DIR
@@ -34,9 +43,14 @@ class SiteError(Exception):
"""Raised when the site cannot be assembled."""
-def build(destination: Path) -> dict:
+#: A published result tag, as release_results.py creates them.
+VERSION_TAG = re.compile(r"benchmark-[A-Za-z0-9][A-Za-z0-9._-]*")
+
+
+def build(destination: Path, results_dir: Path = None) -> dict:
"""Copy docs/ and the result files into ``destination``. Returns a summary."""
destination = Path(destination)
+ results_dir = Path(results_dir or RESULTS_DIR)
if destination.exists():
shutil.rmtree(destination)
if not DOCS_DIR.is_dir():
@@ -45,18 +59,18 @@ def build(destination: Path) -> dict:
summary = {"boards": [], "details": 0, "archives": 0, "missing": []}
for name in ("leaderboard.json", "leaderboard.csv", "release.json"):
- source = RESULTS_DIR / name
+ 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"
+ details = results_dir / "details"
if details.is_dir():
target = destination / "details"
target.mkdir(exist_ok=True)
@@ -66,7 +80,7 @@ def build(destination: Path) -> dict:
# 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 +93,31 @@ def build(destination: Path) -> dict:
return summary
+def add_versions(destination: Path, versions_dir: Path) -> list:
+ """Assemble every downloaded release under ``destination/v//``.
+
+ ``versions_dir/versions.json`` (newest first) decides what is listed; a
+ release whose snapshot is missing is left out rather than linked broken.
+ Returns the listed versions, also written to ``destination/versions.json``.
+ """
+ destination, versions_dir = Path(destination), Path(versions_dir)
+ index = versions_dir / "versions.json"
+ if not index.is_file():
+ raise SiteError(f"{index} is missing — run release_results.py --versions-dir first.")
+ listed = []
+ for version in json.loads(index.read_text()).get("versions", []):
+ tag = version.get("tag", "")
+ if not VERSION_TAG.fullmatch(tag) or not (versions_dir / tag / "leaderboard.json").is_file():
+ continue
+ summary = build(destination / "v" / tag, versions_dir / tag)
+ if "release.json" in summary["missing"]:
+ raise SiteError(f"release {tag} has no release.json")
+ listed.append({key: version.get(key) for key in ("tag", "published_at", "url", "evaluation_keys")})
+ (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 +154,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 v//",
+ )
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 +176,9 @@ 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 v/: "
+ + (", ".join(v["tag"] 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 bbb01c1..214f242 100644
--- a/matchmaker_eval/release_results.py
+++ b/matchmaker_eval/release_results.py
@@ -35,11 +35,16 @@ def releases(repo):
return [release for page in pages for release in page]
-def latest(records):
+def published(records):
+ """Published result releases with a website snapshot, newest first."""
candidates = [r for r in records if r["tag_name"].startswith("benchmark-")
and not r["draft"] and not r["prerelease"]
and any(a["name"] == SNAPSHOT for a in r["assets"])]
- return max(candidates, key=lambda r: r["published_at"], default=None)
+ return sorted(candidates, key=lambda r: r["published_at"], reverse=True)
+
+
+def latest(records):
+ return next(iter(published(records)), None)
def extract(archive, destination):
@@ -211,11 +216,35 @@ 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. Each snapshot is checked
+ against the release's SHA256SUMS, exactly as when it is deployed alone.
+ """
+ destination = Path(destination)
+ destination.mkdir(parents=True, exist_ok=True)
+ versions = []
+ for release in published(records):
+ tag = release["tag_name"]
+ if not re.fullmatch(r"benchmark-[A-Za-z0-9][A-Za-z0-9._-]*", tag):
+ continue
+ 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()
if not args.repo or not re.fullmatch(r"[\w.-]+/[\w.-]+", args.repo):
parser.error("Set GITHUB_REPOSITORY or --repo owner/repository")
@@ -232,6 +261,10 @@ def main():
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 dea0dff..20ed608 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -137,6 +137,83 @@ def test_it_assembles_what_the_page_reads(self, tmp_path):
assert (site / "leaderboard.json").exists()
assert summary["details"] >= 0
+ 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
+
+ versions = tmp_path / "versions"
+ for tag, generated in (("benchmark-v2", "new"), ("benchmark-v1", "old")):
+ (versions / tag / "details").mkdir(parents=True)
+ (versions / tag / "leaderboard.json").write_text(json.dumps({"generated": generated}))
+ (versions / tag / "release.json").write_text(json.dumps({"tag": tag}))
+ (versions / "benchmark-v0").mkdir() # listed, but its snapshot is missing
+ (versions / "versions.json").write_text(json.dumps({"versions": [
+ {"tag": "benchmark-v2", "published_at": "2026-12-01T00:00:00Z", "url": "u2"},
+ {"tag": "benchmark-v1", "published_at": "2026-11-20T00:00:00Z", "url": "u1"},
+ {"tag": "benchmark-v0"},
+ {"tag": "../escape"},
+ ]}))
+ site = tmp_path / "site"
+ build_site.build(site)
+ listed = build_site.add_versions(site, versions)
+
+ assert [v["tag"] for v in listed] == ["benchmark-v2", "benchmark-v1"]
+ assert json.loads((site / "versions.json").read_text())["versions"] == listed
+ for tag, generated in (("benchmark-v2", "new"), ("benchmark-v1", "old")):
+ assert (site / "v" / tag / "index.html").exists()
+ assert json.loads((site / "v" / tag / "leaderboard.json").read_text()) == {"generated": generated}
+ assert not (site / "v" / "benchmark-v0").exists()
+ # The root site is left as built from the current results.
+ assert (site / "leaderboard.json").exists()
+
+ def test_versions_need_the_downloaded_index(self, tmp_path):
+ import build_site
+
+ build_site.build(tmp_path / "site")
+ with pytest.raises(build_site.SiteError, match="versions.json is missing"):
+ build_site.add_versions(tmp_path / "site", tmp_path / "nothing")
+
+ def test_release_versions_are_downloaded_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("benchmark-v1", "2026-11-20T00:00:00Z"),
+ release("benchmark-v2", "2026-12-01T00:00:00Z"),
+ release("benchmark-v3", "2026-12-05T00:00:00Z", draft=True),
+ release("benchmark-v4", "2026-12-06T00:00:00Z", snapshot=False),
+ release("v0.4.0", "2026-10-27T00: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": {"midi": "ek2-" + rel["tag_name"][-2:]}}))
+
+ monkeypatch.setattr(R, "fetch", fake_fetch)
+ versions = R.fetch_versions("owner/repo", records, tmp_path / "versions")
+
+ assert fetched == ["benchmark-v2", "benchmark-v1"]
+ assert [v["tag"] for v in versions] == ["benchmark-v2", "benchmark-v1"]
+ assert versions[0]["url"] == "https://example/benchmark-v2"
+ assert versions[0]["evaluation_keys"] == {"midi": "ek2-v2"}
+ on_disk = json.loads((tmp_path / "versions" / "versions.json").read_text())
+ assert on_disk["versions"] == versions
+ assert R.latest(records)["tag_name"] == "benchmark-v2"
+
+ def test_the_publish_workflow_builds_the_version_paths(self):
+ pages = (WORKFLOWS / "pages.yml").read_text()
+ assert '--versions-dir "$RUNNER_TEMP/benchmark-versions"' in pages
+ assert 'build_site.py _site --versions "$RUNNER_TEMP/benchmark-versions"' in pages
+
def test_it_refuses_to_build_without_a_leaderboard(self, tmp_path, monkeypatch):
import build_site
From 1d0690e998ce5c087a7c8731599a0e1ed984cbe2 Mon Sep 17 00:00:00 2001
From: darth-alexus
Date: Fri, 13 Nov 2026 13:15:53 +0100
Subject: [PATCH 2/2] Show only the newest and cited result versions in full on
the site
---
.github/workflows/pages.yml | 6 +++-
data/full_versions.yaml | 18 ++++++++++++
docs/index.html | 13 +++++++--
matchmaker_eval/build_site.py | 53 ++++++++++++++++++++++++++++-------
tests/test_workflows.py | 51 ++++++++++++++++++++++++++++++++-
5 files changed, 127 insertions(+), 14 deletions(-)
create mode 100644 data/full_versions.yaml
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index b73efd9..c31b1ff 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -11,6 +11,7 @@ on:
paths:
- "docs/**"
- "matchmaker_eval/build_site.py"
+ - "data/full_versions.yaml"
- "matchmaker_eval/release_results.py"
- ".github/workflows/pages.yml"
workflow_dispatch:
@@ -73,7 +74,10 @@ jobs:
if: steps.results.outputs.ready == 'true'
# Every published release is also kept under v//, so a cited
# version stays viewable after newer results are published.
- run: python matchmaker_eval/build_site.py _site --versions "$RUNNER_TEMP/benchmark-versions"
+ # data/full_versions.yaml decides which keep their per-piece views.
+ run: |
+ pip install --quiet pyyaml
+ python matchmaker_eval/build_site.py _site --versions "$RUNNER_TEMP/benchmark-versions"
- uses: actions/configure-pages@v5
if: steps.results.outputs.ready == 'true'
diff --git a/data/full_versions.yaml b/data/full_versions.yaml
new file mode 100644
index 0000000..2f9f0ac
--- /dev/null
+++ b/data/full_versions.yaml
@@ -0,0 +1,18 @@
+# Which published result versions the website shows in full.
+#
+# Every published `benchmark-*` release stays on the website under v//
+# and in the "Results version" menu. Versions listed here (and the newest
+# ones) also keep their per-piece views and plots, about 25-30 MB each. All
+# other versions show their tables only (under 1 MB); their per-piece results
+# stay downloadable from the release files on GitHub.
+#
+# GitHub Pages allows 1 GB per site, so keep this list short.
+
+# How many of the newest releases to show in full.
+newest: 3
+
+# Versions that are always shown in full, whatever their age. Add every
+# version a paper cites, e.g. the release made for the TISMIR submission.
+# A tag listed here that has not been published yet only causes a warning.
+keep:
+ - benchmark-v1 # TODO: the paper's version; confirm the tag once the final rerun is released
diff --git a/docs/index.html b/docs/index.html
index 803e498..5044caf 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1154,7 +1154,10 @@
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;
}
@@ -1526,6 +1529,9 @@
Submitting
} catch (error) { return null; }
}
+// Set to this version's release URL when the site has its tables only.
+let tablesOnly = null;
+
async function showVersions() {
const [index, release] = await Promise.all([
fetchJson(SITE_ROOT + "versions.json"), fetchJson("./release.json"),
@@ -1548,12 +1554,15 @@
Submitting
const link = el("version-release");
link.href = (current && current.url)
|| `https://github.com/pymatchmaker/matchmaker_benchmark/releases/tag/${encodeURIComponent(shown)}`;
+ // Older versions may be published with their tables only (full_versions.yaml).
+ if (VERSION_PATH && current && current.full === false) tablesOnly = link.href;
el("versions").hidden = false;
const note = el("version-note");
if (shown !== newest) {
note.innerHTML = `You are viewing ${escapeHtml(shown)}${current && date(current) ? `, published ${escapeHtml(date(current))}` : ""}.
- Newer results exist: see the latest version (${escapeHtml(newest)}).`;
+ Newer results exist: see the latest version (${escapeHtml(newest)}).${
+ tablesOnly ? " Per-piece plots for this version are in its release files." : ""}`;
note.hidden = false;
} else {
const permanent = new URL(`v/${encodeURIComponent(shown)}/`, new URL(SITE_ROOT, location.href)).href;
diff --git a/matchmaker_eval/build_site.py b/matchmaker_eval/build_site.py
index 861f7bf..53fb9c4 100644
--- a/matchmaker_eval/build_site.py
+++ b/matchmaker_eval/build_site.py
@@ -12,6 +12,8 @@
With ``--versions``, every published result release found in DIR (as written
by ``release_results.py --versions-dir``) is also assembled under
``v//``, and ``versions.json`` lists them for the page's version menu.
+``data/full_versions.yaml`` decides which versions keep their per-piece views
+(the newest few and any cited version); the others show their tables only.
Each version uses the current page with that release's data, so a link such
as ``v/benchmark-v1/`` keeps showing the numbers a paper cites.
@@ -37,6 +39,7 @@
from matchmaker_eval.load_folds import REPO_ROOT, RESULTS_DIR
DOCS_DIR = REPO_ROOT / "docs"
+FULL_VERSIONS = REPO_ROOT / "data" / "full_versions.yaml"
class SiteError(Exception):
@@ -47,8 +50,12 @@ class SiteError(Exception):
VERSION_TAG = re.compile(r"benchmark-[A-Za-z0-9][A-Za-z0-9._-]*")
-def build(destination: Path, results_dir: Path = None) -> 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():
@@ -70,11 +77,11 @@ def build(destination: Path, results_dir: Path = None) -> dict:
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
@@ -93,14 +100,33 @@ def build(destination: Path, results_dir: Path = None) -> dict:
return summary
-def add_versions(destination: Path, versions_dir: Path) -> list:
+def full_version_rule(path: Path = None) -> dict:
+ """Read data/full_versions.yaml: how many newest versions, and which tags,
+ keep their per-piece views on the site."""
+ import yaml
+
+ path = Path(path or FULL_VERSIONS)
+ config = (yaml.safe_load(path.read_text()) if path.is_file() else None) or {}
+ newest = config.get("newest", 3)
+ keep = config.get("keep") or []
+ if not isinstance(newest, int) or newest < 1:
+ raise SiteError(f"{path}: 'newest' must be a positive whole number")
+ if not isinstance(keep, list) or not all(isinstance(t, str) for t in keep):
+ raise SiteError(f"{path}: 'keep' must be a list of release tags")
+ return {"newest": newest, "keep": keep}
+
+
+def add_versions(destination: Path, versions_dir: Path, rule: dict = None) -> list:
"""Assemble every downloaded release under ``destination/v//``.
``versions_dir/versions.json`` (newest first) decides what is listed; a
release whose snapshot is missing is left out rather than linked broken.
- Returns the listed versions, also written to ``destination/versions.json``.
+ The newest versions and those kept by name (``full_version_rule``) are
+ assembled in full, the rest without per-piece views. Returns the listed
+ versions, also written to ``destination/versions.json``.
"""
destination, versions_dir = Path(destination), Path(versions_dir)
+ rule = rule or full_version_rule()
index = versions_dir / "versions.json"
if not index.is_file():
raise SiteError(f"{index} is missing — run release_results.py --versions-dir first.")
@@ -109,10 +135,16 @@ def add_versions(destination: Path, versions_dir: Path) -> list:
tag = version.get("tag", "")
if not VERSION_TAG.fullmatch(tag) or not (versions_dir / tag / "leaderboard.json").is_file():
continue
- summary = build(destination / "v" / tag, versions_dir / tag)
+ full = len(listed) < rule["newest"] or tag in rule["keep"]
+ summary = build(destination / "v" / tag, versions_dir / tag, details=full)
if "release.json" in summary["missing"]:
raise SiteError(f"release {tag} has no release.json")
- listed.append({key: version.get(key) for key in ("tag", "published_at", "url", "evaluation_keys")})
+ listed.append({**{key: version.get(key) for key in ("tag", "published_at", "url", "evaluation_keys")},
+ "full": full})
+ missing = [tag for tag in rule["keep"] if tag not in {v["tag"] for v in listed}]
+ for tag in missing:
+ # Expected until that version is published (e.g. the paper's release).
+ print(f"::warning::{tag} is kept in full by data/full_versions.yaml but is not published yet")
(destination / "versions.json").write_text(
json.dumps({"versions": listed}, indent=2) + "\n")
return listed
@@ -178,7 +210,8 @@ def main():
)
if args.versions:
print(f" {len(versions)} published version(s) under v/: "
- + (", ".join(v["tag"] for v in versions) or "none"))
+ + (", ".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/tests/test_workflows.py b/tests/test_workflows.py
index 20ed608..308fd22 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -156,9 +156,10 @@ def test_every_published_version_gets_its_own_path(self, tmp_path):
]}))
site = tmp_path / "site"
build_site.build(site)
- listed = build_site.add_versions(site, versions)
+ listed = build_site.add_versions(site, versions, {"newest": 3, "keep": []})
assert [v["tag"] for v in listed] == ["benchmark-v2", "benchmark-v1"]
+ assert all(v["full"] for v in listed)
assert json.loads((site / "versions.json").read_text())["versions"] == listed
for tag, generated in (("benchmark-v2", "new"), ("benchmark-v1", "old")):
assert (site / "v" / tag / "index.html").exists()
@@ -167,6 +168,53 @@ def test_every_published_version_gets_its_own_path(self, tmp_path):
# The root site is left as built from the current results.
assert (site / "leaderboard.json").exists()
+ def test_only_the_newest_and_kept_versions_keep_per_piece_views(self, tmp_path, capsys):
+ """Older versions shrink to their tables, so the site stays under the
+ Pages size limit, while a version a paper cites is never trimmed."""
+ import json
+ import build_site
+
+ versions = tmp_path / "versions"
+ tags = [f"benchmark-v{n}" for n in (5, 4, 3, 2, 1)] # newest first
+ for tag in tags:
+ (versions / tag / "details").mkdir(parents=True)
+ (versions / tag / "details" / "m-midi.json").write_text("{}")
+ (versions / tag / "leaderboard.json").write_text("{}")
+ (versions / tag / "release.json").write_text(json.dumps({"tag": tag}))
+ (versions / "versions.json").write_text(json.dumps(
+ {"versions": [{"tag": tag} for tag in tags]}))
+ site = tmp_path / "site"
+ build_site.build(site)
+ rule = {"newest": 2, "keep": ["benchmark-v1", "benchmark-v9"]}
+ listed = build_site.add_versions(site, versions, rule)
+
+ full = {v["tag"]: v["full"] for v in listed}
+ assert full == {"benchmark-v5": True, "benchmark-v4": True, "benchmark-v3": False,
+ "benchmark-v2": False, "benchmark-v1": True}
+ for tag, kept in full.items():
+ assert (site / "v" / tag / "details" / "m-midi.json").exists() is kept
+ assert (site / "v" / tag / "leaderboard.json").exists()
+ # A kept tag that is not published yet is a reminder, not an error.
+ assert "benchmark-v9 is kept in full" in capsys.readouterr().out
+
+ def test_the_committed_full_version_rule_is_valid(self):
+ import build_site
+
+ rule = build_site.full_version_rule()
+ assert rule["newest"] >= 1
+ assert all(build_site.VERSION_TAG.fullmatch(tag) for tag in rule["keep"])
+
+ def test_a_malformed_full_version_rule_is_refused(self, tmp_path):
+ import build_site
+
+ path = tmp_path / "full_versions.yaml"
+ path.write_text("newest: 0\n")
+ with pytest.raises(build_site.SiteError, match="newest"):
+ build_site.full_version_rule(path)
+ path.write_text("keep: benchmark-v1\n")
+ with pytest.raises(build_site.SiteError, match="keep"):
+ build_site.full_version_rule(path)
+
def test_versions_need_the_downloaded_index(self, tmp_path):
import build_site
@@ -213,6 +261,7 @@ def test_the_publish_workflow_builds_the_version_paths(self):
pages = (WORKFLOWS / "pages.yml").read_text()
assert '--versions-dir "$RUNNER_TEMP/benchmark-versions"' in pages
assert 'build_site.py _site --versions "$RUNNER_TEMP/benchmark-versions"' in pages
+ assert "data/full_versions.yaml" in pages # editing the rule redeploys
def test_it_refuses_to_build_without_a_leaderboard(self, tmp_path, monkeypatch):
import build_site