Datasets:
File size: 1,571 Bytes
df805d1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # 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])
|