-
Notifications
You must be signed in to change notification settings - Fork 1
/
start_bayesian_opt
executable file
·64 lines (51 loc) · 1.85 KB
/
start_bayesian_opt
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
#!/usr/bin/env bash
pkg_path="/home/mepland/chance_of_showers"
# Models to run, see model_kwarg_list in drive_bayesian_opt.py
# prod
i_model_min=0
i_model_max=34
# dev
# i_model_min=30 # 0, 3, 20, 25, 30
# i_model_max=$i_model_min
# Total number of points to generate
# prod
max_points=200
# dev
# max_points=5
# Turn on tdqm
# unset TQDM_DISABLE
# Turn off tqdm
export TQDM_DISABLE=1
# Maximum number of iterations of Bayesian optimization to perform.
# Will stop script if reached before max_points, preventing infinite loops.
max_iter=999
max_iter=$((max_points < max_iter ? max_points : max_iter))
# Check for running drive_bayesian_opt.py
if pgrep -fc "python.*?drive_bayesian_opt.py" > /dev/null 2>&1; then
echo "Found python drive_bayesian_opt.py running, doing nothing"
unset TQDM_DISABLE
exit
fi
# Run over all models
for ((i_model = i_model_min; i_model <= i_model_max; i_model++)); do
printf "Starting i_model = %d, running to i_model = %d\n\n" "$i_model" "$i_model_max"
# Run drive_bayesian_opt.py max_iter times, or until max_points is reached
n_points=-1
for ((i_iter = 1; i_iter <= max_iter; i_iter++)); do
# Can add \r to start to backup one line, if drive_bayesian_opt.py is printing nothing out
printf "Starting drive_bayesian_opt.py i_iter = %d of %d for i_model = %d, currently have %d points\n" "$i_iter" "$max_iter" "$i_model" "$n_points"
poetry run python -u $pkg_path/ana/drive_bayesian_opt.py +i_model=$i_model +max_points=$max_points
status=$?
n_points=$((status - 10))
if [[ $status -lt 10 ]]; then
echo "On i_iter = $i_iter, found status = $status, an exception occurred, breaking to next model!"
break
elif [[ $max_points -le $n_points ]]; then
echo "On i_iter = $i_iter, found max_points = $max_points <= $n_points points, breaking to next model"
break
fi
done
done
echo "Completed all runs"
unset TQDM_DISABLE
exit