Spaces:
Running
Running
Download foresightbench_env/data.py from ruhzi/foresightbench-rl: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/spaces/ruhzi/foresightbench-rl/resolve/main/foresightbench_env/data.py
- Command line
-
hf download hf://spaces/ruhzi/foresightbench-rl/foresightbench_env/data.py
-
curl -L -o data.py https://huggingface.co/spaces/ruhzi/foresightbench-rl/resolve/main/foresightbench_env/data.py
690 Bytes
| """Paper-disjoint train/eval split of ForesightBench, bundled as jsonl.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from typing import Literal | |
| _PKG = Path(__file__).resolve().parent | |
| def load_split(name: Literal["train", "eval"], root: Path | None = None) -> list[dict]: | |
| """Rows of one split, bundled inside the package. `root` overrides with <root>/data/.""" | |
| if name not in ("train", "eval"): | |
| raise ValueError(f"unknown split {name!r}") | |
| path = ((root / "data") if root else (_PKG / "data")) / f"{name}.jsonl" | |
| with path.open(encoding="utf-8") as fh: | |
| return [json.loads(line) for line in fh if line.strip()] | |