prophet / scripts /rewrite_instructions.py
drkylj's picture
Add predictor spec and prompt; tasks get a Rules section; audit flags end-to-end solving
60f3845 verified
Raw History Blame Contribute Delete
939 Bytes
"""Re-render instruction.md for already-built tasks from the current INSTRUCTION template."""
import glob, json, os, sys, importlib.util
spec = importlib.util.spec_from_file_location('bt', 'scripts/build_tasks.py'); bt = importlib.util.module_from_spec(spec); spec.loader.exec_module(bt)
n = 0
for root in sys.argv[1:]:
for t in glob.glob(os.path.join(root, '*')):
ctx = os.path.join(t, 'environment', 'context')
info = json.load(open(f'{ctx}/run_info.json')); tg = json.load(open(f'{ctx}/targets.json'))
c = info['cut_at_submission_index']
tmd = '\n'.join(f"- submission {x['index']} ({'final, hidden workloads' if x['kind']=='final' else 'train'})" for x in tg)
ex = ', '.join(f'{{"index": {x["index"]}, "score": <number>}}' for x in tg)
open(os.path.join(t, 'instruction.md'), 'w').write(bt.INSTRUCTION.format(c=c, targets_md=tmd, pred_example=ex))
n += 1
print('rewrote', n)