"""Extract the complete T814 default computation without changing any number.
python3 extract-computation.py compute.log computed.json
"""
import json,sys
from pathlib import Path
source=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_name('compute.log')
target=Path(sys.argv[2]) if len(sys.argv)>2 else source.with_name('computed.json')
lines=source.read_text().splitlines()
assert lines[-1]=='COMPUTATION_COMPLETE','Preserve incomplete checkpoints and resume'
rows=[json.loads(s[6:]) for s in lines if s.startswith('ENTRY ')]
assert len(rows)==670
target.write_text(json.dumps(rows,indent=2)+'\n')
