-
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
8b83751
55eb0dd
68b7f47
e71326c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // 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" | ||
| ) | ||
|
|
||
| // 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"` | ||
| } | ||
|
|
||
| // 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"` | ||
|
|
||
| // Tighter TrainJob Integration: Strongly typed to TrainJob rather than arbitrary CRDs. | ||
| TrialTemplate trainerv1alpha1.TrainJob `json:"trialTemplate"` | ||
| } | ||
|
|
||
| // OptimizationJobStatus defines the observed state of OptimizationJob. | ||
| type OptimizationJobStatus struct { | ||
| // Add status fields here (e.g., Conditions, BestTrial, etc.) as the controller matures. | ||
|
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. Should also integrate with train job status tracking feature
Author
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. Ack, added it. |
||
| } | ||
|
|
||
| // +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"` | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.