-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - chore(backend): remove bazel from backend code generation #5115
Closed
Closed
Changes from 38 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
e93f6d4
updated to remove bazel
NikeNano e17a96b
rename@
NikeNano bbb2b8d
script to run in container
NikeNano 9696224
update the generation
NikeNano 7c98945
updated docker image
NikeNano 3c2179f
changed name
NikeNano 8696f8b
updated the code
NikeNano e04d852
regenerated API
NikeNano 84e18f5
fix env variables
NikeNano 2bd56c4
updated version of go swagger
NikeNano a79d7d6
rerun generate with updated package
NikeNano dda0445
added healthz
NikeNano 6e2fc06
typo with folders fixed
NikeNano b599ce6
changed version
NikeNano 8e94d8f
set version of protoc compiler
NikeNano a8afe58
test if version is correct
NikeNano b57406c
test version
NikeNano c1be66d
changed version
NikeNano 99fa74b
updated version agian
NikeNano eafd36c
test version
NikeNano 280ac94
the latest test
NikeNano 1c55741
updated docker image
NikeNano c6dd5fb
fixed some stuff
NikeNano 6d69b7f
new test
NikeNano 86ed6b0
tested other version
NikeNano bc96ab1
new tests
NikeNano 37150ca
changed swagger
NikeNano 21de412
new test
NikeNano 4ccb894
updated versions
NikeNano a1532b3
missed docker file
NikeNano a0a01fe
updated files@
NikeNano 644701a
change back
NikeNano 588d320
updated after feedback@
NikeNano 643a8ca
clean up
NikeNano b2280df
Merge branch 'master' into nikenano/GenerateAPIRemoveBazel
Bobgy 32defa9
chore(backend): tidy go.mod and update tools.go
Bobgy 3405b69
go install, instead of go get
Bobgy ec3abc1
fix problems reported by go vet
Bobgy 0b99bed
simplify some ide reported redundant syntax
Bobgy e0925a0
license is not required for generated code
Bobgy b220f93
remove licenses for generated code
Bobgy 92a0d54
cleanup
Bobgy 383851a
remove license more
Bobgy 79d574b
Merge remote-tracking branch 'upstream/master' into bazel-cleanup
Bobgy ec313eb
Merge remote-tracking branch 'upstream/master' into rm-bazel-gen-api
Bobgy 72695fa
fix problems
Bobgy 3725626
regenerate all go clients
Bobgy 80bb1ea
Merge remote-tracking branch 'upstream/master' into bazel-cleanup
Bobgy ec1d7b8
rm unused BUILD.bazel files
Bobgy 50cb605
fixed generate_api.sh
Bobgy d691d8c
reimport error.proto
Bobgy c91d47d
Merge branch 'bazel-cleanup' into rm-bazel-gen-api
Bobgy e3b33ee
no longer use protobuffers repo
Bobgy 64400ed
update version
Bobgy 1e7a338
wip
Bobgy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 0. Generate client code (go & json) from API protocol buffers | ||
FROM golang:1.13.1-stretch as generator | ||
ENV KFP_VERSION 1.0.0 | ||
ENV GRPC_GATEWAY_VERSION v1.9.0 | ||
ENV GO_SWAGGER_VERSION v0.18.0 | ||
ENV GOLANG_PROTOBUF_VERSION v1.3.2 | ||
ENV PROTOCOLBUFFERS_PROTOBUF_VERSION v3.11.3 | ||
ENV GRPC_VERSION v1.23.0 | ||
|
||
# Install protoc. | ||
RUN apt-get update -y && apt-get install -y jq sed unzip | ||
ENV PROTOC_ZIP=protoc-3.13.0-linux-x86_64.zip | ||
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/$PROTOC_ZIP | ||
RUN unzip -o $PROTOC_ZIP -d /usr/ bin/protoc | ||
RUN unzip -o $PROTOC_ZIP -d /usr/ 'include/*' | ||
RUN rm -f $PROTOC_ZIP | ||
ENV PROTOCCOMPILER /usr/bin/protoc | ||
ENV PROTOCINCLUDE /usr/include/google/protobuf | ||
|
||
# Need grpc-gateway source code for -I in protoc command. | ||
WORKDIR /go/src/github.com | ||
RUN mkdir grpc-ecosystem && cd grpc-ecosystem && git clone --depth 1 --branch $GRPC_GATEWAY_VERSION https://github.com/grpc-ecosystem/grpc-gateway.git | ||
RUN mkdir grpc && git clone --depth 1 --branch $GRPC_VERSION https://github.com/grpc/grpc-go | ||
|
||
# Install protoc-gen-rpc-gateway && protoc-gen-swagger. | ||
RUN cd grpc-ecosystem/grpc-gateway && GO111MODULE=on go mod vendor | ||
RUN GOBIN=/go/bin go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway | ||
RUN GOBIN=/go/bin go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger | ||
|
||
# Download go-swagger binary. | ||
RUN curl -LO "https://github.com/go-swagger/go-swagger/releases/download/${GO_SWAGGER_VERSION}/swagger_linux_amd64" | ||
RUN chmod +x swagger_linux_amd64 && mv swagger_linux_amd64 /usr/bin/swagger | ||
|
||
# Need protobuf source code for -I in protoc command. | ||
RUN mkdir golang && cd golang && git clone --depth 1 --branch $GOLANG_PROTOBUF_VERSION https://github.com/golang/protobuf.git | ||
# Install protoc-gen-go. | ||
RUN cd golang/protobuf && GO111MODULE=on go mod vendor | ||
RUN GOBIN=/go/bin go install github.com/golang/protobuf/protoc-gen-go | ||
|
||
# Need protobuffers/protobuf source code for -I in proto command. | ||
RUN mkdir protocolbuffers && cd protocolbuffers && git clone --depth 1 --branch $PROTOCOLBUFFERS_PROTOBUF_VERSION https://github.com/protocolbuffers/protobuf.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2018-2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -ex | ||
|
||
export TMP_OUTPUT=/tmp | ||
|
||
# Change directory\ | ||
cd /go/src/github.com/kubeflow/pipelines | ||
# Delete currently generated code. | ||
rm -r -f backend/api/go_http_client/* | ||
rm -f -f backend/api/go_client/* | ||
|
||
# Generate *.pb.go (grpc api client) from *.proto . | ||
${PROTOCCOMPILER} -I. -Ibackend/api \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/ \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/ \ | ||
-I/usr/include/ \ | ||
--plugin=protoc-gen-go=/go/bin/protoc-gen-go \ | ||
--go_out=plugins=grpc:${TMP_OUTPUT} \ | ||
backend/api/*.proto | ||
# Generate *.pb.gw.go (grpc api rest client) from *.proto. | ||
${PROTOCCOMPILER} -I. -Ibackend/api \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/ \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/ \ | ||
-I/usr/include/ \ | ||
--plugin=protoc-gen-grpc-gateway=/go/bin/protoc-gen-grpc-gateway \ | ||
--grpc-gateway_out=logtostderr=true:${TMP_OUTPUT} \ | ||
backend/api/*.proto | ||
# Move *.pb.go and *.gw.go to go_client folder. | ||
cp ${TMP_OUTPUT}/github.com/kubeflow/pipelines/backend/api/go_client/* ./backend/api/go_client | ||
# Generate *.swagger.json from *.proto into swagger folder. | ||
${PROTOCCOMPILER} -I. -Ibackend/api \ | ||
-I/go/src/github.com/protocolbuffers/protobuf/src \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/ \ | ||
-I/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/ \ | ||
-I/go/src/github.com/protocolbuffers/protobuf/src/google/protobuf \ | ||
--plugin=protoc-gen-swagger=/go/bin/protoc-gen-swagger \ | ||
--swagger_out=logtostderr=true:${TMP_OUTPUT} \ | ||
backend/api/*.proto | ||
cp ${TMP_OUTPUT}/backend/api/*.swagger.json ./backend/api/swagger | ||
# Generate a single swagger json file from the swagger json files of all models. | ||
# Note: use backend/backend/api/swagger/{run,job,experiment,pipeline,pipeline.upload}.swagger.json when apt-get can install jq-1.6 | ||
jq -s 'reduce .[] as $item ({}; . * $item) | .info.title = "Kubeflow Pipelines API" | .info.description = "This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition." | .info.version = "'$KFP_VERSION'" | .info.contact = { "name": "google", "email": "kubeflow-pipelines@google.com", "url": "https://www.google.com" } | .info.license = { "name": "Apache 2.0", "url": "https://raw.githubusercontent.com/kubeflow/pipelines/master/LICENSE" }' backend/api/swagger/run.swagger.json backend/api/swagger/job.swagger.json backend/api/swagger/experiment.swagger.json backend/api/swagger/pipeline.swagger.json backend/api/swagger/pipeline.upload.swagger.json > "backend/api/swagger/kfp_api_single_file.swagger.json" | ||
# Generate go_http_client from swagger json. | ||
swagger generate client \ | ||
-f backend/api/swagger/job.swagger.json \ | ||
-A job \ | ||
--principal models.Principal \ | ||
-c job_client \ | ||
-m job_model \ | ||
-t backend/api/go_http_client | ||
swagger generate client \ | ||
-f backend/api/swagger/run.swagger.json \ | ||
-A run \ | ||
--principal models.Principal \ | ||
-c run_client \ | ||
-m run_model \ | ||
-t backend/api/go_http_client | ||
swagger generate client \ | ||
-f backend/api/swagger/experiment.swagger.json \ | ||
-A experiment \ | ||
--principal models.Principal \ | ||
-c experiment_client \ | ||
-m experiment_model \ | ||
-t backend/api/go_http_client | ||
swagger generate client \ | ||
-f backend/api/swagger/pipeline.swagger.json \ | ||
-A pipeline \ | ||
--principal models.Principal \ | ||
-c pipeline_client \ | ||
-m pipeline_model \ | ||
-t backend/api/go_http_client | ||
swagger generate client \ | ||
-f backend/api/swagger/pipeline.upload.swagger.json \ | ||
-A pipeline_upload \ | ||
--principal models.Principal \ | ||
-c pipeline_upload_client \ | ||
-m pipeline_upload_model \ | ||
-t backend/api/go_http_client | ||
swagger generate client \ | ||
-f backend/api/swagger/visualization.swagger.json \ | ||
-A visualization \ | ||
--principal models.Principal \ | ||
-c visualization_client \ | ||
-m visualization_model \ | ||
-t backend/api/go_http_client | ||
swagger generate client \ | ||
-f backend/api/swagger/healthz.swagger.json \ | ||
-A healthz \ | ||
--principal models.Principal \ | ||
-c healthz_client \ | ||
-m healthz_model \ | ||
-t backend/api/go_http_client | ||
# Hack to fix an issue with go-swagger | ||
# See https://github.com/go-swagger/go-swagger/issues/1381 for details. | ||
sed -i -- 's/MaxConcurrency int64 `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/go_http_client/job_model/api_job.go | ||
sed -i -- 's/IntervalSecond int64 `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/go_http_client/job_model/api_periodic_schedule.go | ||
sed -i -- 's/MaxConcurrency string `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/go_http_client/job_model/api_job.go | ||
sed -i -- 's/IntervalSecond string `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/go_http_client/job_model/api_periodic_schedule.go | ||
# Execute the //go:generate directives in the generated code. | ||
cd backend/api && go generate ./... | ||
cd ../.. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we generally do with updating licenses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually update the date to include the last year there's a change, so we should update this as
Copyright 2020-2021 The Kubeflow Authors
, because you created it.