StatePlay-Reward-2280 / source /project /scripts /start_test03_then_test04.py
lupele's picture
Add files using upload-large-folder tool
4ec41f2 verified
Raw History Blame Contribute Delete
1.56 kB
#!/usr/bin/env python3
"""Start both versioned benchmarks detached, without storing API keys on disk."""
from __future__ import annotations
import getpass
import os
import subprocess
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
RUNNER = ROOT / "scripts/run_test03_then_test04.sh"
LOG_DIR = ROOT / "evaluation/versioned_tests/logs"
def main() -> None:
env = os.environ.copy()
for name in ("STATEPLAY_GPT_API_KEY", "STATEPLAY_GEMINI_API_KEY"):
if not env.get(name):
if not sys.stdin.isatty():
raise SystemExit(f"{name} is required; launch interactively or set it in the environment")
env[name] = getpass.getpass(f"{name}: ").strip()
if not env[name]:
raise SystemExit(f"{name} cannot be empty")
os.umask(0o077)
LOG_DIR.mkdir(parents=True, exist_ok=True)
log_path = LOG_DIR / "launcher.log"
with log_path.open("ab") as log:
process = subprocess.Popen(
["bash", str(RUNNER)], cwd=ROOT, env=env,
stdin=subprocess.DEVNULL, stdout=log, stderr=subprocess.STDOUT,
start_new_session=True,
)
(LOG_DIR / "launcher.pid").write_text(f"{process.pid}\n", encoding="ascii")
del env
time.sleep(2)
if process.poll() is not None:
raise SystemExit(f"Benchmark exited during startup (code {process.returncode}); see {log_path}")
print(f"Started test_03 then test_04 benchmark PID {process.pid}; log: {log_path}")
if __name__ == "__main__":
main()