Skip to content

Commit

Permalink
Generate codes
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Iwai <[email protected]>
  • Loading branch information
tenzen-y committed Oct 11, 2024
1 parent 10665be commit e5f72b3
Show file tree
Hide file tree
Showing 154 changed files with 19,796 additions and 702 deletions.
561 changes: 501 additions & 60 deletions deploy/v2beta1/mpi-operator.yaml

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions hack/python-sdk/gen-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ if [ -z "${GOPATH:-}" ]; then
export GOPATH=$(go env GOPATH)
fi

# Backup existing v2 openapi_generated.go
cp pkg/apis/kubeflow/v2beta1/openapi_generated.go pkg/apis/kubeflow/v2beta1/openapi_generated.go.backup

CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1)
GOBIN="${PWD}/bin" go install "k8s.io/code-generator/cmd/openapi-gen@${CODEGEN_VERSION}"
echo "Generating V2 OpenAPI specification ..."
"${PWD}/bin/openapi-gen" --input-dirs github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --output-package github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --go-header-file hack/boilerplate/boilerplate.go.txt

echo "Generating V2 swagger file ..."
go run hack/python-sdk/main.go v2beta1 > ${SWAGGER_V2_CODEGEN_FILE}

Expand All @@ -47,7 +39,7 @@ fi
echo "Generating V2 Python SDK for Kubeflow MPI-Operator ..."
java -jar ${SWAGGER_CODEGEN_JAR} generate -i ${SWAGGER_V2_CODEGEN_FILE} -g python-legacy -o ${SDK_OUTPUT_PATH}/v2beta1 -c ${SWAGGER_CODEGEN_CONF}

# Rollback the current V2 openapi_generated.go
mv pkg/apis/kubeflow/v2beta1/openapi_generated.go.backup pkg/apis/kubeflow/v2beta1/openapi_generated.go
# Rollback the current V2 zz_generated.openapi.go
mv pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go.backup pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go

echo "Kubeflow MPI-Operator Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/."
47 changes: 31 additions & 16 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,34 @@ set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
pushd "${SCRIPT_ROOT}"
SCRIPT_ROOT=$(pwd)
popd

# Note that we use code-generator from `${GOPATH}/pkg/mod/` because we cannot vendor it
# via `go mod vendor` to the project's /vendor directory.
# Reference: https://github.com/kubernetes/code-generator/issues/57
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1)
CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}")
chmod +x "${CODEGEN_PKG}/generate-groups.sh"
chmod +x "${CODEGEN_PKG}/generate-internal-groups.sh"

"${CODEGEN_PKG}/generate-groups.sh" "deepcopy,client,informer,lister,applyconfiguration" \
github.com/kubeflow/mpi-operator/pkg/client github.com/kubeflow/mpi-operator/pkg/apis \
kubeflow:v2beta1 --go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt"
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
MPI_OPERATOR_ROOT=$(realpath "${CURRENT_DIR}/..")
MPI_OPERATOR_PKG="github.com/kubeflow/mpi-operator"
CODEGEN_PKG=$(go list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator)

cd "${CURRENT_DIR}/.."

source "${CODEGEN_PKG}/kube_codegen.sh"

kube::codegen::gen_helpers \
--boilerplate "${MPI_OPERATOR_ROOT}/hack/custom-boilerplate.go.txt" \
"${MPI_OPERATOR_ROOT}/pkg/apis"

# Generating OpenAPI
cp "${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go" \
"${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go.backup"

kube::codegen::gen_openapi \
--boilerplate "${MPI_OPERATOR_ROOT}/hack/custom-boilerplate.go.txt" \
--output-dir "${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1" \
--output-pkg "${MPI_OPERATOR_PKG}/pkg/apis/kubeflow/v2beta1" \
--update-report \
"${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1"

kube::codegen::gen_client \
--with-watch \
--with-applyconfig \
--output-dir "${MPI_OPERATOR_ROOT}/pkg/client" \
--output-pkg "${MPI_OPERATOR_PKG}/pkg/client" \
--boilerplate "${MPI_OPERATOR_ROOT}/hack/custom-boilerplate.go.txt" \
"${MPI_OPERATOR_ROOT}/pkg/apis"
561 changes: 501 additions & 60 deletions manifests/base/kubeflow.org_mpijobs.yaml

Large diffs are not rendered by default.

Loading

0 comments on commit e5f72b3

Please sign in to comment.