Skip to content

Commit 6f72a00

Browse files
Merge pull request kubeflow#45 from kubeflow/main
[pull] main from kubeflow:main
2 parents a1ee20b + 5f7fac0 commit 6f72a00

File tree

8 files changed

+71
-38
lines changed

8 files changed

+71
-38
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
include

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ log.html
3434
output.xml
3535
report.html
3636
__pycache__
37+
38+
# Protoc files
39+
include/
40+
readme.txt

Dockerfile

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,19 @@ RUN yum install -y nodejs npm java-11
1919
# Copy the go source
2020
COPY ["Makefile", "main.go", ".openapi-generator-ignore", "openapitools.json", "./"]
2121

22-
# Download protoc compiler v24.3
23-
RUN wget -q https://github.com/protocolbuffers/protobuf/releases/download/v24.3/protoc-24.3-linux-x86_64.zip -O protoc.zip && \
24-
unzip -q protoc.zip && \
25-
bin/protoc --version && \
26-
rm protoc.zip
27-
28-
# Download tools
29-
RUN make deps
30-
3122
# Copy rest of the source
32-
COPY bin/ bin/
23+
COPY .git/ .git/
3324
COPY cmd/ cmd/
3425
COPY api/ api/
3526
COPY internal/ internal/
36-
COPY pkg/ pkg/
3727
COPY scripts/ scripts/
28+
COPY pkg/ pkg/
3829
COPY patches/ patches/
3930
COPY templates/ templates/
4031

32+
# Download tools
33+
RUN make deps
34+
4135
# Build
4236
USER root
4337
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean model-registry

Makefile

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
33
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
44
PROJECT_BIN := $(PROJECT_PATH)/bin
5+
GO := $(PROJECT_BIN)/go1.19
56

67
# add tools bin directory
78
PATH := $(PROJECT_BIN):$(PATH)
@@ -56,7 +57,7 @@ api/grpc/ml_metadata/proto/metadata_store_service.proto:
5657
sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_store_service.proto
5758

5859
internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto
59-
protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \
60+
bin/protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \
6061
--go-grpc_out=./internal --go-grpc_opt=paths=source_relative $<
6162

6263
.PHONY: gen/grpc
@@ -76,8 +77,8 @@ openapi/validate: bin/openapi-generator-cli
7677
# generate the openapi server implementation
7778
.PHONY: gen/openapi-server
7879
gen/openapi-server: bin/openapi-generator-cli openapi/validate
79-
@if git diff --cached --name-only | grep -q "api/openapi/model-registry.yaml" || \
80-
git diff --name-only | grep -q "api/openapi/model-registry.yaml" || \
80+
@if git diff --exit-code --name-only | grep -q "api/openapi/model-registry.yaml" || \
81+
git diff --exit-code --name-only | grep -q "api/openapi/model-registry.yaml" || \
8182
[ -n "${FORCE_SERVER_GENERATION}" ]; then \
8283
ROOT_FOLDER="." ./scripts/gen_openapi_server.sh; \
8384
else \
@@ -97,7 +98,7 @@ pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml
9798

9899
.PHONY: vet
99100
vet:
100-
go vet ./...
101+
${GO} vet ./...
101102

102103
.PHONY: clean
103104
clean:
@@ -107,22 +108,29 @@ clean:
107108
clean/odh:
108109
rm -Rf ./model-registry
109110

111+
bin/go:
112+
GOBIN=$(PROJECT_BIN) go install golang.org/dl/go1.19@latest
113+
$(PROJECT_BIN)/go1.19 download
114+
115+
bin/protoc:
116+
./scripts/install_protoc.sh
117+
110118
bin/go-enum:
111-
GOBIN=$(PROJECT_BIN) go install github.com/searKing/golang/tools/[email protected]
119+
GOBIN=$(PROJECT_BIN) ${GO} install github.com/searKing/golang/tools/[email protected]
112120

113121
bin/protoc-gen-go:
114-
GOBIN=$(PROJECT_BIN) go install google.golang.org/protobuf/cmd/[email protected]
122+
GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/protobuf/cmd/[email protected]
115123

116124
bin/protoc-gen-go-grpc:
117-
GOBIN=$(PROJECT_BIN) go install google.golang.org/grpc/cmd/[email protected]
125+
GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/grpc/cmd/[email protected]
118126

119127
GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint
120128
bin/golangci-lint:
121129
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.54.2
122130

123131
GOVERTER ?= ${PROJECT_BIN}/goverter
124132
bin/goverter:
125-
GOBIN=$(PROJECT_PATH)/bin go install github.com/jmattheis/goverter/cmd/[email protected]
133+
GOBIN=$(PROJECT_PATH)/bin ${GO} install github.com/jmattheis/goverter/cmd/[email protected]
126134

127135
OPENAPI_GENERATOR ?= ${PROJECT_BIN}/openapi-generator-cli
128136
NPM ?= "$(shell which npm)"
@@ -147,23 +155,23 @@ clean/deps:
147155
rm -Rf bin/*
148156

149157
.PHONY: deps
150-
deps: bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli
158+
deps: bin/go bin/protoc bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli
151159

152160
.PHONY: vendor
153161
vendor:
154-
go mod vendor
162+
${GO} mod vendor
155163

156164
.PHONY: build
157165
build: gen vet lint
158-
go build
166+
${GO} build -buildvcs=false
159167

160168
.PHONY: build/odh
161169
build/odh: vet
162-
go build
170+
${GO} build -buildvcs=false
163171

164172
.PHONY: gen
165173
gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter
166-
go generate ./...
174+
${GO} generate ./...
167175

168176
.PHONY: lint
169177
lint:
@@ -172,20 +180,20 @@ lint:
172180

173181
.PHONY: test
174182
test: gen
175-
go test ./internal/... ./pkg/...
183+
${GO} test ./internal/... ./pkg/...
176184

177185
.PHONY: test-nocache
178186
test-nocache: gen
179-
go test ./internal/... ./pkg/... -count=1
187+
${GO} test ./internal/... ./pkg/... -count=1
180188

181189
.PHONY: test-cover
182190
test-cover: gen
183-
go test ./internal/... ./pkg/... -coverprofile=coverage.txt
184-
go tool cover -html=coverage.txt -o coverage.html
191+
${GO} test ./internal/... ./pkg/... -coverprofile=coverage.txt
192+
${GO} tool cover -html=coverage.txt -o coverage.html
185193

186194
.PHONY: run/proxy
187195
run/proxy: gen
188-
go run main.go proxy --logtostderr=true
196+
${GO} run main.go proxy --logtostderr=true
189197

190198
.PHONY: proxy
191199
proxy: build

clients/python/poetry.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose-local.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22
services:
33
mlmd-server:
44
image: gcr.io/tfx-oss-public/ml_metadata_store_server:1.14.0
@@ -13,8 +13,9 @@ services:
1313
build:
1414
context: .
1515
dockerfile: Dockerfile
16-
command: ["proxy", "--mlmd-hostname", "localhost", "--mlmd-port", "9090"]
16+
command: ["proxy", "--hostname", "0.0.0.0", "--mlmd-hostname", "mlmd-server", "--mlmd-port", "8080"]
1717
container_name: model-registry
18-
network_mode: host
18+
ports:
19+
- "8080:8080"
1920
depends_on:
2021
- mlmd-server

docker-compose.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ services:
1111
- ./test/config/ml-metadata:/tmp/shared
1212
model-registry:
1313
image: quay.io/opendatahub/model-registry:latest
14-
command: ["proxy", "--mlmd-hostname", "localhost", "--mlmd-port", "9090"]
14+
command: ["proxy", "--hostname", "0.0.0.0", "--mlmd-hostname", "mlmd-server", "--mlmd-port", "8080"]
1515
container_name: model-registry
16-
network_mode: host
16+
ports:
17+
- "8080:8080"
1718
depends_on:
1819
- mlmd-server

scripts/install_protoc.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /bin/bash
2+
set -euxo pipefail
3+
4+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
6+
VERSION="24.3"
7+
OS="linux"
8+
if [[ "$OSTYPE" == "darwin"* ]]; then
9+
# Mac OSX
10+
OS="osx"
11+
fi
12+
ARCH="x86_64"
13+
if [[ "$(uname -m)" == "arm"* ]]; then
14+
ARCH="aarch_64"
15+
fi
16+
17+
mkdir -p ${SCRIPT_DIR}/../bin
18+
19+
wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-${OS}-${ARCH}.zip -O ${SCRIPT_DIR}/../protoc.zip && \
20+
unzip -qo ${SCRIPT_DIR}/../protoc.zip -d ${SCRIPT_DIR}/.. && \
21+
bin/protoc --version && \
22+
rm ${SCRIPT_DIR}/../protoc.zip

0 commit comments

Comments
 (0)