-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_test2.sh
executable file
·197 lines (173 loc) · 5.01 KB
/
run_test2.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
# save output to log.out
exec > >(tee -i log.out)
# save error to log.err
exec 2> >(tee -i log.err >&2)
# Display help message
function Help {
echo "Usage: test_runs.sh [options]"
echo "Example: ./test_runs.sh nkululeko"
echo "Options:"
echo " nkululeko: test basic nkululeko"
echo " augment: test augmentation"
echo " predict: test prediction"
echo " demo: test demo"
echo " test: test test module"
echo " multidb: test multidb"
echo " explore: test explore module (must be run last)"
echo " all: test all modules"
echo " -spotlight: test all modules except spotlight (useful in SSH)"
echo " -overwrite: remove (old) results directory and create if not exist"
echo " --help: display this help message"
}
# rm results dir if argument is "nkululeko" or "all"
# TODO: move root to /tmp so no need to do this
if [ "$1" == "nkululeko" ] || [ "$1" == "all" ]; [ "$1" == "-spotlight" ]; then
# add overwrite argument
if [ "$2" == "-overwrite" ]; then
echo "Removing (old) results directory and create if not exist"
rm -rf tests/results/*
mkdir -p tests/results
fi
fi
# Run a test and check for errors
function RunTest {
"$@"
if [ $? -ne 0 ]; then
echo "Error: Test failed - $@"
return 1 # exit after error message
# else
# return 0 # continue after error message
fi
}
# resample before performing other tests
resample_ini_files=(
exp_polish_gmm.ini
)
# test basic nkululeko
nkululeko_ini_files=(
exp_emodb_os_praat_xgb.ini
exp_emodb_limit_size.ini
exp_emodb_featimport_xgb.ini
exp_emodb_cnn.ini
exp_emodb_balancing.ini
exp_emodb_split.ini
exp_ravdess_os_xgb.ini
exp_agedb_class_os_xgb.ini
exp_emodb_hubert_xgb.ini
exp_emodb_wavlm_xgb.ini
exp_emodb_whisper_xgb.ini
emodb_demo.ini
exp_emodb_os_xgb_test.ini
exp_emodb_trill_test.ini
exp_emodb_wav2vec2_test.ini
exp_emodb_os_xgb.ini
exp_emodb_os_svm.ini
exp_emodb_os_knn.ini
exp_emodb_os_mlp.ini
exp_agedb_os_xgr.ini
exp_agedb_os_mlp.ini
exp_polish_gmm.ini
)
# test augmentation
augment_ini_files=(
exp_emodb_augment_os_xgb.ini
exp_emodb-aug_os_xgb.ini
exp_emodb_random_splice_os_xgb.ini
exp_emodb_rs_os_xgb.ini
emodb_aug_train.ini
)
# test prediction
predict_ini_files=(
exp_emodb_predict.ini
)
# test demo
demo_ini_files=(
exp_emodb_os_xgb.ini
exp_emodb_os_svm.ini
exp_emodb_os_knn.ini
exp_emodb_os_mlp.ini
exp_agedb_os_xgr.ini
exp_agedb_os_mlp.ini
)
# test test module
test_ini_files=(
exp_emodb_os_xgb_test.ini
exp_emodb_trill_test.ini
exp_emodb_wav2vec2_test.ini
)
# test multidb
multidb_ini_files=(
exp_multidb.ini
)
# test explore module
explore_ini_files=(
exp_emodb_explore_data.ini
exp_emodb_explore_featimportance.ini
exp_emodb_explore_scatter.ini
exp_emodb_explore_features.ini
exp_agedb_explore_data.ini
exp_polish_gmm.ini # shap
exp_explore.ini # test splotlight
)
ensemble_ini_files=(
exp_emodb_os_knn.ini
exp_emodb_os_svm.ini
)
if [ $# -eq 0 ] || [ "$1" == "--help" ]; then
Help
fi
start_time=$(date +%s)
# Loop over the module or all modules if -all arg is given
if [ "$1" == "all" ]; then
modules=(nkululeko augment predict demo test multidb explore)
elif [ "$1" == "-spotlight" ]; then
modules=(resample nkululeko augment predict demo test multidb explore)
# unset last two ini files to exclude spotlight and shap
unset explore_ini_files[-1] # Exclude INI file for spotlight
unset explore_ini_files[-1] # and shap
else
modules=("$@")
fi
success_count=0
failed_count=0
for module in "${modules[@]}"
do
# Run the test over the selected modules
ini_files="${module}_ini_files[@]"
for ini_file in "${!ini_files}"
do
# if module is "demo" add "--list" argument
if [ "$module" == "demo" ]; then
RunTest python3 -m "nkululeko.$module" --config "tests/$ini_file" --list "data/test/samples.csv"
# for ensemble module
elif [ "$module" == "ensemble" ]; then
# combine all ini files
inis = ""
for ensemble_ini_file in "${ensemble_ini_files[@]}"
do
inis += "tests/$ensemble_ini_file "
done
RunTest python3 -m "nkululeko.$module" $inis --method mean
else # for other modules
RunTest python3 -m "nkululeko.$module" --config "tests/$ini_file"
fi
if [ $? -eq 0 ]; then
((success_count++))
else
((failed_count++))
failed_modules+=("$module with $ini_file")
fi
done
done
echo "Total tests passed: $success_count"
echo "Total tests failed: $failed_count"
if [ ${#failed_modules[@]} -gt 0 ]; then
echo "Failed modules and INI files:"
for failed_module in "${failed_modules[@]}"; do
echo "$failed_module"
done
fi
end_time=$(date +%s)
total_time=$((end_time - start_time))
echo "Total time taken: $total_time seconds"