-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-all-postprocess.sh
More file actions
executable file
·101 lines (83 loc) · 2.71 KB
/
run-all-postprocess.sh
File metadata and controls
executable file
·101 lines (83 loc) · 2.71 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# run-all-postprocess.sh
# Batch post-processing: generates videos for all case directories in simulationCases/
# Usage: bash run-all-postprocess.sh [--cpus N] [--dry-run]
#
# Processes ONE case at a time (sequential), but each case uses --cpus workers
# for parallel frame rendering. This avoids overloading the machine.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SIM_DIR="$REPO_ROOT/simulationCases"
PP_SCRIPT="$REPO_ROOT/postProcess/Video-generic.py"
LOG_DIR="$REPO_ROOT/postprocess-logs"
# Defaults
CPUS=4
DRY_RUN=false
# Parse args
while [[ $# -gt 0 ]]; do
case "$1" in
--cpus) CPUS="$2"; shift 2 ;;
--dry-run) DRY_RUN=true; shift ;;
*) echo "Unknown arg: $1"; exit 1 ;;
esac
done
# Environment setup
source ~/miniconda3/etc/profile.d/conda.sh
conda activate default
export BASILISK="/home/vatsal/CMP-codes/basilisk/src"
export PATH="$BASILISK:$PATH"
mkdir -p "$LOG_DIR"
echo "=================================================="
echo "Batch Post-Processing"
echo "Repo: $REPO_ROOT"
echo "CPUs: $CPUS per case (sequential case processing)"
echo "Started: $(date)"
echo "=================================================="
TOTAL=0
DONE=0
FAILED=0
SKIPPED=0
# Count eligible cases
for case_dir in "$SIM_DIR"/c*-{in,out}; do
[[ -d "$case_dir" ]] || continue
TOTAL=$((TOTAL + 1))
done
echo "Found $TOTAL case directories"
echo ""
for case_dir in "$SIM_DIR"/c*-{in,out}; do
[[ -d "$case_dir" ]] || continue
case_name=$(basename "$case_dir")
snap_count=$(ls "$case_dir/intermediate/snapshot-"* 2>/dev/null | wc -l)
if [[ "$snap_count" -eq 0 ]]; then
echo "[$case_name] SKIP — no snapshots"
SKIPPED=$((SKIPPED + 1))
continue
fi
# Check if video already exists
if [[ -f "$case_dir/video-film-generic.mp4" ]]; then
echo "[$case_name] SKIP — video already exists ($snap_count snapshots)"
SKIPPED=$((SKIPPED + 1))
continue
fi
echo "[$case_name] Processing $snap_count snapshots..."
log_file="$LOG_DIR/${case_name}.log"
if $DRY_RUN; then
echo " DRY RUN: python3 $PP_SCRIPT --case-dir $case_dir --cpus $CPUS"
continue
fi
if python3 "$PP_SCRIPT" --case-dir "$case_dir" --cpus "$CPUS" > "$log_file" 2>&1; then
DONE=$((DONE + 1))
echo "[$case_name] DONE ✓ (log: $log_file)"
else
FAILED=$((FAILED + 1))
echo "[$case_name] FAILED ✗ (log: $log_file)"
# Show last 5 lines of error
tail -5 "$log_file" | sed "s/^/ /"
fi
done
echo ""
echo "=================================================="
echo "Batch Post-Processing Complete"
echo "Total: $TOTAL | Done: $DONE | Failed: $FAILED | Skipped: $SKIPPED"
echo "Finished: $(date)"
echo "=================================================="