forked from yesup/tensorflow-serving-client-java
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·55 lines (50 loc) · 1.67 KB
/
update.sh
File metadata and controls
executable file
·55 lines (50 loc) · 1.67 KB
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
#!/bin/bash
set -e
cd $(dirname ${BASH_SOURCE[0]})
ver="$(cat VERSION | cut -d'.' -f1,2)"
proj=tensorflow-serving-client
apis=tensorflow_serving/apis
repo=build/upstream
goto=proto
#groot="github.com/figroc/tensorflow-serving-client/v${ver%%.*}/go/"
norm=(#'s@(import "tensorflow)_(serving/.*.proto".*)@\1/\2@'
's@(tensorflow/core/)lib/core(/.*.proto)@\1protobuf\2@'
"s@(option go_package = \")github.com/.*/([a-z_]+)/go(/.*)@\1${groot}\2\3@"
's@(option go_package = ".*tensorflow/core/)protobuf(/.*)@\1framework\2@'
's@(option go_package = ".*)/[a-z_]*_go_proto(".*)@\1\2@')
norm=$(IFS=';'; echo "${norm[*]}")
rm -rf ${repo} && mkdir -p ${repo}
function fetchRepo {( set -e
git -C ${repo} \
clone --depth 1 -b r${ver} \
https://github.com/tensorflow/${1}.git
)}
fetchRepo tensorflow tensorflow
fetchRepo serving tensorflow_serving
rm -rf ${goto}
function importProto {( set -e
local f=${1} i=${1}
#if [[ "${1}" == tensorflow_serving/* ]]; then
# i=${i/_//}
#elif [[ "${1}" == tensorflow/serving/* ]]; then
# f=${f/\//_}
#fi
if [[ ! -f ${goto}/${i} ]]; then
for p in $(find ${repo} -path "*/${f}"); do
mkdir -p ${goto}/${i%/*} && echo ${p}
local fix="${norm}"
if ! grep 'option go_package = "' ${p} &>/dev/null; then
fix+=";s@^package .*\$@&\\noption go_package = \"${groot}${i%/*}\"\;@"
fi
sed -E "${fix}" ${p} > ${goto}/${i}
done
for p in $(grep -s '^import ' ${goto}/${i} \
| grep -Eo '((\w|-)+(/|\.))+proto'); do
importProto ${p}
done
fi
)}
for i in ${repo}/serving/${apis}/*_service.proto; do
importProto ${apis}/${i##*/}
done
importProto ${apis}/prediction_log.proto