forked from pinecone-io/pinecone-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-grpc.sh
More file actions
executable file
·54 lines (42 loc) · 1.05 KB
/
build-grpc.sh
File metadata and controls
executable file
·54 lines (42 loc) · 1.05 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
#!/bin/bash
set -eux -o pipefail
version=$1 # e.g. 2024-07
update_apis_repo() {
echo "Updating apis repo"
pushd codegen/apis
git fetch
git checkout main
git pull
just build
popd
}
update_buf_config() {
pushd codegen
# Update buf config to find correct proto version
sed -i '' "s/[0-9][0-9][0-9][0-9]-[0-1][0-9]/${version}/g" buf.yaml
# Clean before building
rm -rf gen
# Ensure path valid by running the buf build command
buf build
popd
}
buf_generate() {
pushd codegen
# Generate the python code
buf generate
popd
}
update_apis_repo
update_buf_config
buf_generate
dest="pinecone/core/grpc/protos/"
# Remove existing files in dest
rm -rf "${dest}*.py"
rm -rf "${dest}*.pyi"
find codegen/gen/ -name "*.py" | while IFS= read -r file; do
sed -i '' "s/^import db_data/import pinecone.core.grpc.protos.db_data/g" "${file}"
done
# Copy the new generated files to dest directory
cp codegen/gen/* ${dest}
# Cleanup the intermediate files that were generated
rm -rf codegen/gen