Download scripts/validate_local_package.py from StableTradeAtlas/stableeval-arena: direct link, hf CLI and curl.
- Browser
- Download file 5.34 kB
-
https://huggingface.co/datasets/StableTradeAtlas/stableeval-arena/resolve/main/scripts/validate_local_package.py
- Command line
-
hf download hf://datasets/StableTradeAtlas/stableeval-arena/scripts/validate_local_package.py
-
curl -L -o validate_local_package.py https://huggingface.co/datasets/StableTradeAtlas/stableeval-arena/resolve/main/scripts/validate_local_package.py
5.34 kB
| from __future__ import annotations | |
| import json | |
| import re | |
| from collections import Counter | |
| from pathlib import Path | |
| import pandas as pd | |
| ROOT = Path(__file__).resolve().parents[1] | |
| BANNED_NAMES = {".env", ".DS_Store", "__pycache__"} | |
| BANNED_PATTERNS = [ | |
| r"sk-or-v1-[A-Za-z0-9._-]+", | |
| r"ghp_[A-Za-z0-9]{20,}", | |
| r"hf_[A-Za-z0-9]{20,}", | |
| r"AKIA[0-9A-Z]{16}", | |
| r"Bearer [A-Za-z0-9._=-]{30,}", | |
| r"/Users/", | |
| r"results/validation_120", | |
| r"results/scaling_507", | |
| r"data/benchmark/full_507_prompt_packets.jsonl", | |
| r"data/benchmark/validation_120_prompt_packets.jsonl", | |
| r"raw_outputs", | |
| ] | |
| REQUIRED = [ | |
| "README.md", | |
| "LICENSE", | |
| "CITATION.cff", | |
| "benchmark_data_card.md", | |
| "FILE_MANIFEST.md", | |
| "checksums.sha256", | |
| "schemas/input_packet_schema.json", | |
| "schemas/output_schema.json", | |
| "schemas/label_schema.json", | |
| "data/stableeval_120_enriched/case_list.csv", | |
| "data/stableeval_120_enriched/labels.csv", | |
| "data/stableeval_120_enriched/prompt_packets.jsonl", | |
| "data/stableeval_507_natural/case_list.csv", | |
| "data/stableeval_507_natural/labels.csv", | |
| "data/stableeval_507_natural/prompt_packets.jsonl", | |
| "data/stableeval_507_natural/full_case_pool.csv", | |
| "results/stableeval_507_natural/final_tables/stableeval_507_natural_v6_leaderboard.csv", | |
| ] | |
| SYSTEMS_120 = ["nanobot", "langgraph", "hermes_ai", "evoagentx", "openclaw", "nanoclaw"] | |
| SYSTEMS_507 = [ | |
| "nanobot_qwen_507", | |
| "langgraph_qwen_507", | |
| "hermes_ai_qwen_507", | |
| "evoagentx_qwen_507", | |
| "openclaw_adapter_qwen_507", | |
| "nanoclaw_adapter_qwen_507", | |
| ] | |
| def count_jsonl(path: Path) -> int: | |
| count = 0 | |
| with path.open("r", encoding="utf-8") as handle: | |
| for line_no, line in enumerate(handle, start=1): | |
| if line.strip(): | |
| json.loads(line) | |
| count += 1 | |
| return count | |
| def assert_file(path: str) -> Path: | |
| p = ROOT / path | |
| if not p.exists(): | |
| raise SystemExit(f"Missing required file: {path}") | |
| return p | |
| for required in REQUIRED: | |
| assert_file(required) | |
| for path in ROOT.rglob("*"): | |
| if path.name in BANNED_NAMES or path.suffix == ".pyc": | |
| raise SystemExit(f"Banned cache/private file present: {path.relative_to(ROOT)}") | |
| if path.is_file() and path.stat().st_size > 75 * 1024 * 1024: | |
| raise SystemExit(f"Unexpected very large file: {path.relative_to(ROOT)}") | |
| if path.is_file() and path.suffix.lower() in {".md", ".txt", ".json", ".jsonl", ".csv", ".cff", ".sha256"}: | |
| text = path.read_text(encoding="utf-8", errors="ignore") | |
| for pattern in BANNED_PATTERNS: | |
| if re.search(pattern, text): | |
| raise SystemExit(f"Banned/stale/private pattern in {path.relative_to(ROOT)}: {pattern}") | |
| labels_120 = pd.read_csv(assert_file("data/stableeval_120_enriched/labels.csv")) | |
| labels_507 = pd.read_csv(assert_file("data/stableeval_507_natural/labels.csv")) | |
| cases_120 = pd.read_csv(assert_file("data/stableeval_120_enriched/case_list.csv")) | |
| cases_507 = pd.read_csv(assert_file("data/stableeval_507_natural/case_list.csv")) | |
| leaderboard = pd.read_csv(assert_file("results/stableeval_507_natural/final_tables/stableeval_507_natural_v6_leaderboard.csv")) | |
| if len(cases_120) != 120 or len(labels_120) != 120: | |
| raise SystemExit("StableEval-120-Enriched count check failed.") | |
| if len(cases_507) != 507 or len(labels_507) != 507: | |
| raise SystemExit("StableEval-507-Natural count check failed.") | |
| if Counter(labels_507["enhanced_stability_label"]) != Counter({"stable": 441, "watch": 45, "stress": 21}): | |
| raise SystemExit("507 label distribution check failed.") | |
| if count_jsonl(assert_file("data/stableeval_120_enriched/prompt_packets.jsonl")) != 120: | |
| raise SystemExit("120 prompt packet count check failed.") | |
| if count_jsonl(assert_file("data/stableeval_507_natural/prompt_packets.jsonl")) != 507: | |
| raise SystemExit("507 prompt packet count check failed.") | |
| if len(leaderboard) != 16: | |
| raise SystemExit("507 v6 leaderboard row count check failed.") | |
| for system in SYSTEMS_120: | |
| if count_jsonl(assert_file(f"results/stableeval_120_enriched/raw_predictions/{system}.jsonl")) != 120: | |
| raise SystemExit(f"120 raw prediction count failed for {system}") | |
| if count_jsonl(assert_file(f"results/stableeval_120_enriched/calibrated_predictions/{system}.jsonl")) != 120: | |
| raise SystemExit(f"120 calibrated prediction count failed for {system}") | |
| for system in SYSTEMS_507: | |
| if count_jsonl(assert_file(f"results/stableeval_507_natural/raw_predictions/{system}.jsonl")) != 507: | |
| raise SystemExit(f"507 raw prediction count failed for {system}") | |
| if count_jsonl(assert_file(f"results/stableeval_507_natural/calibrated_predictions/{system}.jsonl")) != 507: | |
| raise SystemExit(f"507 calibrated prediction count failed for {system}") | |
| for schema in ["input_packet_schema.json", "output_schema.json", "label_schema.json"]: | |
| json.loads((ROOT / "schemas" / schema).read_text(encoding="utf-8")) | |
| json.loads((ROOT / "croissant.json").read_text(encoding="utf-8")) | |
| print("Local StableEval Arena Hugging Face package validation passed.") | |
| print(f"120 cases: {len(cases_120)}") | |
| print(f"507 cases: {len(cases_507)}") | |
| print(f"507 label distribution: {dict(Counter(labels_507['enhanced_stability_label']))}") | |
| print(f"507 leaderboard rows: {len(leaderboard)}") | |