#!/usr/bin/env bash # Rebuild the Parquet release from annotations + an extracted image tree. # # Usage: # 1. Extract the screenshots to /images/ (see README, "Getting the screenshots") # 2. Put this repository's anno/ anno_point/ meta/ scripts/ under / # 3. cd && bash scripts/hf_export/reexport.sh [meta file] [output dir] # # Paths inside meta/ are relative, so the working directory must be . set -euo pipefail META="${1:-meta/meta_full.json}" OUT="${2:-parquet_out/data}" PY="${PYTHON:-python3}" JOBS="${JOBS:-8}" [ -f "$META" ] || { echo "cannot find $META (cwd must be the data root)" >&2; exit 1; } [ -d images ] || { echo "cannot find ./images/ - extract the screenshots first" >&2; exit 1; } mkdir -p "$OUT" NTASK=$("$PY" -c "import json; print(len(json.load(open('$META'))))") echo "== exporting $NTASK tasks -> $OUT ==" seq 0 $((NTASK - 1)) | xargs -P "$JOBS" -I{} \ "$PY" scripts/hf_export/build_shards.py --meta "$META" --out "$OUT" --task-index {} echo "== renaming to train-XXXXX-of-YYYYY.parquet ==" "$PY" scripts/hf_export/finalize.py --dir "$OUT" --meta "$META" --apply echo "== result ==" ls "$OUT" | grep -cE '^train-[0-9]{5}-of-[0-9]{5}\.parquet$' du -sh "$OUT"