-
Notifications
You must be signed in to change notification settings - Fork 835
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
refactor(crds): Use built-in OpenAPI validation #5129
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,42 +25,74 @@ import ( | |
"github.com/seldonio/seldon-core/apis/go/v2/mlops/scheduler" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:resource:shortName=mlp | ||
|
||
// Pipeline is the Schema for the pipelines API | ||
type Pipeline struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PipelineSpec `json:"spec,omitempty"` | ||
Status PipelineStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// PipelineList contains a list of Pipeline | ||
type PipelineList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
|
||
Items []Pipeline `json:"items"` | ||
} | ||
|
||
// PipelineSpec defines the desired state of Pipeline | ||
type PipelineSpec struct { | ||
// External inputs to this pipeline, optional | ||
Input *PipelineInput `json:"input,omitempty"` | ||
|
||
// The steps of this inference graph pipeline | ||
Steps []PipelineStep `json:"steps"` | ||
|
||
// Synchronous output from this pipeline, optional | ||
Output *PipelineOutput `json:"output,omitempty"` | ||
} | ||
|
||
// +kubebuilder:validation:Enum=inner;outer;any | ||
type JoinType string | ||
|
||
const ( | ||
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. explain: It's not ideal that it's repeated here, but this approach seems common [1]. [1] https://github.com/search?q=%2Bkubebuilder%3Avalidation%3AEnum&type=code — e.g. Grafana, Cilium, etc. |
||
// data must be available from all inputs | ||
JoinTypeInner JoinType = "inner" | ||
// data will include any data from any inputs at end of window | ||
JoinTypeOuter JoinType = "outer" | ||
JoinTypeAny JoinType = "any" | ||
// first data input that arrives will be forwarded | ||
JoinTypeAny JoinType = "any" | ||
) | ||
|
||
type PipelineStep struct { | ||
// Name of the step | ||
Name string `json:"name"` | ||
|
||
// Previous step to receive data from | ||
Inputs []string `json:"inputs,omitempty"` | ||
|
||
// msecs to wait for messages from multiple inputs to arrive before joining the inputs | ||
JoinWindowMs *uint32 `json:"joinWindowMs,omitempty"` | ||
|
||
// Map of tensor name conversions to use e.g. output1 -> input1 | ||
TensorMap map[string]string `json:"tensorMap,omitempty"` | ||
|
||
// Triggers required to activate step | ||
Triggers []string `json:"triggers,omitempty"` | ||
// One of inner (default), outer, or any | ||
// inner - do an inner join: data must be available from all inputs | ||
// outer - do an outer join: data will include any data from any inputs at end of window | ||
// any - first data input that arrives will be forwarded | ||
|
||
// +kubebuilder:default=inner | ||
InputsJoinType *JoinType `json:"inputsJoinType,omitempty"` | ||
// One of inner (default), outer, or any (see above for details) | ||
|
||
TriggersJoinType *JoinType `json:"triggersJoinType,omitempty"` | ||
|
||
// Batch size of request required before data will be sent to this step | ||
Batch *PipelineBatch `json:"batch,omitempty"` | ||
} | ||
|
@@ -74,25 +106,33 @@ type PipelineBatch struct { | |
type PipelineInput struct { | ||
// Previous external pipeline steps to receive data from | ||
ExternalInputs []string `json:"externalInputs,omitempty"` | ||
|
||
// Triggers required to activate inputs | ||
ExternalTriggers []string `json:"externalTriggers,omitempty"` | ||
|
||
// msecs to wait for messages from multiple inputs to arrive before joining the inputs | ||
JoinWindowMs *uint32 `json:"joinWindowMs,omitempty"` | ||
// One of inner (default), outer, or any (see above for details) | ||
|
||
// +kubebuilder:default=inner | ||
JoinType *JoinType `json:"joinType,omitempty"` | ||
// One of inner (default), outer, or any (see above for details) | ||
|
||
// +kubebuilder:default=inner | ||
TriggersJoinType *JoinType `json:"triggersJoinType,omitempty"` | ||
|
||
// Map of tensor name conversions to use e.g. output1 -> input1 | ||
TensorMap map[string]string `json:"tensorMap,omitempty"` | ||
} | ||
|
||
type PipelineOutput struct { | ||
// Previous step to receive data from | ||
Steps []string `json:"steps,omitempty"` | ||
|
||
// msecs to wait for messages from multiple inputs to arrive before joining the inputs | ||
JoinWindowMs uint32 `json:"joinWindowMs,omitempty"` | ||
// One of inner (default), outer, or any (see above for details) | ||
|
||
// +kubebuilder:default=inner | ||
StepsJoin *JoinType `json:"stepsJoin,omitempty"` | ||
|
||
// Map of tensor name conversions to use e.g. output1 -> input1 | ||
TensorMap map[string]string `json:"tensorMap,omitempty"` | ||
} | ||
|
@@ -102,28 +142,6 @@ type PipelineStatus struct { | |
duckv1.Status `json:",inline"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:resource:shortName=mlp | ||
|
||
// Pipeline is the Schema for the pipelines API | ||
type Pipeline struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PipelineSpec `json:"spec,omitempty"` | ||
Status PipelineStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// PipelineList contains a list of Pipeline | ||
type PipelineList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Pipeline `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Pipeline{}, &PipelineList{}) | ||
} | ||
|
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
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.
explain: More conventional kubebuilder annotations to have this for both
struct
s, and to be ordered this way. This is also the same for the new lines between fields.