Skip to content

Commit 224aa9d

Browse files
authored
fix(api): resolve all api voilation exceptions in katib api (#2482)
Signed-off-by: truc0 <22969604+truc0@users.noreply.github.com>
1 parent 93bee4d commit 224aa9d

File tree

7 files changed

+378
-67
lines changed

7 files changed

+378
-67
lines changed

hack/violation_exception_v1beta1.list

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +0,0 @@
1-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1,AlgorithmSpec,AlgorithmSettings
2-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1,EarlyStoppingSpec,AlgorithmSettings
3-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1,FilterSpec,MetricsFormat
4-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1,ObjectiveSpec,AdditionalMetricNames
5-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1,ObjectiveSpec,MetricStrategies
6-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1,Observation,Metrics
7-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentSpec,Parameters
8-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,Conditions
9-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,EarlyStoppedTrialList
10-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,FailedTrialList
11-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,KilledTrialList
12-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,MetricsUnavailableTrialList
13-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,PendingTrialList
14-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,RunningTrialList
15-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,ExperimentStatus,SucceededTrialList
16-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,FeasibleSpace,List
17-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,GraphConfig,InputSizes
18-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,GraphConfig,OutputSizes
19-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,NasConfig,Operations
20-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,Operation,Parameters
21-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,OptimalTrial,ParameterAssignments
22-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/experiments/v1beta1,TrialTemplate,TrialParameters
23-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1,SuggestionStatus,AlgorithmSettings
24-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1,SuggestionStatus,Conditions
25-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1,SuggestionStatus,Suggestions
26-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1,TrialAssignment,EarlyStoppingRules
27-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1,TrialAssignment,ParameterAssignments
28-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/trials/v1beta1,TrialSpec,EarlyStoppingRules
29-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/trials/v1beta1,TrialSpec,ParameterAssignments
30-
API rule violation: list_type_missing,github.com/kubeflow/katib/pkg/apis/controller/trials/v1beta1,TrialStatus,Conditions

pkg/apis/controller/common/v1beta1/common_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ type AlgorithmSpec struct {
2727
AlgorithmName string `json:"algorithmName,omitempty"`
2828

2929
// Key-value pairs representing settings for suggestion algorithms.
30+
// +listType=map
31+
// +listMapKey=name
3032
AlgorithmSettings []AlgorithmSetting `json:"algorithmSettings,omitempty"`
3133
}
3234

@@ -46,6 +48,8 @@ type EarlyStoppingSpec struct {
4648
AlgorithmName string `json:"algorithmName,omitempty"`
4749

4850
// Key-value pairs representing settings for early stopping algorithm.
51+
// +listType=map
52+
// +listMapKey=name
4953
AlgorithmSettings []EarlyStoppingSetting `json:"algorithmSettings,omitempty"`
5054
}
5155

@@ -105,10 +109,13 @@ type ObjectiveSpec struct {
105109
// AdditionalMetricNames represents metrics that should be collected from Trials.
106110
// This can be empty if we only care about the objective metric.
107111
// Note: If we adopt a push instead of pull mechanism, this can be omitted completely.
112+
// +listType=set
108113
AdditionalMetricNames []string `json:"additionalMetricNames,omitempty"`
109114

110115
// MetricStrategies defines various rules (min, max or latest) to extract metrics values.
111116
// This field is allowed to missing, experiment defaulter (webhook) will fill it.
117+
// +listType=map
118+
// +listMapKey=name
112119
MetricStrategies []MetricStrategy `json:"metricStrategies,omitempty"`
113120
}
114121

@@ -150,6 +157,8 @@ type Metric struct {
150157
// +k8s:deepcopy-gen=true
151158
type Observation struct {
152159
// Key-value pairs for metric names and values
160+
// +listType=map
161+
// +listMapKey=name
153162
Metrics []Metric `json:"metrics,omitempty"`
154163
}
155164

@@ -177,6 +186,7 @@ type SourceSpec struct {
177186
type FilterSpec struct {
178187
// When the metrics output follows format as this field specified, metricsCollector
179188
// collects it and reports to metrics server, it can be "<metric_name>: <float>" or else
189+
// +listType=set
180190
MetricsFormat []string `json:"metricsFormat,omitempty"`
181191
}
182192

pkg/apis/controller/experiments/v1beta1/experiment_types.go

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
// ExperimentSpec is the specification of an Experiment.
2727
type ExperimentSpec struct {
2828
// List of hyperparameter configurations.
29+
// +listType=map
30+
// +listMapKey=name
2931
Parameters []ParameterSpec `json:"parameters,omitempty"`
3032

3133
// Describes the objective of the experiment.
@@ -78,30 +80,39 @@ type ExperimentStatus struct {
7880
LastReconcileTime *metav1.Time `json:"lastReconcileTime,omitempty"`
7981

8082
// List of observed runtime conditions for this Experiment.
83+
// +listType=map
84+
// +listMapKey=type
8185
Conditions []ExperimentCondition `json:"conditions,omitempty"`
8286

8387
// Current optimal trial parameters and observations.
8488
CurrentOptimalTrial OptimalTrial `json:"currentOptimalTrial,omitempty"`
8589

8690
// List of trial names which are running.
91+
// +listType=set
8792
RunningTrialList []string `json:"runningTrialList,omitempty"`
8893

8994
// List of trial names which are pending.
95+
// +listType=set
9096
PendingTrialList []string `json:"pendingTrialList,omitempty"`
9197

9298
// List of trial names which have already failed.
99+
// +listType=set
93100
FailedTrialList []string `json:"failedTrialList,omitempty"`
94101

95102
// List of trial names which have already succeeded.
103+
// +listType=set
96104
SucceededTrialList []string `json:"succeededTrialList,omitempty"`
97105

98106
// List of trial names which have been killed.
107+
// +listType=set
99108
KilledTrialList []string `json:"killedTrialList,omitempty"`
100109

101110
// List of trial names which have been early stopped.
111+
// +listType=set
102112
EarlyStoppedTrialList []string `json:"earlyStoppedTrialList,omitempty"`
103113

104114
// List of trial names which have been metrics unavailable
115+
// +listType=set
105116
MetricsUnavailableTrialList []string `json:"metricsUnavailableTrialList,omitempty"`
106117

107118
// Trials is the total number of trials owned by the experiment.
@@ -134,6 +145,8 @@ type OptimalTrial struct {
134145
// BestTrialName is the name of the best trial.
135146
BestTrialName string `json:"bestTrialName,omitempty"`
136147
// Key-value pairs for hyperparameters and assignment values.
148+
// +listType=map
149+
// +listMapKey=name
137150
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments,omitempty"`
138151

139152
// Observation for this trial
@@ -207,8 +220,10 @@ const (
207220
)
208221

209222
type FeasibleSpace struct {
210-
Max string `json:"max,omitempty"`
211-
Min string `json:"min,omitempty"`
223+
Max string `json:"max,omitempty"`
224+
Min string `json:"min,omitempty"`
225+
226+
// +listType=set
212227
List []string `json:"list,omitempty"`
213228
Step string `json:"step,omitempty"`
214229
Distribution Distribution `json:"distribution,omitempty"`
@@ -233,6 +248,8 @@ type TrialTemplate struct {
233248
TrialSource `json:",inline"`
234249

235250
// List of parameters that are used in trial template
251+
// +listType=map
252+
// +listMapKey=name
236253
TrialParameters []TrialParameterSpec `json:"trialParameters,omitempty"`
237254

238255
// Labels that determines if pod needs to be injected by Katib sidecar container.
@@ -314,20 +331,30 @@ type ExperimentList struct {
314331
// NasConfig contains config for NAS job
315332
type NasConfig struct {
316333
GraphConfig GraphConfig `json:"graphConfig,omitempty"`
317-
Operations []Operation `json:"operations,omitempty"`
334+
335+
// +listType=map
336+
// +listMapKey=operationType
337+
Operations []Operation `json:"operations,omitempty"`
318338
}
319339

320340
// GraphConfig contains a config of DAG
321341
type GraphConfig struct {
322-
NumLayers *int32 `json:"numLayers,omitempty"`
323-
InputSizes []int32 `json:"inputSizes,omitempty"`
342+
NumLayers *int32 `json:"numLayers,omitempty"`
343+
344+
// +listType=set
345+
InputSizes []int32 `json:"inputSizes,omitempty"`
346+
347+
// +listType=set
324348
OutputSizes []int32 `json:"outputSizes,omitempty"`
325349
}
326350

327351
// Operation contains type of operation in DAG
328352
type Operation struct {
329-
OperationType string `json:"operationType,omitempty"`
330-
Parameters []ParameterSpec `json:"parameters,omitempty"`
353+
OperationType string `json:"operationType,omitempty"`
354+
355+
// +listType=map
356+
// +listMapKey=name
357+
Parameters []ParameterSpec `json:"parameters,omitempty"`
331358
}
332359

333360
func init() {

pkg/apis/controller/suggestions/v1beta1/suggestion_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ type SuggestionStatus struct {
4646
// AlgorithmSettings defines HP or NAS algorithm settings which suggestion gRPC service returns.
4747
// These settings overwrites Experiment's settings before the gRPC request.
4848
// It can be empty if settings haven't been changed.
49+
// +listType=map
50+
// +listMapKey=name
4951
AlgorithmSettings []common.AlgorithmSetting `json:"algorithmSettings,omitempty"`
5052

5153
// Number of suggestion results
5254
SuggestionCount int32 `json:"suggestionCount,omitempty"`
5355

5456
// Suggestion results
57+
// +listType=map
58+
// +listMapKey=name
5559
Suggestions []TrialAssignment `json:"suggestions,omitempty"`
5660

5761
// Represents time when the Suggestion was acknowledged by the Suggestion controller.
@@ -70,19 +74,25 @@ type SuggestionStatus struct {
7074
LastReconcileTime *metav1.Time `json:"lastReconcileTime,omitempty"`
7175

7276
// List of observed runtime conditions for this Suggestion.
77+
// +listType=map
78+
// +listMapKey=type
7379
Conditions []SuggestionCondition `json:"conditions,omitempty"`
7480
}
7581

7682
// TrialAssignment is the assignment for one trial.
7783
type TrialAssignment struct {
7884
// Suggestion results with Trial parameters
85+
// +listType=map
86+
// +listMapKey=name
7987
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments,omitempty"`
8088

8189
// Name of the suggestion
8290
Name string `json:"name,omitempty"`
8391

8492
// Rules for early stopping techniques
8593
// Contains rule name, value and comparison type
94+
// +listType=map
95+
// +listMapKey=name
8696
EarlyStoppingRules []common.EarlyStoppingRule `json:"earlyStoppingRules,omitempty"`
8797

8898
// Suggestion label metadata to attach to Trial job

pkg/apis/controller/trials/v1beta1/trial_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ type TrialSpec struct {
2929
Objective *common.ObjectiveSpec `json:"objective,omitempty"`
3030

3131
// Key-value pairs for hyperparameters and assignment values.
32+
// +listType=map
33+
// +listMapKey=name
3234
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments,omitempty"`
3335

3436
// Rules for early stopping techniques.
3537
// Each rule should be met to early stop Trial.
38+
// +listType=map
39+
// +listMapKey=name
3640
EarlyStoppingRules []common.EarlyStoppingRule `json:"earlyStoppingRules,omitempty"`
3741

3842
// Raw text for the trial run spec. This can be any generic Kubernetes
@@ -84,6 +88,8 @@ type TrialStatus struct {
8488
LastReconcileTime *metav1.Time `json:"lastReconcileTime,omitempty"`
8589

8690
// List of observed runtime conditions for this Trial.
91+
// +listType=map
92+
// +listMapKey=type
8793
Conditions []TrialCondition `json:"conditions,omitempty"`
8894

8995
// Results of the Trial - objectives and other metrics values.

0 commit comments

Comments
 (0)