-
Notifications
You must be signed in to change notification settings - Fork 521
feat: Scaffold OptimizationJob CRD v1alpha1 types and clients #2624
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
Open
aniket2405
wants to merge
4
commits into
kubeflow:master
Choose a base branch
from
aniket2405:feat/optimizationjob-crd
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8b83751
feat: Scaffold OptimizationJob CRD v1alpha1 types and clients
aniket2405 55eb0dd
address PR reviews: add top-level initializer and status tracking fields
aniket2405 68b7f47
Update Go definitions
aniket2405 e71326c
Revert "Update Go definitions"
aniket2405 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
| // pkg/apis/optimizer/v1alpha1/doc.go | ||
|
|
||
| // Package v1alpha1 contains API Schema definitions for the optimizer v1alpha1 API group. | ||
| // +k8s:deepcopy-gen=package | ||
| // +groupName=optimizer.kubeflow.org | ||
| // +kubebuilder:object:generate=true | ||
|
|
||
| package v1alpha1 |
This file contains hidden or 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,101 @@ | ||
| // pkg/apis/optimizer/v1alpha1/optimizationjob_types.go | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| trainerv1alpha1 "github.com/kubeflow/trainer/pkg/apis/trainer/v1alpha1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| runtime "k8s.io/apimachinery/pkg/runtime" | ||
| ) | ||
|
|
||
| // Objective defines the metric and goal for the HPO job. | ||
| type Objective struct { | ||
| Metric string `json:"metric"` | ||
| Direction string `json:"direction"` | ||
| Goal *float64 `json:"goal,omitempty"` | ||
| } | ||
|
|
||
| // Algorithm defines the optimization algorithm configuration. | ||
| type Algorithm struct { | ||
| Name string `json:"name"` | ||
| Settings []SettingKV `json:"settings,omitempty"` | ||
| } | ||
|
|
||
| // SettingKV is a key-value pair for algorithm settings. | ||
| type SettingKV struct { | ||
| Name string `json:"name"` | ||
| Value string `json:"value"` | ||
| } | ||
|
|
||
| // TrialConfig controls the orchestration of the trials. | ||
| type TrialConfig struct { | ||
| NumTrials *int32 `json:"num_trials,omitempty"` | ||
| ParallelTrials *int32 `json:"parallel_trials,omitempty"` | ||
| MaxFailedTrials *int32 `json:"max_failed_trials,omitempty"` | ||
| } | ||
|
|
||
| // BestTrial tracks the best performing trial and its metrics. | ||
| type BestTrial struct { | ||
| Name string `json:"name"` | ||
| Value float64 `json:"value"` | ||
| } | ||
|
|
||
| // OptimizationJobSpec defines the desired state of OptimizationJob. | ||
| type OptimizationJobSpec struct { | ||
| Objectives []Objective `json:"objectives"` | ||
| Algorithm Algorithm `json:"algorithm"` | ||
|
|
||
| // Using map[string]string initially, can be refined to strict types later if needed. | ||
| SearchSpace map[string]string `json:"searchSpace"` | ||
|
|
||
| TrialConfig TrialConfig `json:"trialConfig"` | ||
|
|
||
| Initializer *trainerv1alpha1.Initializer `json:"initializer,omitempty"` | ||
|
|
||
| // Tighter TrainJob Integration: Strongly typed to TrainJob rather than arbitrary CRDs. | ||
| // runtime.RawExtension allows embedding the raw TrainJob Kubernetes object. | ||
| // +kubebuilder:pruning:PreserveUnknownFields | ||
| TrialTemplate runtime.RawExtension `json:"trialTemplate"` | ||
| } | ||
|
|
||
| // OptimizationJobStatus defines the observed state of OptimizationJob. | ||
| type OptimizationJobStatus struct { | ||
| // Conditions track the overall lifecycle of the OptimizationJob (e.g., Created, Running, Succeeded, Failed). | ||
| Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
|
|
||
| // Active is the number of currently running trials. | ||
| Active int32 `json:"active,omitempty"` | ||
|
|
||
| // Succeeded is the number of trials that successfully completed. | ||
| Succeeded int32 `json:"succeeded,omitempty"` | ||
|
|
||
| // Failed is the number of trials that failed. | ||
| Failed int32 `json:"failed,omitempty"` | ||
|
|
||
| // BestTrial holds the information about the best performing trial so far. | ||
| BestTrial *BestTrial `json:"bestTrial,omitempty"` | ||
| } | ||
|
|
||
| // +genclient | ||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // OptimizationJob is the Schema for the optimizationjobs API. | ||
| type OptimizationJob struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec OptimizationJobSpec `json:"spec,omitempty"` | ||
| Status OptimizationJobStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| // +kubebuilder:object:root=true | ||
|
|
||
| // OptimizationJobList contains a list of OptimizationJob. | ||
| type OptimizationJobList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []OptimizationJob `json:"items"` | ||
| } | ||
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.
Should the spec have initializer config at top level? We want have a common initializer for all jobs/trials
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.
Agreed, added an
Initializerconfig.