-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sh
executable file
·62 lines (56 loc) · 1.34 KB
/
common.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
#!/bin/bash
function run_in_parallel()
{
cmd=$1
#echo_err $cmd
lrc=${params[LRC]-1}
if [ $lrc -eq 1 ]; then
jobname=$2
priority=$3
logdir=$4
timeout=$5
$ML_FRAMEWORK_DIR/log.sh INFO "Running job $jobname on cluster. The logfile can be found in $logdir"
qsubmit --jobname="$jobname" --mem="5g" --priority="$priority" --logdir="$logdir" \
"$cmd"
sleep $timeout
else
eval $cmd
fi
}
function wait_for_jobs()
{
jobs_finished_indicators=$1
all_jobs_count=$2
timeout=${3-10}
$ML_FRAMEWORK_DIR/log.sh INFO "Waiting for jobs to be completed..."
while [ `ls $jobs_finished_indicators 2> /dev/null | wc -l` -lt $all_jobs_count ]; do
$ML_FRAMEWORK_DIR/log.sh DEBUG `ls $jobs_finished_indicators 2> /dev/null | wc -l` $all_jobs_count
sleep $timeout
done
}
function echo_err() {
echo "$@" >&2
}
function print_ranking_header() {
if [ -z $1 ]; then
echo "TRAIN:"
else
echo "$1:"
fi
echo
echo
echo
}
function print_header() {
stats_size=`cat $1 | wc -l`
shift
one_label_size=$(( $stats_size / $# ))
for (( i=0; i<$stats_size; i++ )); do
if [ $(( $i % $one_label_size )) -eq 0 ]; then
echo "$1:"
shift
else
echo
fi
done
}