Spaces:
Running
Running
Download python/borderland_eval/manifests.py from FatUnc6969/borderland-rl: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/FatUnc6969/borderland-rl/resolve/main/python/borderland_eval/manifests.py
- Command line
-
hf download hf://spaces/FatUnc6969/borderland-rl/python/borderland_eval/manifests.py
-
curl -L -o manifests.py https://huggingface.co/spaces/FatUnc6969/borderland-rl/resolve/main/python/borderland_eval/manifests.py
1.33 kB
| """Frozen operator-only root seeds; never passed to a policy's choose method.""" | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| def canonical(value): | |
| return json.dumps(value, sort_keys=True, separators=(",", ":")) | |
| def digest(value): | |
| return hashlib.sha256(canonical(value).encode()).hexdigest() | |
| def manifest(split, generation_version=2): | |
| if split not in ("train", "dev", "test"): | |
| raise ValueError("split must be train, dev, or test") | |
| if type(generation_version) is not int or generation_version not in (2, 3): | |
| raise ValueError("generation_version must be 2 or 3") | |
| value = json.loads((Path(__file__).parent / "manifests" / f"v{generation_version}" / (split + ".json")).read_text()) | |
| if generation_version == 3 and value["sha256"] != digest({k: v for k, v in value.items() if k != "sha256"}): | |
| raise ValueError("split manifest hash mismatch") | |
| return value | |
| def manifests(generation_version=2): | |
| return {split: manifest(split, generation_version) for split in ("train", "dev", "test")} | |
| def source_hash(): | |
| root = Path(__file__).resolve().parent.parent | |
| hasher = hashlib.sha256() | |
| for path in sorted(root.glob("borderland*/**/*.py")): | |
| hasher.update(str(path.relative_to(root)).encode() + b"\0" + path.read_bytes()) | |
| return hasher.hexdigest() | |