File size: 1,231 Bytes
89552cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Rebuild the Parquet release from annotations + an extracted image tree.
#
# Usage:
#   1. Extract the screenshots to <root>/images/        (see README, "Getting the screenshots")
#   2. Put this repository's anno/ anno_point/ meta/ scripts/ under <root>/
#   3. cd <root> && bash scripts/hf_export/reexport.sh [meta file] [output dir]
#
# Paths inside meta/ are relative, so the working directory must be <root>.
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"