-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_debug_job.sh
executable file
·49 lines (39 loc) · 1.1 KB
/
run_debug_job.sh
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
#!/bin/bash
cd ~/multi-gpu-path-tracer
mkdir -p tmp
output_file="tmp/debug-job-output.txt"
prev_output_file="tmp/debug-job-output-prev.txt"
touch "$output_file" "$prev_output_file"
jobId=$(sbatch --output="$output_file" --error="$output_file" ./scripts/run_job.sh "$@" | awk '{print $4}')
show_new_lines() {
diff "$prev_output_file" "$output_file" | grep ">" | cut -c 3-
}
get_job_status() {
hpc-jobs | grep $jobId | awk '{print $4}'
}
cleanup() {
scancel $jobId
rm -f "$output_file" "$prev_output_file"
}
trap cleanup EXIT
has_notified_about_pending_state=false
while true; do
if ! cmp -s "$output_file" "$prev_output_file"; then
show_new_lines
cp "$output_file" "$prev_output_file"
fi
job_status=$(get_job_status)
if [ "$job_status" == "COMPLETED" ]; then
echo "Job completed successfully"
break
elif [ "$job_status" == "FAILED" ]; then
echo "Job failed"
break
elif [ "$job_status" == "PENDING" ]; then
if [ "$has_notified_about_pending_state" = false ]; then
echo "Job is pending..."
has_notified_about_pending_state=true
fi
fi
sleep 0.3
done