cb-telemetry / scripts /run_smoke_eval.py
ghdgfxzfdz's picture
Add CB-Telemetry v1 benchmark package
f4c7158 verified
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import csv
import gzip
import json
from pathlib import Path
def read_csv_rows(path: Path) -> list[dict[str, str]]:
if path.suffix == ".gz":
handle = gzip.open(path, "rt", encoding="utf-8", newline="")
else:
handle = path.open("r", encoding="utf-8", newline="")
with handle:
return list(csv.DictReader(handle))
def main() -> None:
parser = argparse.ArgumentParser(description="Run a dependency-light CB-Telemetry smoke check.")
parser.add_argument("--root", default=".")
args = parser.parse_args()
root = Path(args.root).resolve()
scored = read_csv_rows(root / "manifests" / "scored_snapshot_manifest.csv")
samples = read_csv_rows(root / "manifests" / "audio_sample_manifest.csv")
default_features = read_csv_rows(root / "features" / "feature_table_default.csv.gz")
strict_features = read_csv_rows(root / "features" / "feature_table_strict_clean.csv.gz")
summary = {
"status": "pass",
"scored_rows": len(scored),
"audio_sample_rows": len(samples),
"default_feature_rows": len(default_features),
"strict_feature_rows": len(strict_features),
"jstage_matched_recordings": sum(1 for row in scored if int(float(row.get("jstage_event_count") or 0)) > 0),
}
(root / "qa").mkdir(parents=True, exist_ok=True)
(root / "qa" / "smoke_eval_summary.json").write_text(
json.dumps(summary, indent=2, ensure_ascii=False) + "\n",
encoding="utf-8",
)
print(json.dumps(summary, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()