Datasets:
File size: 6,616 Bytes
2f49b29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | #!/usr/bin/env python3
"""Build or verify the curated public manifest for a POSA Bench preview."""
from __future__ import annotations
import argparse
import hashlib
import json
from datetime import date
from pathlib import Path
HERE = Path(__file__).resolve().parent
BENCHMARK = HERE.parent
DEFAULT_RELEASE = "preview-v0.1.0"
# Source paths are relative to benchmark/. Targets are paths in the HF dataset.
# Internal briefs, end-to-end runs, and smoke runs are deliberately absent.
PUBLIC_FILES = [
("../LICENSE", "LICENSE"),
("README.md", "benchmark/README.md"),
("METHODOLOGY.md", "METHODOLOGY.md"),
("SUBMISSIONS.md", "SUBMISSIONS.md"),
("posa_bench.py", "code/posa_bench.py"),
("tests/test_benchmark.py", "code/tests/test_benchmark.py"),
("scripts/release_status.py", "code/release_status.py"),
("review/HUMAN-REVIEW-PROTOCOL.md", "review/HUMAN-REVIEW-PROTOCOL.md"),
("huggingface/public_bundle.py", "code/public_bundle.py"),
("huggingface/space/README.md", "code/space/README.md"),
("huggingface/space/index.html", "code/space/index.html"),
("huggingface/space/preview_leaderboard.csv", "leaderboard/preview_leaderboard.csv"),
("data/questions.v1.jsonl", "questions.v1.jsonl"),
("data/device-profiles.v1.json", "device-profiles.v1.json"),
("data/models.v1.json", "models.v1.json"),
("review/manual-audit-2026-08-26.json", "review/manual-audit-2026-08-26.json"),
(
"review/results/2026-08-26-pixel7-liquid-llamacpp-r1.reviewed.json",
"review/results/2026-08-26-pixel7-liquid-llamacpp-r1.reviewed.json",
),
(
"review/results/2026-08-26-pixel7-qwen3-0.6b-llamacpp-r1.reviewed.json",
"review/results/2026-08-26-pixel7-qwen3-0.6b-llamacpp-r1.reviewed.json",
),
(
"review/results/2026-08-26-pixel7-smollm2-1.7b-llamacpp-r1.reviewed.json",
"review/results/2026-08-26-pixel7-smollm2-1.7b-llamacpp-r1.reviewed.json",
),
(
"review/results/2026-08-26-pixel7-llama3.2-1b-llamacpp-r1.reviewed.json",
"review/results/2026-08-26-pixel7-llama3.2-1b-llamacpp-r1.reviewed.json",
),
(
"results/2026-08-26-pixel7-liquid-llamacpp-r1.json",
"results/2026-08-26-pixel7-liquid-llamacpp-r1.json",
),
(
"results/2026-08-26-pixel7-qwen3-0.6b-llamacpp-r1.json",
"results/2026-08-26-pixel7-qwen3-0.6b-llamacpp-r1.json",
),
(
"results/2026-08-26-pixel7-smollm2-1.7b-llamacpp-r1.json",
"results/2026-08-26-pixel7-smollm2-1.7b-llamacpp-r1.json",
),
(
"results/2026-08-26-pixel7-llama3.2-1b-llamacpp-r1.json",
"results/2026-08-26-pixel7-llama3.2-1b-llamacpp-r1.json",
),
("raw/pixel7-liquid-llamacpp-r1/metadata.json", "raw/pixel7-liquid-llamacpp-r1/metadata.json"),
("raw/pixel7-liquid-llamacpp-r1/responses.jsonl", "raw/pixel7-liquid-llamacpp-r1/responses.jsonl"),
("raw/pixel7-qwen3-0.6b-llamacpp-r1/metadata.json", "raw/pixel7-qwen3-0.6b-llamacpp-r1/metadata.json"),
("raw/pixel7-qwen3-0.6b-llamacpp-r1/responses.jsonl", "raw/pixel7-qwen3-0.6b-llamacpp-r1/responses.jsonl"),
(
"raw/pixel7-smollm2-1.7b-llamacpp-r1/metadata.json",
"raw/pixel7-smollm2-1.7b-llamacpp-r1/metadata.json",
),
(
"raw/pixel7-smollm2-1.7b-llamacpp-r1/responses.jsonl",
"raw/pixel7-smollm2-1.7b-llamacpp-r1/responses.jsonl",
),
(
"raw/pixel7-llama3.2-1b-llamacpp-r1/metadata.json",
"raw/pixel7-llama3.2-1b-llamacpp-r1/metadata.json",
),
(
"raw/pixel7-llama3.2-1b-llamacpp-r1/responses.jsonl",
"raw/pixel7-llama3.2-1b-llamacpp-r1/responses.jsonl",
),
("releases/preview-v0.1.0/README.md", "release/README.md"),
("releases/preview-v0.1.0/PUBLIC_PREVIEW.md", "PREVIEW.md"),
]
def digest(path: Path) -> str:
value = hashlib.sha256()
with path.open("rb") as handle:
for block in iter(lambda: handle.read(1024 * 1024), b""):
value.update(block)
return value.hexdigest()
def manifest_path(release: str) -> Path:
return HERE / "dataset" / f"{release}-manifest.json"
def build_manifest(release: str) -> dict:
files = []
for source_name, target_name in PUBLIC_FILES:
source = BENCHMARK / source_name
if not source.is_file():
raise RuntimeError(f"missing public input: {source}")
files.append({
"source": source_name,
"path": target_name,
"bytes": source.stat().st_size,
"sha256": digest(source),
})
return {
"schema_version": "1.0",
"release_id": release,
"created_on": date.today().isoformat(),
"status": "unranked-directional-preview",
"track": "fixed-context-common-runtime",
"excludes": ["internal-only brief", "end-to-end result", "smoke result"],
"files": files,
}
def write_manifest(release: str) -> int:
output = manifest_path(release)
if output.exists():
raise RuntimeError(f"{output} already exists; public release manifests are immutable")
value = build_manifest(release)
output.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print(output)
print(f"Pinned {len(value['files'])} public files.")
return 0
def verify_manifest(release: str) -> int:
path = manifest_path(release)
value = json.loads(path.read_text(encoding="utf-8"))
expected = {(entry["source"], entry["path"]) for entry in value["files"]}
declared = set(PUBLIC_FILES)
errors = []
if expected != declared:
errors.append("public file list differs from frozen manifest")
for entry in value["files"]:
source = BENCHMARK / entry["source"]
if not source.is_file():
errors.append(f"missing: {entry['source']}")
elif source.stat().st_size != entry["bytes"] or digest(source) != entry["sha256"]:
errors.append(f"hash mismatch: {entry['source']}")
if errors:
raise RuntimeError("; ".join(errors))
print(f"Verified {len(value['files'])} public files for {release}.")
return 0
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--release", default=DEFAULT_RELEASE)
parser.add_argument("--verify", action="store_true")
args = parser.parse_args()
try:
return verify_manifest(args.release) if args.verify else write_manifest(args.release)
except (OSError, ValueError, RuntimeError) as exc:
print(f"ERROR: {exc}")
return 2
if __name__ == "__main__":
raise SystemExit(main())
|