File size: 939 Bytes
60f3845
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""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)