Skip to content

Commit

Permalink
Split framework struct (kubeflow#1956)
Browse files Browse the repository at this point in the history
* rename framework struct
SupportedModelTypes -> SupportedModelFormats
ServingRuntimeFramework -> SupportedModelFormat
Framework -> ModelFormat

Signed-off-by: Suresh Nakkeran <suresh.n@ideas2it.com>

* added openapi-gen marker for servingruntime structs

Signed-off-by: Suresh Nakkeran <suresh.n@ideas2it.com>

* updated openapigen and swagger for servingruntime

Signed-off-by: Suresh Nakkeran <suresh.n@ideas2it.com>

* update supportedmodelformat in runtime yaml files

Signed-off-by: Suresh Nakkeran <suresh.n@ideas2it.com>
  • Loading branch information
Suresh-Nakkeran authored Dec 21, 2021
1 parent e900189 commit 9bac2b3
Show file tree
Hide file tree
Showing 27 changed files with 1,162 additions and 189 deletions.
2 changes: 1 addition & 1 deletion config/crd/serving.kserve.io_clusterservingruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ spec:
disabled:
type: boolean
type: object
supportedModelTypes:
supportedModelFormats:
items:
properties:
autoSelect:
Expand Down
20 changes: 9 additions & 11 deletions config/crd/serving.kserve.io_inferenceservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4941,17 +4941,6 @@ spec:
type: object
type: object
type: array
framework:
properties:
autoSelect:
type: boolean
name:
type: string
version:
type: string
required:
- name
type: object
image:
type: string
imagePullPolicy:
Expand Down Expand Up @@ -5120,6 +5109,15 @@ spec:
format: int32
type: integer
type: object
modelFormat:
properties:
name:
type: string
version:
type: string
required:
- name
type: object
name:
type: string
ports:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/serving.kserve.io_servingruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ spec:
disabled:
type: boolean
type: object
supportedModelTypes:
supportedModelFormats:
items:
properties:
autoSelect:
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-lgbserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-lgbserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: lightgbm
version: "2"
autoSelect: true
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-mlserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-mlserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: sklearn
version: "0"
- name: xgboost
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-paddleserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-paddleserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: paddle
version: "2"
autoSelect: true
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-pmmlserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-pmmlserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: pmml
version: "3"
autoSelect: true
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-sklearnserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-sklearnserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: sklearn
version: "0"
autoSelect: true
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-tensorflow-serving.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-tensorflow-serving
spec:
supportedModelTypes:
supportedModelFormats:
- name: tensorflow
version: "1"
autoSelect: true
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-torchserve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-torchserve
spec:
supportedModelTypes:
supportedModelFormats:
- name: pytorch
version: "1"
autoSelect: true
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-tritonserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-tritonserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: tensorrt
version: "8"
- name: tensorflow
Expand Down
2 changes: 1 addition & 1 deletion config/runtimes/kserve-xgbserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServingRuntime
metadata:
name: kserve-xgbserver
spec:
supportedModelTypes:
supportedModelFormats:
- name: xgboost
version: "0"
autoSelect: true
Expand Down
1 change: 1 addition & 0 deletions hack/update-openapigen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ go run k8s.io/kube-openapi/cmd/openapi-gen \

# Hack, the name is required in openAPI specification even if set "+optional" for v1.Container in PredictorExtensionSpec.
sed -i'.bak' -e 's/Required: \[\]string{\"name\"},//g' $OPENAPI_SPEC_FILE && rm -rf $OPENAPI_SPEC_FILE.bak
sed -i'.bak' -e 's/Required: \[\]string{\"modelFormat\", \"name\"},/Required: \[\]string{\"modelFormat\"},/g' $OPENAPI_SPEC_FILE && rm -rf $OPENAPI_SPEC_FILE.bak

test -f $CURRENT_VIOLATION_EXCEPTIONS || touch $CURRENT_VIOLATION_EXCEPTIONS

Expand Down
7 changes: 7 additions & 0 deletions hack/violation_exceptions.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,Container,Args
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,Container,Command
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,Container,Env
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,ServingRuntimePodSpec,Containers
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,ServingRuntimePodSpec,Tolerations
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,ServingRuntimeSpec,SupportedModelFormats
API rule violation: list_type_missing,./pkg/apis/serving/v1alpha1,TrainedModelList,Items
API rule violation: list_type_missing,./pkg/apis/serving/v1beta1,ComponentStatusSpec,Traffic
API rule violation: list_type_missing,./pkg/apis/serving/v1beta1,InferenceServiceList,Items
Expand All @@ -11,6 +17,7 @@ API rule violation: list_type_missing,./pkg/apis/serving/v1beta1,PodSpec,Tolerat
API rule violation: list_type_missing,./pkg/apis/serving/v1beta1,PodSpec,Volumes
API rule violation: list_type_missing,./pkg/apis/serving/v1beta1,PredictorConfig,SupportedFrameworks
API rule violation: names_match,./pkg/apis/serving/v1alpha1,ModelSpec,StorageURI
API rule violation: names_match,./pkg/apis/serving/v1alpha1,ServingRuntimeSpec,GrpcMultiModelManagementEndpoint
API rule violation: names_match,./pkg/apis/serving/v1beta1,ComponentExtensionSpec,TimeoutSeconds
API rule violation: names_match,./pkg/apis/serving/v1beta1,ExplainerConfig,ContainerImage
API rule violation: names_match,./pkg/apis/serving/v1beta1,ExplainerExtensionSpec,StorageURI
Expand Down
22 changes: 17 additions & 5 deletions pkg/apis/serving/v1alpha1/servingruntime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type Framework struct {
// Name of the model format/framework.
// +k8s:openapi-gen=true
type SupportedModelFormat struct {
// Name of the model format.
// +required
Name string `json:"name"`
// Version of the model format/framework.
// Version of the model format.
// Used in validating that a predictor is supported by a runtime.
// Can be "major", "major.minor" or "major.minor.patch".
// +optional
Version *string `json:"version,omitempty"`
// Set to true to allow the ServingRuntime to be used for automatic model placement if
// this framework is specified with no explicit runtime.
// this model format is specified with no explicit runtime.
// +optional
AutoSelect *bool `json:"autoSelect,omitempty"`
}

// +k8s:openapi-gen=true
type Container struct {
Name string `json:"name,omitempty" validate:"required"`
Image string `json:"image,omitempty" validate:"required"`
Expand All @@ -54,11 +56,13 @@ type Container struct {
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"`
}

// +k8s:openapi-gen=true
type StorageHelper struct {
// +optional
Disabled bool `json:"disabled,omitempty"`
}

// +k8s:openapi-gen=true
type ServingRuntimePodSpec struct {
// List of containers belonging to the pod.
// Containers cannot currently be added or removed.
Expand Down Expand Up @@ -88,9 +92,10 @@ type ServingRuntimePodSpec struct {
// ServingRuntimeSpec defines the desired state of ServingRuntime. This spec is currently provisional
// and are subject to change as details regarding single-model serving and multi-model serving
// are hammered out.
// +k8s:openapi-gen=true
type ServingRuntimeSpec struct {
// Model formats and version supported by this runtime
SupportedModelTypes []Framework `json:"supportedModelTypes,omitempty"`
SupportedModelFormats []SupportedModelFormat `json:"supportedModelFormats,omitempty"`
// Set to true to disable use of this runtime
// +optional
Disabled *bool `json:"disabled,omitempty"`
Expand Down Expand Up @@ -129,10 +134,12 @@ type ServingRuntimeSpec struct {
}

// ServingRuntimeStatus defines the observed state of ServingRuntime
// +k8s:openapi-gen=true
type ServingRuntimeStatus struct {
}

// ServerType constant for specifying the runtime name
// +k8s:openapi-gen=true
// +kubebuilder:validation:Enum=triton;mlserver
type ServerType string

Expand All @@ -144,6 +151,7 @@ const (
MLServer ServerType = "mlserver"
)

// +k8s:openapi-gen=true
type BuiltInAdapter struct {
// ServerType can be one of triton/mlserver and the runtime's container must have the same name
ServerType ServerType `json:"serverType,omitempty"`
Expand All @@ -156,6 +164,7 @@ type BuiltInAdapter struct {
}

// ServingRuntime is the Schema for the servingruntimes API
// +k8s:openapi-gen=true
// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="Disabled",type="boolean",JSONPath=".spec.disabled"
// +kubebuilder:printcolumn:name="ModelType",type="string",JSONPath=".spec.supportedModelTypes[*].name"
Expand All @@ -170,6 +179,7 @@ type ServingRuntime struct {
}

// ServingRuntimeList contains a list of ServingRuntime
// +k8s:openapi-gen=true
// +kubebuilder:object:root=true
type ServingRuntimeList struct {
metav1.TypeMeta `json:",inline"`
Expand All @@ -178,6 +188,7 @@ type ServingRuntimeList struct {
}

// ClusterServingRuntime is the Schema for the servingruntimes API
// +k8s:openapi-gen=true
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:printcolumn:name="Disabled",type="boolean",JSONPath=".spec.disabled"
Expand All @@ -193,6 +204,7 @@ type ClusterServingRuntime struct {
}

// ServingRuntimeList contains a list of ServingRuntime
// +k8s:openapi-gen=true
// +kubebuilder:object:root=true
type ClusterServingRuntimeList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/serving/v1alpha1/servingruntime_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestMarshalServingRuntime(t *testing.T) {
},
},
},
SupportedModelTypes: []Framework{
SupportedModelFormats: []SupportedModelFormat{
{
Name: "name",
Version: &version,
Expand Down
56 changes: 28 additions & 28 deletions pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9bac2b3

Please sign in to comment.