Skip to content

Commit 3b6d8e3

Browse files
authored
chore: Update go targets in Makefile (#4861)
* update go targets in Makefile Signed-off-by: Dimitris <xanias@gmail.com> * Separate proto compilation for Go Signed-off-by: Dimitris <xanias@gmail.com> --------- Signed-off-by: Dimitris <xanias@gmail.com>
1 parent 22c7b58 commit 3b6d8e3

File tree

3 files changed

+46
-76
lines changed

3 files changed

+46
-76
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ scratch*
33

44
### Local Environment ###
55
*local*.env
6+
tools
67

78
### Secret ###
89
**/service_account.json
@@ -101,6 +102,7 @@ htmlcov/
101102
.cache
102103
nosetests.xml
103104
coverage.xml
105+
coverage.out
104106
*.cover
105107
.hypothesis/
106108
.pytest_cache/
@@ -222,4 +224,4 @@ ui/.vercel
222224
**/yarn-error.log*
223225

224226
# Go subprocess binaries (built during feast pip package building)
225-
sdk/python/feast/binaries/
227+
sdk/python/feast/binaries/

Makefile

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
# limitations under the License.
1515
#
1616

17-
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
17+
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
18+
19+
# install tools in project (tool) dir to not pollute the system
20+
TOOL_DIR := $(ROOT_DIR)/tools
21+
export GOBIN=$(TOOL_DIR)/bin
22+
export PATH := $(TOOL_DIR)/bin:$(PATH)
23+
1824
MVN := mvn -f java/pom.xml ${MAVEN_EXTRA_OPTS}
1925
OS := linux
2026
ifeq ($(shell uname -s), Darwin)
@@ -24,12 +30,15 @@ TRINO_VERSION ?= 376
2430
PYTHON_VERSION = ${shell python --version | grep -Eo '[0-9]\.[0-9]+'}
2531

2632
PYTHON_VERSIONS := 3.9 3.10 3.11
33+
2734
define get_env_name
2835
$(subst .,,py$(1))
2936
endef
3037

3138

3239
# General
40+
$(TOOL_DIR):
41+
mkdir -p $@/bin
3342

3443
format: format-python format-java
3544

@@ -561,43 +570,60 @@ build-ui:
561570

562571

563572
# Go SDK & embedded
564-
install-protoc-dependencies:
565-
pip install "protobuf>=4.24.0,<5.0.0" "grpcio-tools>=1.56.2,<2" "mypy-protobuf>=3.1"
573+
PB_REL = https://github.com/protocolbuffers/protobuf/releases
574+
PB_VERSION = 3.11.2
575+
PB_ARCH := $(shell uname -m)
576+
ifeq ($(PB_ARCH), arm64)
577+
PB_ARCH=aarch_64
578+
endif
579+
PB_PROTO_FOLDERS=core registry serving types storage
580+
581+
$(TOOL_DIR)/protoc-$(PB_VERSION)-$(OS)-$(PB_ARCH).zip: $(TOOL_DIR)
582+
cd $(TOOL_DIR) && \
583+
curl -LO $(PB_REL)/download/v$(PB_VERSION)/protoc-$(PB_VERSION)-$(OS)-$(PB_ARCH).zip
566584

567-
install-go-proto-dependencies:
585+
.PHONY: install-go-proto-dependencies
586+
install-go-proto-dependencies: $(TOOL_DIR)/protoc-$(PB_VERSION)-$(OS)-$(PB_ARCH).zip
587+
unzip -u $(TOOL_DIR)/protoc-$(PB_VERSION)-$(OS)-$(PB_ARCH).zip -d $(TOOL_DIR)
568588
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0
569589
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
570590

591+
.PHONY: compile-protos-go
592+
compile-protos-go: install-go-proto-dependencies
593+
$(foreach folder,$(PB_PROTO_FOLDERS), \
594+
protoc --proto_path=$(ROOT_DIR)/protos \
595+
--go_out=$(ROOT_DIR)/go/protos \
596+
--go_opt=module=github.com/feast-dev/feast/go/protos \
597+
--go-grpc_out=$(ROOT_DIR)/go/protos \
598+
--go-grpc_opt=module=github.com/feast-dev/feast/go/protos $(ROOT_DIR)/protos/feast/$(folder)/*.proto; ) true
599+
571600
#install-go-ci-dependencies:
572601
# go install golang.org/x/tools/cmd/goimports
573602
# python -m pip install "pybindgen==0.22.1" "grpcio-tools>=1.56.2,<2" "mypy-protobuf>=3.1"
574603

575-
build-go:
576-
compile-protos-go
604+
.PHONY: build-go
605+
build-go: compile-protos-go
577606
go build -o feast ./go/main.go
578607

608+
.PHONY: install-feast-ci-locally
579609
install-feast-ci-locally:
580-
pip install -e ".[ci]"
610+
uv pip install -e ".[ci]"
581611

582-
test-go:
583-
compile-protos-go
584-
compile-protos-python
585-
install-feast-ci-locally
612+
.PHONY: test-go
613+
test-go: compile-protos-go install-feast-ci-locally compile-protos-python
586614
CGO_ENABLED=1 go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out -o coverage.html
587615

616+
.PHONY: format-go
588617
format-go:
589618
gofmt -s -w go/
590619

591-
lint-go:
592-
compile-protos-go
620+
.PHONY: lint-go
621+
lint-go: compile-protos-go
593622
go vet ./go/internal/feast
594623

624+
.PHONY: build-go-docker-dev
595625
build-go-docker-dev:
596626
docker buildx build --build-arg VERSION=dev \
597627
-t feastdev/feature-server-go:dev \
598628
-f go/infra/docker/feature-server/Dockerfile --load .
599629

600-
compile-protos-go:
601-
install-go-proto-dependencies
602-
install-protoc-dependencies
603-
python setup.py build_go_protos

setup.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -257,61 +257,6 @@
257257

258258
PYTHON_CODE_PREFIX = "sdk/python"
259259

260-
def _generate_path_with_gopath():
261-
go_path = subprocess.check_output(["go", "env", "GOPATH"]).decode("utf-8")
262-
go_path = go_path.strip()
263-
path_val = os.getenv("PATH")
264-
path_val = f"{path_val}:{go_path}/bin"
265-
266-
return path_val
267-
268-
class BuildGoProtosCommand(Command):
269-
description = "Builds the proto files into Go files."
270-
user_options = []
271-
272-
def initialize_options(self):
273-
self.go_protoc = [
274-
sys.executable,
275-
"-m",
276-
"grpc_tools.protoc",
277-
] # find_executable("protoc")
278-
self.proto_folder = os.path.join(repo_root, "protos")
279-
self.go_folder = os.path.join(repo_root, "go/protos")
280-
self.sub_folders = ["core", "registry", "serving", "types", "storage"]
281-
self.path_val = _generate_path_with_gopath()
282-
283-
def finalize_options(self):
284-
pass
285-
286-
def _generate_go_protos(self, path: str):
287-
proto_files = glob.glob(os.path.join(self.proto_folder, path))
288-
289-
try:
290-
subprocess.check_call(
291-
self.go_protoc
292-
+ [
293-
"-I",
294-
self.proto_folder,
295-
"--go_out",
296-
self.go_folder,
297-
"--go_opt=module=github.com/feast-dev/feast/go/protos",
298-
"--go-grpc_out",
299-
self.go_folder,
300-
"--go-grpc_opt=module=github.com/feast-dev/feast/go/protos",
301-
]
302-
+ proto_files,
303-
env={"PATH": self.path_val},
304-
)
305-
except CalledProcessError as e:
306-
print(f"Stderr: {e.stderr}")
307-
print(f"Stdout: {e.stdout}")
308-
309-
def run(self):
310-
go_dir = Path(repo_root) / "go" / "protos"
311-
go_dir.mkdir(exist_ok=True)
312-
for sub_folder in self.sub_folders:
313-
self._generate_go_protos(f"feast/{sub_folder}/*.proto")
314-
315260

316261
setup(
317262
name=NAME,
@@ -376,7 +321,4 @@ def run(self):
376321
"pybindgen==0.22.0", # TODO do we need this?
377322
"setuptools_scm>=6.2", # TODO do we need this?
378323
],
379-
cmdclass={
380-
"build_go_protos": BuildGoProtosCommand
381-
},
382324
)

0 commit comments

Comments
 (0)