Datasets:
Download code/public_bundle.py from UnpluggedAI/posa-bench: direct link, hf CLI and curl.
- Browser
- Download file 6.62 kB
-
https://huggingface.co/datasets/UnpluggedAI/posa-bench/resolve/main/code/public_bundle.py
- Command line
-
hf download hf://datasets/UnpluggedAI/posa-bench/code/public_bundle.py
-
curl -L -o public_bundle.py https://huggingface.co/datasets/UnpluggedAI/posa-bench/resolve/main/code/public_bundle.py
6.62 kB
| #!/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()) | |