Record independent benchmark child exits without scientific retries
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
"""Write new engineering child-process exit receipts; never retry a job."""
|
||||||
|
import argparse
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
p = argparse.ArgumentParser()
|
||||||
|
p.add_argument('--label', required=True)
|
||||||
|
p.add_argument('--timeout', type=int, default=900)
|
||||||
|
p.add_argument('command', nargs=argparse.REMAINDER)
|
||||||
|
a = p.parse_args()
|
||||||
|
assert re.fullmatch(r'[a-z0-9-]+', a.label)
|
||||||
|
assert a.command
|
||||||
|
out = Path('/home/qishizhe/phase4ar-v100-acceleration-20261001') / 'jobs'
|
||||||
|
out.mkdir(exist_ok=True)
|
||||||
|
start = time.perf_counter()
|
||||||
|
receipt = dict(command=a.command, label=a.label, started_utc=datetime.now(timezone.utc).isoformat(),
|
||||||
|
original_experiment_resumed=False)
|
||||||
|
with (out / (a.label + '.start.json')).open('x') as f:
|
||||||
|
json.dump(receipt, f, indent=2)
|
||||||
|
with (out / (a.label + '.stdout.log')).open('x') as stdout, (out / (a.label + '.stderr.log')).open('x') as stderr:
|
||||||
|
try:
|
||||||
|
result = subprocess.run(a.command, stdout=stdout, stderr=stderr,
|
||||||
|
env={**os.environ, 'PYTHONDONTWRITEBYTECODE': '1'}, timeout=a.timeout)
|
||||||
|
receipt.update(exit_code=result.returncode, observed_exit=True, timed_out=False)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
receipt.update(exit_code=None, observed_exit=False, timed_out=True)
|
||||||
|
receipt.update(wall_seconds=time.perf_counter()-start, finished_utc=datetime.now(timezone.utc).isoformat())
|
||||||
|
with (out / (a.label + '.exit.json')).open('x') as f:
|
||||||
|
json.dump(receipt, f, indent=2)
|
||||||
|
print(json.dumps(receipt), flush=True)
|
||||||
|
raise SystemExit(receipt['exit_code'] if receipt['observed_exit'] else 124)
|
||||||
Reference in New Issue
Block a user