Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Selected completed runs are preserved in a release before deployment.
# Documentation-only rebuilds reuse the last published result snapshot.
# Every published release is also served under v/<tag>/ (version menu).
name: Publish leaderboard

on:
Expand All @@ -10,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:
Expand Down Expand Up @@ -65,11 +67,17 @@ jobs:
SOURCE_RUNS: ${{ inputs.source_runs }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
python matchmaker_eval/release_results.py --source-runs "$SOURCE_RUNS" --tag "$RELEASE_TAG"
python matchmaker_eval/release_results.py --source-runs "$SOURCE_RUNS" --tag "$RELEASE_TAG" \
--versions-dir "$RUNNER_TEMP/benchmark-versions"

- name: Assemble the site
if: steps.results.outputs.ready == 'true'
run: python matchmaker_eval/build_site.py _site
# Every published release is also kept under v/<tag>/, so a cited
# version stays viewable after newer results are published.
# 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'
Expand Down
18 changes: 18 additions & 0 deletions data/full_versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Which published result versions the website shows in full.
#
# Every published `benchmark-*` release stays on the website under v/<tag>/
# 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
87 changes: 86 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@
color: var(--ink-soft);
}

/* ── Result versions ──────────────────────────────────────────────────── */
.versions {
display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
font-size: 13px; color: var(--ink-soft);
}
.versions select {
font-family: var(--ui); font-size: 13px; color: var(--ink);
background: var(--surface); border: 1px solid var(--rule-firm);
border-radius: 2px; padding: 5px 9px; max-width: 100%;
}
.versions a { color: var(--ink-soft); text-underline-offset: 2px; }
.version-note {
border-left: 3px solid var(--warn); background: var(--surface);
padding: 8px 12px; font-size: 13px; color: var(--ink-soft);
}
.version-note b { color: var(--ink); font-weight: 500; }
.version-note a { color: var(--ink); text-underline-offset: 2px; }

/* ── Controls ─────────────────────────────────────────────────────────── */
.controls {
display: flex;
Expand Down Expand Up @@ -540,6 +558,12 @@ <h1>Matchmaker Benchmark</h1>
</p>
<div class="staff" role="presentation"></div>
<div class="provenance" id="provenance"></div>
<div class="versions" id="versions" hidden>
<label for="version-select">Results version</label>
<select id="version-select"></select>
<a id="version-release" href="#">release files</a>
</div>
<p class="version-note" id="version-note" hidden></p>
</header>

<div class="controls">
Expand Down Expand Up @@ -1130,7 +1154,10 @@ <h2>Submitting</h2>
container.innerHTML = '<p class="plot-hint">Loading the full record…</p>';
const detail = await loadDetail(entry);
if (!detail) {
container.innerHTML = '<p class="plot-hint">Per-piece results are not published for this entry.</p>';
container.innerHTML = tablesOnly
? `<p class="plot-hint">This older version is shown with its tables only. Per-piece results
are in its <a href="${escapeHtml(tablesOnly)}">release files</a>.</p>`
: '<p class="plot-hint">Per-piece results are not published for this entry.</p>';
return;
}

Expand Down Expand Up @@ -1488,6 +1515,64 @@ <h2>Submitting</h2>
return null;
}

// Published result versions. Pages serves the latest release at the root and
// every release under v/<tag>/ (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; }
}

// 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"),
]);
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) => `<option value="${escapeHtml(v.tag)}"
${v.tag === shown ? "selected" : ""}>${escapeHtml(v.tag)}${date(v) ? " · " + escapeHtml(date(v)) : ""}${v.tag === newest ? " (latest)" : ""}</option>`).join("");
select.addEventListener("change", () => {
// The newest version lives at the root; every version, newest included,
// also has a permanent address under v/<tag>/.
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)}`;
// 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 <b>${escapeHtml(shown)}</b>${current && date(current) ? `, published ${escapeHtml(date(current))}` : ""}.
Newer results exist: <a href="${SITE_ROOT}">see the latest version (${escapeHtml(newest)})</a>.${
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;
note.innerHTML = `To cite these exact numbers, link this version: <a href="${escapeHtml(permanent)}">${escapeHtml(permanent)}</a>`;
note.hidden = false;
note.style.borderLeftColor = "var(--accent)";
}
}
showVersions();

loadBoard().then((board) => {
if (!board) {
const empty = el("empty");
Expand Down
17 changes: 17 additions & 0 deletions docs/maintaining.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<tag>/` (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/<tag>/` 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
Expand Down
99 changes: 91 additions & 8 deletions matchmaker_eval/build_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@

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/<tag>/

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/<tag>/``, 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.

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.
Expand All @@ -23,20 +32,32 @@
sys.path.insert(0, str(_path))

import argparse
import json
import re
import shutil

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):
"""Raised when the site cannot be assembled."""


def build(destination: Path) -> dict:
"""Copy docs/ and the result files into ``destination``. Returns a summary."""
#: 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, 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():
Expand All @@ -45,28 +66,28 @@ 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-<dataset>.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/<key>/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())
Expand All @@ -79,6 +100,56 @@ def build(destination: Path) -> dict:
return summary


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/<tag>/``.

``versions_dir/versions.json`` (newest first) decides what is listed; a
release whose snapshot is missing is left out rather than linked broken.
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.")
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
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")},
"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


def serve(directory: Path, port: int) -> None:
import functools
import http.server
Expand Down Expand Up @@ -115,10 +186,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/<tag>/",
)
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
Expand All @@ -129,6 +208,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 v/: "
+ (", ".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:
Expand Down
Loading
Loading