Download scripts/rewrite_instructions.py from drkylj/prophet: direct link, hf CLI and curl.
- Browser
- Download file 939 Bytes
-
https://huggingface.co/datasets/drkylj/prophet/resolve/main/scripts/rewrite_instructions.py
- Command line
-
hf download hf://datasets/drkylj/prophet/scripts/rewrite_instructions.py
-
curl -L -o rewrite_instructions.py https://huggingface.co/datasets/drkylj/prophet/resolve/main/scripts/rewrite_instructions.py
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) | |