-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_pe.sh
executable file
·105 lines (83 loc) · 2.45 KB
/
run_pe.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
#!/bin/bash
start=$(date +%s)
if [ $# != 2 ]; then
echo "USAGE: sh run.sh input output"
echo "input: directory or file"
echo "output: directory or file"
exit 1
fi
INPUT=$1
OUTPUT=$2
UPGRADE_MDL="api_upgrade_src"
# UPGRADE_FILE="parallel_executor_api_upgrade_run.py"
UPGRADE_FILE="pe.py"
CUR_FOLDER=$(dirname $(readlink -f "$0"))
if [ -d ${INPUT} ]
then
if [ ! -d ${UPGRADE_MDL} ]; then
echo "api_upgrade_src module does not exist, please clone the code"
exit 1
fi
if [ ! -f ${UPGRADE_FILE} ]; then
echo "upgrade_models_api_run.py does not exist, please clone the code"
exit 1
fi
if [ ! -d "${INPUT}/${UPGRADE_MDL}" ]; then
# cp -r ${UPGRADE_MDL} ${INPUT}
rsync -av --progress ${UPGRADE_MDL} ${INPUT} --exclude="*/tests/*"
fi
if [ ! -f "${INPUT}/${UPGRADE_FILE}" ]; then
# cp ${UPGRADE_FILE} ${INPUT}
rsync -av --progress ${UPGRADE_FILE} ${INPUT} --exclude="*/tests/*"
fi
cd ${INPUT}
output_fir="${CUR_FOLDER}/${OUTPUT}"
config_file="./api_upgrade_src/conf/upgrade.conf"
sed -i "1c input_path=${INPUT}" ${config_file}
sed -i "2c output_path=${output_fir}" ${config_file}
python3 ${UPGRADE_FILE}
if [ -d "${UPGRADE_MDL}" ]; then
rm -r ${UPGRADE_MDL}
fi
if [ -f "${UPGRADE_FILE}" ]; then
rm ${UPGRADE_FILE}
fi
cd ${CUR_FOLDER}
elif [ -f ${INPUT} ]
then
prefix="./"
INPUT=${INPUT#$prefix}
ls -l | grep "${INPUT}"
cur_stat=$?
filename=${INPUT}
if [ ${cur_stat} == 1 ]; then
dir_name=$(dirname ${INPUT})
filename=${INPUT##*/}
if [ ! -d " ${dir_name}/${UPGRADE_MDL}" ]; then
# cp -r ${UPGRADE_MDL} ${dir_name}
rsync -av --progress ${UPGRADE_MDL} ${dir_name} --exclude="*/tests/*"
fi
if [ ! -f " ${dir_name}/${UPGRADE_FILE}" ]; then
# cp ${UPGRADE_FILE} ${dir_name}
rsync -av --progress ${UPGRADE_FILE} ${dir_name} --exclude="*/tests/*"
fi
cd ${dir_name}
fi
output_fir="${CUR_FOLDER}/${OUTPUT}"
config_file="./api_upgrade_src/conf/upgrade.conf"
sed -i "1c input_path=${filename}" ${config_file}
sed -i "2c output_path=${output_fir}" ${config_file}
python3 ${UPGRADE_FILE}
if [ ${cur_stat} == 1 ]; then
if [ -d "${UPGRADE_MDL}" ]; then
rm -r ${UPGRADE_MDL}
fi
if [ -f "${UPGRADE_FILE}" ]; then
rm ${UPGRADE_FILE}
fi
cd ${CUR_FOLDER}
fi
fi
end=$(date +%s)
take=$(( end - start ))
echo Time taken to execute commands is ${take} seconds.