-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathbuild-proto.sh
More file actions
executable file
·37 lines (29 loc) · 1.21 KB
/
build-proto.sh
File metadata and controls
executable file
·37 lines (29 loc) · 1.21 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
#!/usr/bin/env bash
set -ex
# Do NOT use this directly, use jinaai/protogen image
# use jinaai/protogen:3.21 in order to use compiler version == 21 (creates pb/docarray_pb2.py)
# and use jinaai/protogen:latest to use compiler version <= 20 (creates pb2/docarray_pb2.py)
# make sure to use jinaai/protogen:3.21 to avoid overriting the module
#
# current dir: docarray/docarray
# run the following in bash:
# docker run -v $(pwd)/proto:/jina/proto jinaai/protogen
# finally, set back owner of the generated files using: sudo chown -R $(id -u ${USER}):$(id -g ${USER}) .
SRC_DIR=./
MODULE=docarray
SRC_NAME="${MODULE}.proto"
COMP_OUT_NAME="${MODULE}_pb2.py"
OUT_FOLDER="${2:-pb2}/"
VER_FILE=../__init__.py
if [ "$#" -ne 1 ] && [ "$#" -ne 2 ]; then
echo "Error: Please specify the [PATH_TO_GRPC_PYTHON_PLUGIN], refer more details at " \
"https://docarray.jina.ai/"
printf "\n"
echo "USAGE:"
printf "\t"
echo "bash ./build-proto.sh [PATH_TO_GRPC_PYTHON_PLUGIN]"
exit 1
fi
PLUGIN_PATH=${1} # /Volumes/TOSHIBA-4T/Documents/grpc/bins/opt/grpc_python_plugin
printf "\e[1;33mgenerating protobuf and grpc python interface\e[0m\n"
protoc -I ${SRC_DIR} --python_out="${SRC_DIR}${OUT_FOLDER}" ${SRC_DIR}${SRC_NAME}