rotating-cube-cfd / code /pack_dataset.sh
aloeme's picture
Upload code/pack_dataset.sh with huggingface_hub
be2d21f verified
Raw
History Blame Contribute Delete
1.17 kB
#!/bin/bash
# Package each case in runs/ as a lossless tar+zstd archive for HuggingFace upload.
# Output: hf_upload/<case>.tar.zst (+ .sha256). Resumable: skips an archive that exists.
# Low priority (nice/ionice) so it doesn't starve the running viz batch.
set -u
ROOT=/home/aloeme/openfoam
SRC=$ROOT/runs
OUT=$ROOT/hf_upload
LEVEL=${LEVEL:-6}
THREADS=${THREADS:-16}
mkdir -p "$OUT"
log(){ echo "[$(date +%H:%M:%S)] $*"; }
cases=$(ls -d "$SRC"/Re*_psi* 2>/dev/null | xargs -n1 basename | sort -V)
log "packing $(echo "$cases" | wc -l) cases -> $OUT (zstd -$LEVEL -T$THREADS)"
for case in $cases; do
arc="$OUT/$case.tar.zst"
if [ -s "$arc" ]; then log "SKIP $case (archive exists)"; continue; fi
log "PACK $case"
if nice -n 10 ionice -c2 -n6 \
tar -C "$SRC" -cf - "$case" \
| nice -n 10 zstd -q -$LEVEL -T$THREADS -o "$arc.tmp"; then
mv "$arc.tmp" "$arc"
( cd "$OUT" && sha256sum "$case.tar.zst" > "$case.tar.zst.sha256" )
log "DONE $case -> $(du -h "$arc" | cut -f1)"
else
log "FAIL $case"; rm -f "$arc.tmp"
fi
done
log "packaging complete. archives in $OUT/"
du -sh "$OUT" 2>/dev/null | cut -f1