Buckets:
| """Extract the recorded admitted winner without executing or resizing its output.""" | |
| import argparse | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("sampler", type=Path) | |
| parser.add_argument("output", type=Path) | |
| args = parser.parse_args() | |
| digest = hashlib.sha256(args.sampler.read_bytes()).hexdigest() | |
| assert digest == "6d0c5e65ea9695bddfe2a7a370ad9b8287b9f543b2f4a1c700ea6e08ac1f2f51" | |
| sampler = json.loads(args.sampler.read_text()) | |
| initial = {s["id"]: s for s in sampler["initial_states"]} | |
| states = [s for s in sampler["states"] if s["id"] not in initial and s["timestep"] == 0 and 1000 <= len(s["construction"]) <= 100000] | |
| winner = max(states, key=lambda s: s["value"]) | |
| assert winner["id"] == "6c30c38f-744d-4e72-99ed-d0b5973a05fc" | |
| parent = initial[winner["parents"][0]["id"]] | |
| program = winner["code"].strip() | |
| if program.startswith("```python"): | |
| program = program[len("```python"):] | |
| elif program.startswith("```"): | |
| program = program[3:] | |
| if program.rstrip().endswith("```"): | |
| program = program.rstrip()[:-3] | |
| program = program.strip() + "\n" | |
| artifact = dict(task="ac1", source_sampler_sha256=digest, source_sampler_step=1, | |
| selection="best_actual_admitted_state", admitted_candidates=len(states), state_id=winner["id"], | |
| parent_id=parent["id"], raw_score=-winner["value"], construction=winner["construction"], | |
| source_values=parent["construction"], program=program, program_sha256=hashlib.sha256(program.encode()).hexdigest(), | |
| program_replayed=False, construction_changed=False) | |
| assert artifact["program_sha256"] == "5967360d3dc3c0110b46082a3411246f78e7e78bcab0b64c530c1b93c0ceb558" | |
| args.output.write_text(json.dumps(artifact, indent=2) + "\n", encoding="utf-8") | |
| print(json.dumps({k: v for k, v in artifact.items() if k not in {"program", "construction", "source_values"}}, indent=2)) | |
Xet Storage Details
- Size:
- 1.87 kB
- Xet hash:
- 47b2f43c4f646912ebe8544c6738c2884d344c95f5e0c68751a4981afcf2c670
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.