-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_figures.sh
executable file
·83 lines (64 loc) · 2.32 KB
/
generate_figures.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
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
#!/usr/bin/env bash
# Exit if any command fails
set -e
# Navigate to the "src" directory
cd src
echo "Generating main figures..."
entire_runtime=0
# Iterate notebooks from 1 to 6
for i in {1..6}; do
echo "Running Figure${i}.ipynb..."
# Record the start time (in seconds)
start_time=$(date +%s)
# Run the notebook without keeping the outputs in the final file
jupyter nbconvert \
--to notebook \
--execute Figure${i}.ipynb \
--output Figure${i}_executed.ipynb \
--ExecutePreprocessor.timeout=-1 \
--ClearOutputPreprocessor.enabled=True
# Record the end time (in seconds) and compute duration
end_time=$(date +%s)
runtime=$((end_time - start_time))
# Convert runtime to minutes (integer approximation)
runtime_secs=$((runtime))
entire_runtime=$((entire_runtime + runtime_secs))
# Print summary
echo "Figures for Figure ${i} are saved under ../results/Figure${i} and it took ${runtime_secs} seconds."
rm Figure${i}_executed.ipynb
echo "--------------------------------------------------------"
done
# Print total runtime
echo "Generating all main figures took ${entire_runtime} seconds."
echo "Generating extended data figures..."
entire_runtime=0
# Iterate notebooks from 1 to 6
for i in {1..12}; do
# Skip 5
if [ $i -eq 5 ]; then
continue
fi
echo "Running EDFigure${i}.ipynb..."
# Record the start time (in seconds)
start_time=$(date +%s)
# Run the notebook without keeping the outputs in the final file
jupyter nbconvert \
--to notebook \
--execute EDFigure${i}.ipynb \
--output EDFigure${i}_executed.ipynb \
--ExecutePreprocessor.timeout=-1 \
--ClearOutputPreprocessor.enabled=True
# Record the end time (in seconds) and compute duration
end_time=$(date +%s)
runtime=$((end_time - start_time))
# Convert runtime to minutes (integer approximation)
runtime_secs=$((runtime))
entire_runtime=$((entire_runtime + runtime_secs))
# Print summary
echo "Figures for EDFigure ${i} are saved under ../results/EDFigure${i} and it took ${runtime_secs} seconds."
rm EDFigure${i}_executed.ipynb
echo "--------------------------------------------------------"
done
# Print total runtime
echo "Generating all extended data figures took ${entire_runtime} seconds."
exit 0