Skip to content

KEP-2170: Generate clientset, openapi spec for the V2 APIs #2273

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

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/boilerplate/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Kubeflow Authors
// Copyright 2024 The Kubeflow Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
13 changes: 10 additions & 3 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ chmod +x ${CODEGEN_PKG}/generate-internal-groups.sh
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
# instead of the $GOPATH directly. For normal projects this can be dropped.
cd ${SCRIPT_ROOT}
echo "Generating client,lister,informer for kubeflow.org/v1"
echo "Generating client,lister,informer for kubeflow.org/v1 and kubeflow.org/v2alpha1"
${CODEGEN_PKG}/generate-groups.sh "client,lister,informer" \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script needs to be refactored to use kube_codegen.sh . The k8s deps need to be bumped to use the latest kube_codegen args. Will create a separate issue to track the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right. After we upgrade the Kube library version from 1.29 to 1.30, we should do it.

github.com/kubeflow/training-operator/pkg/client github.com/kubeflow/training-operator/pkg/apis \
kubeflow.org:v1 \
kubeflow.org:v1,v2alpha1 \
--output-base "${TEMP_DIR}" \
--go-header-file hack/boilerplate/boilerplate.go.txt

Expand All @@ -101,11 +101,18 @@ go build -o openapi-gen ${OPENAPI_PKG}/cmd/openapi-gen

echo "Generating OpenAPI specification for kubeflow.org/v1"
./openapi-gen --input-dirs github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1 \
--report-filename=hack/violation_exception.list \
--report-filename=hack/violation_exception_v1.list \
--output-package github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1 \
--go-header-file hack/boilerplate/boilerplate.go.txt "$@" \
--output-base "${TEMP_DIR}"

echo "Generating OpenAPI specification for kubeflow.org/v2alpha1"
./openapi-gen --input-dirs github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1 \
--report-filename=hack/violation_exception_v2alpha1.list \
--output-package github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1 \
--go-header-file hack/boilerplate/boilerplate.go.txt "$@" \
--output-base "${TEMP_DIR}"

cd - >/dev/null

# Copy everything back.
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions hack/violation_exception_v2alpha1.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,ContainerOverride,Args
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,ContainerOverride,Command
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,ContainerOverride,Env
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,ContainerOverride,EnvFrom
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,ContainerOverride,VolumeMounts
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,DatasetConfig,Env
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have those violations ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is automatically generated. So, I guess @varshaprasad96 does not know the reason.

Copy link
Contributor Author

@varshaprasad96 varshaprasad96 Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, these are auto-generated. Looks like this is because of the OpenAPI Schema validation and I think some of it could possibly be fixed by adding appropriate CRD markers from KB in types.go. I'll dig deeper into this next week, and create a PR to fix them if possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #2317

API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,InputModel,Env
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,OutputModel,Env
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,PodSpecOverride,Containers
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,PodSpecOverride,InitContainers
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,PodSpecOverride,TargetReplicatedJobs
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,PodSpecOverride,Tolerations
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,PodSpecOverride,Volumes
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,TorchElasticPolicy,Metrics
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,TrainJobSpec,PodSpecOverrides
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,TrainJobStatus,Conditions
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,TrainJobStatus,ReplicatedJobsStatus
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,Trainer,Args
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,Trainer,Command
API rule violation: list_type_missing,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,Trainer,Env
API rule violation: names_match,github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1,MPIMLPolicySource,SSHAuthMountPath
1 change: 1 addition & 0 deletions pkg/apis/kubeflow.org/v1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package

// Package v1 is the v1 version of the API.
// +groupName=kubeflow.org
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/kubeflow.org/v1/openapi_generated.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/apis/kubeflow.org/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/apis/kubeflow.org/v1/zz_generated.defaults.go

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

22 changes: 22 additions & 0 deletions pkg/apis/kubeflow.org/v2alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 The Kubeflow Authors
//
// 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.

// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package

// Package v2alpha1 is the v2alpha1 version of the API.
// +groupName=kubeflow.org

package v2alpha1
Loading
Loading