Datasets:
Download make_release.py from udgamlabs/logic-puzzles: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/datasets/udgamlabs/logic-puzzles/resolve/main/make_release.py
- Command line
-
hf download hf://datasets/udgamlabs/logic-puzzles/make_release.py
-
curl -L -o make_release.py https://huggingface.co/datasets/udgamlabs/logic-puzzles/resolve/main/make_release.py
1.57 kB
| # Copyright 2026 Udgam Labs | |
| # SPDX-License-Identifier: Apache-2.0 | |
| """Rebuild the published Udgam Logic Puzzles files exactly (needs pyarrow for Parquet). | |
| python make_release.py OUT_DIR | |
| The test split is made first (100 puzzles per family); the train split (up to 6,000 per family) never repeats a test | |
| question. Same seeds, same files. | |
| """ | |
| import json | |
| import os | |
| import sys | |
| import pyarrow as pa | |
| import pyarrow.parquet as pq | |
| import logic_puzzles as lp | |
| TEST_SEED, TRAIN_SEED = "udgam-logic-puzzles-v1/test", "udgam-logic-puzzles-v1/train" | |
| TEST_PER_FAMILY, TRAIN_PER_FAMILY = 100, 6000 | |
| COLUMNS = ["id", "family", "question", "answer", "answer_type"] | |
| def write(rows, path): | |
| table = pa.Table.from_pylist(rows).select(COLUMNS) | |
| pq.write_table(table, path, compression="zstd") | |
| def main(out): | |
| os.makedirs(os.path.join(out, "data"), exist_ok=True) | |
| log = lambda m: print(m, flush=True) # noqa: E731 | |
| test = list(lp.generate(TEST_SEED, TEST_PER_FAMILY, log=log)) | |
| train = list(lp.generate(TRAIN_SEED, TRAIN_PER_FAMILY, exclude={r["question"] for r in test}, log=log)) | |
| write(test, os.path.join(out, "data", "test.parquet")) | |
| write(train, os.path.join(out, "data", "train.parquet")) | |
| counts = {s: {f: sum(r["family"] == f for r in rows) for f in lp.FAMILIES} for s, rows in (("train", train), ("test", test))} | |
| json.dump(dict(train=len(train), test=len(test), per_family=counts), open(os.path.join(out, "counts.json"), "w"), indent=1) | |
| print(f"train {len(train)}, test {len(test)}") | |
| if __name__ == "__main__": | |
| main(sys.argv[1]) | |