forked from baidu/puck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
puck_train_control.sh
executable file
·84 lines (77 loc) · 1.9 KB
/
puck_train_control.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
#!/bin/bash
function _usage(){
usage_str="sh ${0} [-i init] [-b build] [-t train] [-f conf_file] [-h help]
\n\t\t
\n\toptions:
\n\t\t-i use for init method and init file name is necessary
\n\t\t-b use for build method
\n\t\t-t use for train method
\n\t\t-f conf file name
\n\t\t-h use for help"
echo -e ${usage_str}
}
if [ ! -n "$1" ] ;then
_usage
exit 1
fi
is_train=0
is_build=0
is_init=0
init_file=init-feature-example
conf_file=conf/puck_train.conf
while getopts "i:tbf:h" opt
do
case $opt in
t)
is_train=1;;
b)
is_build=1;;
i)
is_init=1
init_file=$OPTARG;;
f)
conf_file=$OPTARG;;
h)
_usage
exit 0;;
*)
_usage
exit 1;;
esac
done
if [ $is_init -eq 1 ]; then
echo "init feature file :" $init_file
#all_data_url="./puck_index/all_data.url"
python ./script/initProcessData.py -i ${init_file} -f ${conf_file}
retcode=$?
if [ $retcode == 1 ]; then
errmsg="input param error!"
elif [ $retcode == 2 ]; then
errmsg="input file is not exists!"
elif [ $retcode == 3 ]; then
errmsg="init feature file error!"
elif [ $retcode == 0 ]; then
errmsg="init feature file succeed!"
fi
echo `date` $errmsg
[ $retcode -ne 0 ] && exit $retcode
fi
curr_path=`pwd`
lib_path=$curr_path/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$lib_path
if [ $is_train -eq 1 ]; then
echo "start train"
./bin/train --flagfile=${conf_file}
retcode=$?
echo "train retcode : " $retcode
[ $retcode -ne 0 ] && exit $retcode
echo "train succ"
fi
if [ $is_build -eq 1 ]; then
echo "start build puck"
./bin/build --flagfile=${conf_file}
retcode=$?
echo "build puck retcode : " $retcode
[ $retcode -ne 0 ] && exit $retcode
echo "build puck succ"
fi