Skip to content

Commit

Permalink
Generate SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvelich committed Oct 6, 2021
1 parent 948d6cf commit 2fe4271
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ examples/.ipynb_checkpoints/

# openapi-codegen tools and auto generated files but useless
hack/python-sdk/openapi-generator-cli.jar
sdk/python/.openapi-generator

# Coverage
cover.out
13 changes: 6 additions & 7 deletions hack/python-sdk/gen-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

repo_root="$(realpath "$(dirname "$0")/../..")"
repo_root="$(dirname ${BASH_SOURCE})/../.."

SWAGGER_JAR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar"
SWAGGER_CODEGEN_JAR="${repo_root}/hack/python-sdk/openapi-generator-cli.jar"
Expand All @@ -28,7 +28,7 @@ FRAMEWORKS=(tensorflow pytorch mxnet xgboost)
VERSION=1.3.0

if [ -z "${GOPATH:-}" ]; then
export GOPATH=$(go env GOPATH)
export GOPATH=$(go env GOPATH)
fi

echo "Generating OpenAPI specification ..."
Expand All @@ -39,15 +39,14 @@ if [[ ! -f "$SWAGGER_CODEGEN_JAR" ]]; then
wget -O "${SWAGGER_CODEGEN_JAR}" ${SWAGGER_JAR_URL}
fi


for FRAMEWORK in ${FRAMEWORKS[@]}; do
SWAGGER_CODEGEN_FILE="pkg/apis/${FRAMEWORK}/v1/swagger.json"
echo "Generating swagger file for ${FRAMEWORK} ..."
go run "${repo_root}"/hack/python-sdk/main.go "${FRAMEWORK}" ${VERSION} > "${SWAGGER_CODEGEN_FILE}"
SWAGGER_CODEGEN_FILE="pkg/apis/${FRAMEWORK}/v1/swagger.json"
echo "Generating swagger file for ${FRAMEWORK} ..."
go run "${repo_root}"/hack/python-sdk/main.go "${FRAMEWORK}" ${VERSION} >"${SWAGGER_CODEGEN_FILE}"
done

echo "Merging swagger files from different frameworks into one"
download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest |
jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
curl -o /tmp/swagger -L'#' "$download_url"
chmod +x /tmp/swagger
Expand Down
6 changes: 3 additions & 3 deletions hack/python-sdk/swagger.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"swagger": "2.0",
"info": {
"description": "Python SDK for Kubeflow Training",
"title": "Kubeflow Training SDK",
"description": "Python SDK for tensorflow",
"title": "tensorflow",
"version": "v1.3.0"
},
"paths": {},
Expand Down Expand Up @@ -473,4 +473,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions pkg/apis/mxnet/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/pytorch/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/tensorflow/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/xgboost/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/controller.v1/mxnet/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "manifests", "base", "crds")},
ErrorIfCRDPathMissing: true,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/pytorch/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "manifests", "base", "crds")},
ErrorIfCRDPathMissing: true,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/tensorflow/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "manifests", "base", "crds")},
ErrorIfCRDPathMissing: true,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/xgboost/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "manifests", "base", "crds")},
ErrorIfCRDPathMissing: true,
}

Expand Down

0 comments on commit 2fe4271

Please sign in to comment.