-
Notifications
You must be signed in to change notification settings - Fork 739
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
feat(sdk): Generate external Kubernetes and JobSet models #2466
Merged
google-oss-prow
merged 8 commits into
kubeflow:master
from
andreyvelich:generate-sdk-docker
Mar 5, 2025
+16,086
−6,861
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f844687
feat(sdk): Generate external Kubernetes and JobSet models
andreyvelich c947d08
Update JobSet commit in Swagger
andreyvelich d161638
Fix formats for resources and num proc
andreyvelich 0827fce
Add custom Kind config
andreyvelich 330ae40
Use ginkgo to run e2e
andreyvelich bbe2d4b
Revert Kind config change
andreyvelich 76e4b96
Fix ginkgo binary
andreyvelich b5b4597
Print controller logs in case of failure
andreyvelich 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
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
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 |
---|---|---|
@@ -1,8 +1,4 @@ | ||
{ | ||
"packageName": "kubeflow.trainer", | ||
"typeMappings": { | ||
"K8sIoApiAutoscalingV2MetricSpec": "V2MetricSpec", | ||
"K8sIoApimachineryPkgUtilIntstrIntOrString": "object", | ||
"V1Time": "datetime" | ||
} | ||
"typeMappings": {} | ||
} |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ package main | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"runtime/debug" | ||
"strings" | ||
|
||
"k8s.io/klog/v2" | ||
|
@@ -30,12 +31,44 @@ import ( | |
|
||
// Generate Kubeflow Training OpenAPI specification. | ||
func main() { | ||
// Get Kubernetes and JobSet version | ||
var k8sVersion string | ||
var jobSetVersion string | ||
|
||
info, ok := debug.ReadBuildInfo() | ||
if !ok { | ||
fmt.Println("Failed to read build info") | ||
return | ||
} | ||
|
||
for _, dep := range info.Deps { | ||
if dep.Path == "k8s.io/api" { | ||
k8sVersion = strings.Replace(dep.Version, "v0.", "v1.", -1) | ||
} else if dep.Path == "sigs.k8s.io/jobset" { | ||
jobSetVersion = dep.Version | ||
} | ||
Comment on lines
+44
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this look good to fetch Kubernetes and JobSet version ? |
||
} | ||
if k8sVersion == "" || jobSetVersion == "" { | ||
fmt.Println("OpenAPI spec generation failed. Unable to get Kubernetes and JobSet version") | ||
return | ||
} | ||
|
||
k8sOpenAPISpec := fmt.Sprintf("https://raw.githubusercontent.com/kubernetes/kubernetes/refs/tags/%s/api/openapi-spec/swagger.json", k8sVersion) | ||
// TODO (andreyvelich): Use the release version once this JobSet commit is released: d5c7bce. | ||
// jobSetOpenAPISpec := fmt.Sprintf("https://raw.githubusercontent.com/kubernetes-sigs/jobset/refs/tags/%s/hack/python-sdk/swagger.json", jobSetVersion) | ||
jobSetOpenAPISpec := "https://raw.githubusercontent.com/kubernetes-sigs/jobset/d5c7bcebe739a4577e30944370c2d7a68321a929/hack/python-sdk/swagger.json" | ||
|
||
var oAPIDefs = map[string]common.OpenAPIDefinition{} | ||
defs := spec.Definitions{} | ||
|
||
refCallback := func(name string) spec.Ref { | ||
return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(swaggify(name))) | ||
if strings.HasPrefix(name, "k8s.io") { | ||
return spec.MustCreateRef(k8sOpenAPISpec + "#/definitions/" + swaggify(name)) | ||
} else if strings.HasPrefix(name, "sigs.k8s.io/jobset") { | ||
return spec.MustCreateRef(jobSetOpenAPISpec + "#/definitions/" + swaggify(name)) | ||
} | ||
return spec.MustCreateRef("#/definitions/" + swaggify(name)) | ||
|
||
} | ||
|
||
for k, v := range trainer.GetOpenAPIDefinitions(refCallback) { | ||
|
@@ -67,8 +100,7 @@ func main() { | |
func swaggify(name string) string { | ||
name = strings.Replace(name, "github.com/kubeflow/trainer/pkg/apis/", "", -1) | ||
name = strings.Replace(name, "sigs.k8s.io/jobset/api/", "", -1) | ||
name = strings.Replace(name, "k8s.io/api/core/", "", -1) | ||
name = strings.Replace(name, "k8s.io/apimachinery/pkg/apis/meta/", "", -1) | ||
name = strings.Replace(name, "k8s.io", "io.k8s", -1) | ||
name = strings.Replace(name, "/", ".", -1) | ||
return name | ||
} |
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.
I added this config, so we can add more Kind workers in the future to decrease kube-scheduler time for placing Pods.
I think, that should speedup our tests once we run more TrainJobs at the same time.
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.
Could you open a separate PR? Because this seems not to related to openapi-gen.
If we find any issue for Kind config adding, the dedicated PR allows us to easily revert and fix that.
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.
Sure, let me open it.