#!/usr/bin/env python3
"""Parse H200 DSpark benchmark outputs.

This is a thin wrapper around the legacy parser in
scripts/benchmark_dspark_0707/parse_results.py. It exists so that the
experiment keeps the same entry point as other experiments.

Usage:
    python3 parse_results.py <result_root>
"""

import os
import subprocess
import sys
from pathlib import Path


def main() -> None:
    result_root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("results")
    repo_root = Path(__file__).resolve().parents[2]
    legacy_parser = repo_root / "scripts" / "benchmark_dspark_0707" / "parse_results.py"

    if not legacy_parser.exists():
        raise SystemExit(f"legacy parser not found: {legacy_parser}")

    venv_client = os.environ.get("VENV_CLIENT", "/data/user1/yy/envs/sglang")
    python = Path(venv_client) / "bin" / "python"
    if not python.exists():
        python = Path(sys.executable)

    subprocess.run([str(python), str(legacy_parser), str(result_root)], check=True)
    print(f"Parsed {result_root}")


if __name__ == "__main__":
    main()
