Skip to content

Commit be34905

Browse files
authoredMar 4, 2023
chore: Stop compiling embedded go components (#3520)
* chore: Stop compiling embedded go components Signed-off-by: Achal Shah <achals@gmail.com> * remove more stuff Signed-off-by: Achal Shah <achals@gmail.com> * remove more stuff Signed-off-by: Achal Shah <achals@gmail.com> * kill test Signed-off-by: Achal Shah <achals@gmail.com> * remove arrow and go setup from github workflows Signed-off-by: Achal Shah <achals@gmail.com> * newline Signed-off-by: Achal Shah <achals@gmail.com> * format Signed-off-by: Achal Shah <achals@gmail.com> --------- Signed-off-by: Achal Shah <achals@gmail.com>
1 parent c619080 commit be34905

12 files changed

+10
-707
lines changed
 

‎.github/workflows/build_wheels.yml

-54
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ jobs:
7272
CIBW_BUILD: "cp3*_x86_64"
7373
CIBW_SKIP: "cp36-* cp37-* *-musllinux_x86_64 cp310-macosx_x86_64"
7474
CIBW_ARCHS: "native"
75-
CIBW_ENVIRONMENT: >
76-
COMPILE_GO=True PATH=$PATH:/usr/local/go/bin
77-
CIBW_BEFORE_ALL_LINUX: |
78-
curl -o go.tar.gz https://dl.google.com/go/go1.18.2.linux-amd64.tar.gz
79-
tar -C /usr/local -xzf go.tar.gz
80-
go version
81-
yum -y update &&
82-
yum install -y epel-release || yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1).noarch.rpm &&
83-
yum install -y https://apache.jfrog.io/artifactory/arrow/centos/$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)/apache-arrow-release-latest.rpm &&
84-
yum install -y --enablerepo=epel arrow-devel # For C++
8575
CIBW_BEFORE_ALL_MACOS: |
8676
brew install apache-arrow
8777
brew install pkg-config
@@ -90,8 +80,6 @@ jobs:
9080
# There's a `git restore` in here because `make install-go-ci-dependencies` is actually messing up go.mod & go.sum.
9181
CIBW_BEFORE_BUILD: |
9282
make install-protoc-dependencies
93-
make install-go-proto-dependencies
94-
make install-go-ci-dependencies
9583
git status
9684
git restore go.mod go.sum
9785
git restore sdk/python/feast/ui/yarn.lock
@@ -139,8 +127,6 @@ jobs:
139127
run: |
140128
pip install -U pip setuptools wheel twine
141129
make install-protoc-dependencies
142-
make install-go-proto-dependencies
143-
make install-go-ci-dependencies
144130
make build-ui
145131
git status
146132
git restore go.mod go.sum
@@ -203,9 +189,6 @@ jobs:
203189
with:
204190
python-version: ${{ matrix.python-version }}
205191
architecture: x64
206-
- uses: actions/setup-go@v3
207-
with:
208-
go-version: '>=1.17.0'
209192
- uses: actions/download-artifact@v2
210193
with:
211194
name: wheels
@@ -217,33 +200,6 @@ jobs:
217200
cd dist/
218201
pip install wheel
219202
for f in *.whl; do pip install $f || true; done
220-
- name: Install apache-arrow on ubuntu
221-
if: ${{ matrix.from-source && matrix.os == 'ubuntu-latest' }}
222-
run: |
223-
sudo apt update
224-
sudo apt install -y -V ca-certificates lsb-release wget
225-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
226-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
227-
sudo apt update
228-
sudo apt install -y -V libarrow-dev
229-
- name: Install apache-arrow on macos
230-
if: ${{ matrix.from-source && matrix.os == 'macos-10.15' && matrix.python-version != '3.10' }}
231-
run: |
232-
brew install apache-arrow
233-
brew install pkg-config
234-
- name: Install dist with go
235-
if: ${{ matrix.from-source && (matrix.python-version != '3.10' || matrix.os == 'ubuntu-latest')}}
236-
env:
237-
COMPILE_GO: "True"
238-
run: |
239-
pip install 'grpcio-tools==1.47.0' 'pybindgen==0.22.0'
240-
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26.0
241-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0
242-
pip install dist/*tar.gz
243-
# py3.10 on MacOS does not work with Go so we have to install separately. Issue is tracked here: https://github.com/feast-dev/feast/issues/2881
244-
- name: Install dist w/o go
245-
if: ${{ matrix.from-source && matrix.python-version == '3.10' && matrix.os == 'macos-10.15'}}
246-
run: pip install dist/*tar.gz
247203
- name: Install OS X dependencies
248204
if: matrix.os == 'macos-10.15'
249205
run: brew install coreutils
@@ -269,13 +225,3 @@ jobs:
269225
echo "$TEST_SCRIPT" > run-and-wait.sh
270226
bash run-and-wait.sh feast serve
271227
bash run-and-wait.sh feast ui
272-
# We disable this test for the Python 3.10 binary since it does not include Go.
273-
- name: Smoke test with go
274-
if: matrix.python-version != '3.10' || matrix.os == 'ubuntu-latest'
275-
run: |
276-
cd test_repo/feature_repo
277-
feast apply
278-
echo "$TEST_SCRIPT" > run-and-wait.sh
279-
pip install cffi
280-
printf "\ngo_feature_serving: True" >> feature_store.yaml
281-
bash run-and-wait.sh feast serve

‎.github/workflows/java_master_only.yml

+1-13
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ jobs:
112112
with:
113113
python-version: 3.8
114114
architecture: x64
115-
- name: Setup Go
116-
id: setup-go
117-
uses: actions/setup-go@v2
118-
with:
119-
go-version: 1.18.0
120115
- name: Upgrade pip version
121116
run: |
122117
pip install --upgrade pip
@@ -136,14 +131,7 @@ jobs:
136131
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
137132
- name: Install pip-tools
138133
run: pip install pip-tools
139-
- name: Install apache-arrow on ubuntu
140-
run: |
141-
sudo apt update
142-
sudo apt install -y -V ca-certificates lsb-release wget
143-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
144-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
145-
sudo apt update
146-
sudo apt install -y -V libarrow-dev
134+
147135
- name: Install Python dependencies
148136
run: make install-python-ci-dependencies
149137
- uses: actions/cache@v2

‎.github/workflows/java_pr.yml

-13
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ jobs:
148148
with:
149149
python-version: 3.8
150150
architecture: x64
151-
- name: Setup Go
152-
id: setup-go
153-
uses: actions/setup-go@v2
154-
with:
155-
go-version: 1.18.0
156151
- name: Upgrade pip version
157152
run: |
158153
pip install --upgrade pip
@@ -172,14 +167,6 @@ jobs:
172167
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
173168
- name: Install pip-tools
174169
run: pip install pip-tools
175-
- name: Install apache-arrow on ubuntu
176-
run: |
177-
sudo apt update
178-
sudo apt install -y -V ca-certificates lsb-release wget
179-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
180-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
181-
sudo apt update
182-
sudo apt install -y -V libarrow-dev
183170
- name: Install Python dependencies
184171
run: make install-python-ci-dependencies
185172
- name: Run integration tests

‎.github/workflows/linter.yml

-42
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ jobs:
1515
with:
1616
python-version: "3.8"
1717
architecture: x64
18-
- name: Setup Go
19-
id: setup-go
20-
uses: actions/setup-go@v2
21-
with:
22-
go-version: 1.18.0
2318
- name: Upgrade pip version
2419
run: |
2520
pip install --upgrade pip
@@ -39,45 +34,8 @@ jobs:
3934
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
4035
- name: Install pip-tools
4136
run: pip install pip-tools
42-
- name: Install apache-arrow on ubuntu
43-
run: |
44-
sudo apt update
45-
sudo apt install -y -V ca-certificates lsb-release wget
46-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
47-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
48-
sudo apt update
49-
sudo apt install -y -V libarrow-dev
5037
- name: Install dependencies
5138
run: |
52-
make compile-protos-go
5339
make install-python-ci-dependencies
5440
- name: Lint python
5541
run: make lint-python
56-
57-
lint-go:
58-
runs-on: ubuntu-latest
59-
steps:
60-
- uses: actions/checkout@v2
61-
- name: Setup Go
62-
id: setup-go
63-
uses: actions/setup-go@v2
64-
with:
65-
go-version: 1.18.0
66-
- name: Setup Python
67-
id: setup-python
68-
uses: actions/setup-python@v2
69-
with:
70-
python-version: "3.8"
71-
- name: Upgrade pip version
72-
run: |
73-
pip install --upgrade pip
74-
- name: Install apache-arrow on ubuntu
75-
run: |
76-
sudo apt update
77-
sudo apt install -y -V ca-certificates lsb-release wget
78-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
79-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
80-
sudo apt update
81-
sudo apt install -y -V libarrow-dev
82-
- name: Lint go
83-
run: make lint-go

‎.github/workflows/master_only.yml

+1-21
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ jobs:
5858
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ steps.image-tag.outputs.DOCKER_IMAGE_TAG }}
5959
outputs:
6060
DOCKER_IMAGE_TAG: ${{ steps.image-tag.outputs.DOCKER_IMAGE_TAG }}
61-
integration-test-python-and-go:
61+
integration-test-python:
6262
if: github.repository == 'feast-dev/feast'
6363
needs: build-lambda-docker-image
6464
runs-on: ${{ matrix.os }}
6565
strategy:
6666
fail-fast: false
6767
matrix:
6868
python-version: [ "3.8", "3.9", "3.10" ]
69-
go-version: [ 1.17.0 ]
7069
os: [ ubuntu-latest ]
7170
env:
7271
OS: ${{ matrix.os }}
@@ -89,11 +88,6 @@ jobs:
8988
with:
9089
python-version: ${{ matrix.python-version }}
9190
architecture: x64
92-
- name: Setup Go
93-
id: setup-go
94-
uses: actions/setup-go@v2
95-
with:
96-
go-version: ${{ matrix.go-version }}
9791
- name: Authenticate to Google Cloud
9892
uses: 'google-github-actions/auth@v1'
9993
with:
@@ -131,20 +125,6 @@ jobs:
131125
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
132126
- name: Install pip-tools
133127
run: pip install pip-tools
134-
- name: Install apache-arrow on ubuntu
135-
if: matrix.os == 'ubuntu-latest'
136-
run: |
137-
sudo apt update
138-
sudo apt install -y -V ca-certificates lsb-release wget
139-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
140-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
141-
sudo apt update
142-
sudo apt install -y -V libarrow-dev
143-
- name: Install apache-arrow on macos
144-
if: matrix.os == 'macOS-latest'
145-
run: |
146-
brew install apache-arrow
147-
brew install pkg-config
148128
- name: Install dependencies
149129
run: make install-python-ci-dependencies
150130
- name: Setup Redis Cluster

‎.github/workflows/pr_integration_tests.yml

-19
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ jobs:
115115
with:
116116
python-version: ${{ matrix.python-version }}
117117
architecture: x64
118-
- name: Setup Go
119-
id: setup-go
120-
uses: actions/setup-go@v2
121-
with:
122-
go-version: 1.18.0
123118
- name: Authenticate to Google Cloud
124119
uses: 'google-github-actions/auth@v1'
125120
with:
@@ -157,20 +152,6 @@ jobs:
157152
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
158153
- name: Install pip-tools
159154
run: pip install pip-tools
160-
- name: Install apache-arrow on ubuntu
161-
if: matrix.os == 'ubuntu-latest'
162-
run: |
163-
sudo apt update
164-
sudo apt install -y -V ca-certificates lsb-release wget
165-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
166-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
167-
sudo apt update
168-
sudo apt install -y -V libarrow-dev
169-
- name: Install apache-arrow on macos
170-
if: matrix.os == 'macOS-latest'
171-
run: |
172-
brew install apache-arrow
173-
brew install pkg-config
174155
- name: Install dependencies
175156
run: make install-python-ci-dependencies
176157
- name: Setup Redis Cluster

‎.github/workflows/pr_local_integration_tests.yml

-9
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ jobs:
5757
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
5858
- name: Install pip-tools
5959
run: pip install pip-tools
60-
- name: Install apache-arrow on ubuntu
61-
if: matrix.os == 'ubuntu-latest'
62-
run: |
63-
sudo apt update
64-
sudo apt install -y -V ca-certificates lsb-release wget
65-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
66-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
67-
sudo apt update
68-
sudo apt install -y -V libarrow-dev
6960
- name: Install dependencies
7061
run: make install-python-ci-dependencies
7162
- name: Test local integration tests

‎.github/workflows/unit_tests.yml

-47
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ jobs:
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727
architecture: x64
28-
- name: Setup Go
29-
id: setup-go
30-
uses: actions/setup-go@v2
31-
with:
32-
go-version: 1.18.0
3328
- name: Install mysql on macOS
3429
if: startsWith(matrix.os, 'macOS')
3530
run: |
@@ -54,53 +49,11 @@ jobs:
5449
${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-pip-
5550
- name: Install pip-tools
5651
run: pip install pip-tools
57-
- name: Install apache-arrow on ubuntu
58-
if: matrix.os == 'ubuntu-latest'
59-
run: |
60-
sudo apt update
61-
sudo apt install -y -V ca-certificates lsb-release wget
62-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
63-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
64-
sudo apt update
65-
sudo apt install -y -V libarrow-dev
66-
- name: Install apache-arrow on macos
67-
if: matrix.os == 'macOS-latest'
68-
run: |
69-
brew install apache-arrow
70-
brew install pkg-config
7152
- name: Install dependencies
7253
run: make install-python-ci-dependencies
7354
- name: Test Python
7455
run: pytest -n 8 --cov=./ --cov-report=xml --color=yes sdk/python/tests
7556

76-
unit-test-go:
77-
runs-on: ubuntu-latest
78-
steps:
79-
- uses: actions/checkout@v2
80-
- name: Setup Python
81-
id: setup-python
82-
uses: actions/setup-python@v2
83-
with:
84-
python-version: "3.8"
85-
- name: Upgrade pip version
86-
run: |
87-
pip install --upgrade "pip>=22.1,<23"
88-
- name: Setup Go
89-
id: setup-go
90-
uses: actions/setup-go@v2
91-
with:
92-
go-version: 1.18.0
93-
- name: Install apache-arrow on ubuntu
94-
run: |
95-
sudo apt update
96-
sudo apt install -y -V ca-certificates lsb-release wget
97-
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
98-
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
99-
sudo apt update
100-
sudo apt install -y -V libarrow-dev
101-
sudo apt install -y -V pkg-config
102-
- name: Test
103-
run: make test-go
10457

10558
unit-test-ui:
10659
runs-on: ubuntu-latest

‎Makefile

+6-42
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ TRINO_VERSION ?= 376
2424

2525
# General
2626

27-
format: format-python format-java format-go
27+
format: format-python format-java
2828

29-
lint: lint-python lint-java lint-go
29+
lint: lint-python lint-java
3030

31-
test: test-python test-java test-go
31+
test: test-python test-java
3232

33-
protos: compile-protos-go compile-protos-python compile-protos-docs
33+
protos: compile-protos-python compile-protos-docs
3434

3535
build: protos build-java build-docker
3636

3737
# Python SDK
3838

39-
install-python-ci-dependencies: install-go-proto-dependencies install-go-ci-dependencies
39+
install-python-ci-dependencies:
4040
python -m piptools sync sdk/python/requirements/py$(PYTHON)-ci-requirements.txt
4141
COMPILE_GO=true python setup.py develop
4242

@@ -281,9 +281,6 @@ test-python-universal-cassandra-no-cloud-providers:
281281
test-python-universal:
282282
FEAST_USAGE=False IS_TEST=True python -m pytest -n 8 --integration sdk/python/tests
283283

284-
test-python-go-server: compile-go-lib
285-
FEAST_USAGE=False IS_TEST=True pytest --integration --goserver sdk/python/tests
286-
287284
format-python:
288285
# Sort
289286
cd ${ROOT_DIR}/sdk/python; python -m isort feast/ tests/
@@ -334,48 +331,15 @@ test-trino-plugin-locally:
334331
kill-trino-locally:
335332
cd ${ROOT_DIR}; docker stop trino
336333

337-
# Go SDK & embedded
338-
339-
install-go-proto-dependencies:
340-
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26.0
341-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0
342-
343-
install-go-ci-dependencies:
344-
# TODO: currently gopy installation doesn't work w/o explicit go get in the next line
345-
# TODO: there should be a better way to install gopy
346-
go get github.com/go-python/gopy@v0.4.4
347-
go install golang.org/x/tools/cmd/goimports
348-
# The `go get` command on the previous lines download the lib along with replacing the dep to `feast-dev/gopy`
349-
# but the following command is needed to install it for some reason.
350-
go install github.com/go-python/gopy
351-
python -m pip install pybindgen==0.22.0 protobuf==3.20.1
352-
353334
install-protoc-dependencies:
354335
pip install --ignore-installed protobuf grpcio-tools==1.47.0 mypy-protobuf==3.1.0
355336

356-
compile-protos-go: install-go-proto-dependencies install-protoc-dependencies
357-
python setup.py build_go_protos
358-
359-
compile-go-lib: install-go-proto-dependencies install-go-ci-dependencies
360-
CGO_LDFLAGS_ALLOW=".*" COMPILE_GO=True python setup.py build_ext --inplace
361-
362337
install-feast-ci-locally:
363338
pip install -e ".[ci]"
364339

365-
# Needs feast package to setup the feature store
366-
# CGO flag is due to this issue: https://github.com/golang/go/wiki/InvalidFlag
367-
test-go: compile-protos-go compile-protos-python compile-go-lib install-feast-ci-locally
368-
CGO_LDFLAGS_ALLOW=".*" go test -tags cgo,ccalloc ./...
369-
370-
format-go:
371-
gofmt -s -w go/
372-
373-
lint-go: compile-protos-go compile-go-lib
374-
go vet -tags cgo,ccalloc ./go/internal/feast ./go/embedded
375-
376340
# Docker
377341

378-
build-docker: build-feature-server-python-docker build-feature-server-python-aws-docker build-feature-transformation-server-docker build-feature-server-java-docker
342+
build-docker: build-feature-server-python-aws-docker build-feature-transformation-server-docker build-feature-server-java-docker
379343

380344
push-ci-docker:
381345
docker push $(REGISTRY)/feast-ci:$(VERSION)

‎sdk/python/feast/infra/materialization/contrib/bytewax/bytewax_materialization_engine.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class BytewaxMaterializationEngineConfig(FeastConfigBaseModel):
5858
annotations: dict = {}
5959
""" (optional) Annotations to apply to the job container. Useful for linking the service account to IAM roles, operational metadata, etc """
6060

61+
6162
class BytewaxMaterializationEngine(BatchMaterializationEngine):
6263
def __init__(
6364
self,
@@ -350,7 +351,7 @@ def _create_job_definition(self, job_id, namespace, pods, env):
350351
"name": f"feast-{job_id}",
351352
},
352353
],
353-
}
354+
},
354355
},
355356
},
356357
}

‎sdk/python/tests/integration/e2e/test_go_feature_server.py

-263
This file was deleted.

‎setup.py

-183
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@
129129

130130
GE_REQUIRED = ["great_expectations>=0.15.41,<0.16.0"]
131131

132-
GO_REQUIRED = [
133-
"cffi~=1.15.0",
134-
]
135-
136132
AZURE_REQUIRED = [
137133
"azure-storage-blob>=0.37.0",
138134
"azure-identity>=1.6.1",
@@ -316,93 +312,12 @@ def run(self):
316312
file.write(filedata)
317313

318314

319-
def _generate_path_with_gopath():
320-
go_path = subprocess.check_output(["go", "env", "GOPATH"]).decode("utf-8")
321-
go_path = go_path.strip()
322-
path_val = os.getenv("PATH")
323-
path_val = f"{path_val}:{go_path}/bin"
324-
325-
return path_val
326-
327-
328-
def _ensure_go_and_proto_toolchain():
329-
try:
330-
version = subprocess.check_output(["go", "version"])
331-
except Exception as e:
332-
raise RuntimeError("Unable to find go toolchain") from e
333-
334-
semver_string = re.search(r"go[\S]+", str(version)).group().lstrip("go")
335-
parts = semver_string.split(".")
336-
if not (int(parts[0]) >= 1 and int(parts[1]) >= 16):
337-
raise RuntimeError(f"Go compiler too old; expected 1.16+ found {semver_string}")
338-
339-
path_val = _generate_path_with_gopath()
340-
341-
try:
342-
subprocess.check_call(["protoc-gen-go", "--version"], env={"PATH": path_val})
343-
subprocess.check_call(
344-
["protoc-gen-go-grpc", "--version"], env={"PATH": path_val}
345-
)
346-
except Exception as e:
347-
raise RuntimeError("Unable to find go/grpc extensions for protoc") from e
348-
349-
350-
class BuildGoProtosCommand(Command):
351-
description = "Builds the proto files into Go files."
352-
user_options = []
353-
354-
def initialize_options(self):
355-
self.go_protoc = [
356-
sys.executable,
357-
"-m",
358-
"grpc_tools.protoc",
359-
] # find_executable("protoc")
360-
self.proto_folder = os.path.join(repo_root, "protos")
361-
self.go_folder = os.path.join(repo_root, "go/protos")
362-
self.sub_folders = PROTO_SUBDIRS
363-
self.path_val = _generate_path_with_gopath()
364-
365-
def finalize_options(self):
366-
pass
367-
368-
def _generate_go_protos(self, path: str):
369-
proto_files = glob.glob(os.path.join(self.proto_folder, path))
370-
371-
try:
372-
subprocess.check_call(
373-
self.go_protoc
374-
+ [
375-
"-I",
376-
self.proto_folder,
377-
"--go_out",
378-
self.go_folder,
379-
"--go_opt=module=github.com/feast-dev/feast/go/protos",
380-
"--go-grpc_out",
381-
self.go_folder,
382-
"--go-grpc_opt=module=github.com/feast-dev/feast/go/protos",
383-
]
384-
+ proto_files,
385-
env={"PATH": self.path_val},
386-
)
387-
except CalledProcessError as e:
388-
print(f"Stderr: {e.stderr}")
389-
print(f"Stdout: {e.stdout}")
390-
391-
def run(self):
392-
go_dir = Path(repo_root) / "go" / "protos"
393-
go_dir.mkdir(exist_ok=True)
394-
for sub_folder in self.sub_folders:
395-
self._generate_go_protos(f"feast/{sub_folder}/*.proto")
396-
397315

398316
class BuildCommand(build_py):
399317
"""Custom build command."""
400318

401319
def run(self):
402320
self.run_command("build_python_protos")
403-
if os.getenv("COMPILE_GO", "false").lower() == "true":
404-
_ensure_go_and_proto_toolchain()
405-
self.run_command("build_go_protos")
406321

407322
self.run_command("build_ext")
408323
build_py.run(self)
@@ -414,99 +329,10 @@ class DevelopCommand(develop):
414329
def run(self):
415330
self.reinitialize_command("build_python_protos", inplace=1)
416331
self.run_command("build_python_protos")
417-
if os.getenv("COMPILE_GO", "false").lower() == "true":
418-
_ensure_go_and_proto_toolchain()
419-
self.run_command("build_go_protos")
420332

421333
develop.run(self)
422334

423335

424-
class build_ext(_build_ext):
425-
def finalize_options(self) -> None:
426-
super().finalize_options()
427-
if os.getenv("COMPILE_GO", "false").lower() == "false":
428-
self.extensions = [e for e in self.extensions if not self._is_go_ext(e)]
429-
430-
def _is_go_ext(self, ext: Extension):
431-
return any(
432-
source.endswith(".go") or source.startswith("github")
433-
for source in ext.sources
434-
)
435-
436-
def build_extension(self, ext: Extension):
437-
print(f"Building extension {ext}")
438-
if not self._is_go_ext(ext):
439-
# the base class may mutate `self.compiler`
440-
compiler = copy.deepcopy(self.compiler)
441-
self.compiler, compiler = compiler, self.compiler
442-
try:
443-
return _build_ext.build_extension(self, ext)
444-
finally:
445-
self.compiler, compiler = compiler, self.compiler
446-
447-
bin_path = _generate_path_with_gopath()
448-
go_env = json.loads(
449-
subprocess.check_output(["go", "env", "-json"]).decode("utf-8").strip()
450-
)
451-
452-
print(f"Go env: {go_env}")
453-
print(f"CWD: {os.getcwd()}")
454-
455-
destination = os.path.dirname(os.path.abspath(self.get_ext_fullpath(ext.name)))
456-
subprocess.check_call(
457-
["go", "install", "golang.org/x/tools/cmd/goimports"],
458-
env={"PATH": bin_path, **go_env},
459-
)
460-
subprocess.check_call(
461-
["go", "get", "github.com/go-python/gopy@v0.4.4"],
462-
env={"PATH": bin_path, **go_env},
463-
)
464-
subprocess.check_call(
465-
["go", "install", "github.com/go-python/gopy"],
466-
env={"PATH": bin_path, **go_env},
467-
)
468-
subprocess.check_call(
469-
[
470-
"gopy",
471-
"build",
472-
"-output",
473-
destination,
474-
"-vm",
475-
sys.executable,
476-
"--build-tags",
477-
"cgo,ccalloc",
478-
"--dynamic-link=True",
479-
"-no-make",
480-
*ext.sources,
481-
],
482-
env={
483-
"PATH": bin_path,
484-
"CGO_LDFLAGS_ALLOW": ".*",
485-
**go_env,
486-
},
487-
)
488-
489-
def copy_extensions_to_source(self):
490-
build_py = self.get_finalized_command("build_py")
491-
for ext in self.extensions:
492-
fullname = self.get_ext_fullname(ext.name)
493-
modpath = fullname.split(".")
494-
package = ".".join(modpath[:-1])
495-
package_dir = build_py.get_package_dir(package)
496-
497-
src_dir = dest_dir = package_dir
498-
499-
if src_dir.startswith(PYTHON_CODE_PREFIX):
500-
src_dir = package_dir[len(PYTHON_CODE_PREFIX) :]
501-
src_dir = src_dir.lstrip("/")
502-
503-
src_dir = os.path.join(self.build_lib, src_dir)
504-
505-
# copy whole directory
506-
print(f"Copying from {src_dir} to {dest_dir}")
507-
copy_tree(src_dir, dest_dir)
508-
509-
510336
setup(
511337
name=NAME,
512338
author=AUTHOR,
@@ -537,7 +363,6 @@ def copy_extensions_to_source(self):
537363
"mysql": MYSQL_REQUIRED,
538364
"ge": GE_REQUIRED,
539365
"hbase": HBASE_REQUIRED,
540-
"go": GO_REQUIRED,
541366
"docs": DOCS_REQUIRED,
542367
"cassandra": CASSANDRA_REQUIRED,
543368
},
@@ -562,15 +387,7 @@ def copy_extensions_to_source(self):
562387
],
563388
cmdclass={
564389
"build_python_protos": BuildPythonProtosCommand,
565-
"build_go_protos": BuildGoProtosCommand,
566390
"build_py": BuildCommand,
567391
"develop": DevelopCommand,
568-
"build_ext": build_ext,
569392
},
570-
ext_modules=[
571-
Extension(
572-
"feast.embedded_go.lib._embedded",
573-
["github.com/feast-dev/feast/go/embedded"],
574-
)
575-
],
576393
)

0 commit comments

Comments
 (0)
Please sign in to comment.