Skip to content

Commit

Permalink
[ENH] Clean up protobuf generation for golang (#1357)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Cleans up protobuf generation for golang
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*

- [ ] Manually run make proto_go 

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Nov 8, 2023
1 parent 233a7cc commit 93993bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 42 deletions.
40 changes: 0 additions & 40 deletions go/coordinator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,3 @@ clean:

docker:
docker build -t chroma-coordinator:latest .

docker_multi_arch:
docker buildx build --platform linux/x86_64,linux/arm64 -t oxia:latest .

.PHONY: proto
proto:
cd proto && \
protoc \
--go_out=. \
--go_opt paths=source_relative \
--plugin protoc-gen-go="${GOPATH}/bin/protoc-gen-go" \
--go-grpc_out=. \
--go-grpc_opt paths=source_relative \
--plugin protoc-gen-go-grpc="${GOPATH}/bin/protoc-gen-go-grpc" \
--go-vtproto_out=. \
--go-vtproto_opt paths=source_relative \
--plugin protoc-gen-go-vtproto="${GOPATH}/bin/protoc-gen-go-vtproto" \
--go-vtproto_opt=features=marshal+unmarshal+size+pool+equal+clone \
*.proto

proto_clean:
rm -f */*.pb.go

proto_format:
#brew install clang-format
clang-format -i --style=Google proto/*.proto

proto_lint:
#go install github.com/yoheimuta/protolint/cmd/protoc-gen-protolint
protoc --proto_path ./proto \
--protolint_out . \
--protolint_opt config_dir_path=. \
--protolint_opt proto_root=./proto \
proto/*.proto

proto_doc:
#go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
protoc --doc_out=docs/proto --doc_opt=markdown,proto.md proto/*.proto

proto_quality: proto_format proto_lint
18 changes: 16 additions & 2 deletions idl/makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
.PHONY: proto

proto:
@echo "Generating gRPC code..."
proto_python:
@echo "Generating gRPC code for python..."
@python -m grpc_tools.protoc -I ./ --python_out=. --pyi_out=. --grpc_python_out=. ./chromadb/proto/*.proto
@mv chromadb/proto/*.py ../chromadb/proto/
@mv chromadb/proto/*.pyi ../chromadb/proto/
@echo "Done"

proto_go:
@echo "Generating gRPC code for golang..."
@protoc \
--go_out=../go/coordinator/internal/proto/coordinatorpb \
--go_opt paths=source_relative \
--plugin protoc-gen-go="${GOPATH}/bin/protoc-gen-go" \
--go-grpc_out=../go/coordinator/internal/proto/coordinatorpb \
--go-grpc_opt paths=source_relative \
--plugin protoc-gen-go-grpc="${GOPATH}/bin/protoc-gen-go-grpc" \
chromadb/proto/*.proto
@mv ../go/coordinator/internal/proto/coordinatorpb/chromadb/proto/*.go ../go/coordinator/internal/proto/coordinatorpb/
@rm -rf ../go/coordinator/internal/proto/coordinatorpb/chromadb
@echo "Done"

0 comments on commit 93993bb

Please sign in to comment.