neversa commited on
Commit
2b4baa1
·
verified ·
1 Parent(s): e0b8e24

Create extract.sh

Browse files
Files changed (1) hide show
  1. extract.sh +24 -0
extract.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Extract all shard_*.tar.gz in parallel with progress display.
3
+ # Usage: bash extract_shards.sh [shard_dir] [output_dir] [num_workers]
4
+
5
+ SHARD_DIR="${1:-data}"
6
+ OUT_DIR="${2:-llava178k_merged}"
7
+ WORKERS="${3:-8}"
8
+
9
+ mkdir -p "$OUT_DIR"
10
+
11
+ shards=("$SHARD_DIR"/shard_*.tar.gz)
12
+ total=${#shards[@]}
13
+ echo "Found $total shards, extracting with $WORKERS workers -> $OUT_DIR"
14
+
15
+ # Use GNU parallel if available, otherwise xargs
16
+ if command -v parallel &>/dev/null; then
17
+ printf '%s\n' "${shards[@]}" | parallel -j "$WORKERS" --bar \
18
+ tar xf {} --strip-components=1 -C "$OUT_DIR/"
19
+ else
20
+ printf '%s\n' "${shards[@]}" | xargs -P "$WORKERS" -I{} \
21
+ bash -c 'echo "Extracting {}..." && tar xf "{}" --strip-components=1 -C '"$OUT_DIR/"
22
+ fi
23
+
24
+ echo "Done. Extracted $total shards to $OUT_DIR/"