Preserve terminal evaluation observer for unattended recovery
Browse files
scripts/watch_review23_final_eval.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Observe the existing E3 evaluator and archive its terminal state; never launch training."""
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import subprocess
|
| 5 |
+
import time
|
| 6 |
+
from datetime import datetime, timezone
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 10 |
+
OUT = ROOT / 'results/phase6/review23/e3'
|
| 11 |
+
PID = 621209
|
| 12 |
+
|
| 13 |
+
def alive():
|
| 14 |
+
try:
|
| 15 |
+
return 'evaluate_review23_e3_final.py' in Path(f'/proc/{PID}/cmdline').read_text()
|
| 16 |
+
except FileNotFoundError:
|
| 17 |
+
return False
|
| 18 |
+
|
| 19 |
+
def main():
|
| 20 |
+
while alive():
|
| 21 |
+
time.sleep(30)
|
| 22 |
+
metrics = OUT / 'final_metrics.json'
|
| 23 |
+
status = json.loads((OUT / 'pipeline_status.json').read_text())
|
| 24 |
+
status['observed_at_utc'] = datetime.now(timezone.utc).isoformat()
|
| 25 |
+
if metrics.exists():
|
| 26 |
+
final = json.loads(metrics.read_text())
|
| 27 |
+
valid = (final.get('status') == 'complete' and final.get('test_read') is False
|
| 28 |
+
and final.get('config_sha256') == status.get('config_sha256')
|
| 29 |
+
and 'primary_seed42' in final.get('models', {}))
|
| 30 |
+
status['status'] = 'complete' if valid else 'failed_final_metrics_integrity'
|
| 31 |
+
status['final_metrics'] = str(metrics.relative_to(ROOT))
|
| 32 |
+
else:
|
| 33 |
+
status['status'] = 'failed_final_evaluation'
|
| 34 |
+
status['failure_reason'] = 'Observed evaluator terminated without final_metrics.json; inspect final_eval.log. No automatic retry.'
|
| 35 |
+
status['stage'] = 'terminal_final_evaluation'
|
| 36 |
+
status['test_read'] = False
|
| 37 |
+
temp = OUT / 'pipeline_status.completion.tmp'
|
| 38 |
+
temp.write_text(json.dumps(status, indent=2) + '\n')
|
| 39 |
+
os.replace(temp, OUT / 'pipeline_status.json')
|
| 40 |
+
print(json.dumps(status), flush=True)
|
| 41 |
+
subprocess.run([str(ROOT / '.venv/bin/python'), '-u', str(ROOT / 'scripts/hf_sync_snapshot.py')], cwd=ROOT, check=True)
|
| 42 |
+
|
| 43 |
+
if __name__ == '__main__':
|
| 44 |
+
main()
|