From a8e207b805ed1c7737dce448cb47d16310580802 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Sat, 10 Aug 2024 23:50:47 +0800 Subject: [PATCH] API Change From Model to OpenModel Signed-off-by: kerthcet --- README.md | 4 +- api/core/v1alpha1/model_types.go | 12 +- api/core/v1alpha1/zz_generated.deepcopy.go | 118 ++++---- .../core/v1alpha1/{model.go => openmodel.go} | 48 ++-- client-go/applyconfiguration/utils.go | 4 +- .../typed/core/v1alpha1/core_client.go | 6 +- .../core/v1alpha1/fake/fake_core_client.go | 4 +- .../typed/core/v1alpha1/fake/fake_model.go | 188 ------------- .../core/v1alpha1/fake/fake_openmodel.go | 188 +++++++++++++ .../core/v1alpha1/generated_expansion.go | 2 +- .../versioned/typed/core/v1alpha1/model.go | 255 ------------------ .../typed/core/v1alpha1/openmodel.go | 255 ++++++++++++++++++ .../core/v1alpha1/interface.go | 10 +- .../core/v1alpha1/{model.go => openmodel.go} | 38 +-- .../informers/externalversions/generic.go | 4 +- .../core/v1alpha1/expansion_generated.go | 12 +- client-go/listers/core/v1alpha1/model.go | 98 ------- client-go/listers/core/v1alpha1/openmodel.go | 98 +++++++ cmd/main.go | 2 +- ...o_models.yaml => llmaz.io_openmodels.yaml} | 12 +- config/crd/kustomization.yaml | 6 +- ...s.yaml => cainjection_in__openmodels.yaml} | 2 +- ...odels.yaml => webhook_in__openmodels.yaml} | 2 +- ..._role.yaml => _openmodel_editor_role.yaml} | 10 +- ..._role.yaml => _openmodel_viewer_role.yaml} | 10 +- config/rbac/role.yaml | 6 +- ...a1_model.yaml => _v1alpha1_openmodel.yaml} | 2 +- config/webhook/manifests.yaml | 12 +- docs/examples/sglang/model.yaml | 2 +- docs/examples/vllm-huggingface/model.yaml | 2 +- docs/examples/vllm-modelscope/model.yaml | 2 +- docs/installation.md | 4 +- .../inference/playground_controller.go | 8 +- .../inference/service_controller.go | 10 +- pkg/controller/model_controller.go | 10 +- pkg/controller_helper/backend/backend.go | 2 +- pkg/controller_helper/backend/sglang.go | 2 +- pkg/controller_helper/backend/vllm.go | 2 +- .../model_source/modelhub.go | 2 +- .../model_source/modelsource.go | 2 +- .../model_source/modelsource_test.go | 2 +- ...{model_webhook.go => openmodel_webhook.go} | 36 +-- test/e2e/playground_test.go | 4 +- test/e2e/suit_test.go | 2 +- .../controller/inference/playground_test.go | 4 +- .../controller/inference/service_test.go | 4 +- test/integration/webhook/model_test.go | 32 +-- test/integration/webhook/suit_test.go | 2 +- test/util/mock.go | 2 +- test/util/validation/validate_playground.go | 2 +- test/util/validation/validate_service.go | 6 +- test/util/wrapper/model.go | 30 +-- 52 files changed, 791 insertions(+), 791 deletions(-) rename client-go/applyconfiguration/core/v1alpha1/{model.go => openmodel.go} (78%) delete mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_openmodel.go delete mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/model.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/openmodel.go rename client-go/informers/externalversions/core/v1alpha1/{model.go => openmodel.go} (56%) delete mode 100644 client-go/listers/core/v1alpha1/model.go create mode 100644 client-go/listers/core/v1alpha1/openmodel.go rename config/crd/bases/{llmaz.io_models.yaml => llmaz.io_openmodels.yaml} (98%) rename config/crd/patches/{cainjection_in__models.yaml => cainjection_in__openmodels.yaml} (89%) rename config/crd/patches/{webhook_in__models.yaml => webhook_in__openmodels.yaml} (92%) rename config/rbac/{_model_editor_role.yaml => _openmodel_editor_role.yaml} (73%) rename config/rbac/{_model_viewer_role.yaml => _openmodel_viewer_role.yaml} (71%) rename config/samples/{_v1alpha1_model.yaml => _v1alpha1_openmodel.yaml} (97%) rename pkg/webhook/{model_webhook.go => openmodel_webhook.go} (58%) diff --git a/README.md b/README.md index 94217cb..5e2bb54 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Read the [Installation](./docs/installation.md) for guidance. ### Deploy Here's a simplest sample for deploying `facebook/opt-125m`, all you need to do -is to apply the `Model` and `Playground` yamls. +is to apply a `Model` and a `Playground`. Please refer to **[examples](/docs/examples/README.md)** to learn more. @@ -41,7 +41,7 @@ Please refer to **[examples](/docs/examples/README.md)** to learn more. ```yaml apiVersion: llmaz.io/v1alpha1 -kind: Model +kind: OpenModel metadata: name: opt-125m spec: diff --git a/api/core/v1alpha1/model_types.go b/api/core/v1alpha1/model_types.go index c2931d9..cf61e55 100644 --- a/api/core/v1alpha1/model_types.go +++ b/api/core/v1alpha1/model_types.go @@ -154,8 +154,8 @@ type ModelStatus struct { //+kubebuilder:subresource:status //+kubebuilder:resource:scope=Cluster -// Model is the Schema for the models API -type Model struct { +// OpenModel is the Schema for the open models API +type OpenModel struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -165,13 +165,13 @@ type Model struct { //+kubebuilder:object:root=true -// ModelList contains a list of Model -type ModelList struct { +// OpenModelList contains a list of OpenModel +type OpenModelList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []Model `json:"items"` + Items []OpenModel `json:"items"` } func init() { - SchemeBuilder.Register(&Model{}, &ModelList{}) + SchemeBuilder.Register(&OpenModel{}, &OpenModelList{}) } diff --git a/api/core/v1alpha1/zz_generated.deepcopy.go b/api/core/v1alpha1/zz_generated.deepcopy.go index da9e4ef..10c3c08 100644 --- a/api/core/v1alpha1/zz_generated.deepcopy.go +++ b/api/core/v1alpha1/zz_generated.deepcopy.go @@ -62,33 +62,6 @@ func (in *Flavor) DeepCopy() *Flavor { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Model) DeepCopyInto(out *Model) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Model. -func (in *Model) DeepCopy() *Model { - if in == nil { - return nil - } - out := new(Model) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Model) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ModelClaim) DeepCopyInto(out *ModelClaim) { *out = *in @@ -134,38 +107,6 @@ func (in *ModelHub) DeepCopy() *ModelHub { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ModelList) DeepCopyInto(out *ModelList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Model, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ModelList. -func (in *ModelList) DeepCopy() *ModelList { - if in == nil { - return nil - } - out := new(ModelList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ModelList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ModelSource) DeepCopyInto(out *ModelSource) { *out = *in @@ -260,3 +201,62 @@ func (in *MultiModelsClaim) DeepCopy() *MultiModelsClaim { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenModel) DeepCopyInto(out *OpenModel) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenModel. +func (in *OpenModel) DeepCopy() *OpenModel { + if in == nil { + return nil + } + out := new(OpenModel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OpenModel) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenModelList) DeepCopyInto(out *OpenModelList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OpenModel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenModelList. +func (in *OpenModelList) DeepCopy() *OpenModelList { + if in == nil { + return nil + } + out := new(OpenModelList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OpenModelList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/client-go/applyconfiguration/core/v1alpha1/model.go b/client-go/applyconfiguration/core/v1alpha1/openmodel.go similarity index 78% rename from client-go/applyconfiguration/core/v1alpha1/model.go rename to client-go/applyconfiguration/core/v1alpha1/openmodel.go index 4fcce23..e855cf0 100644 --- a/client-go/applyconfiguration/core/v1alpha1/model.go +++ b/client-go/applyconfiguration/core/v1alpha1/openmodel.go @@ -23,22 +23,22 @@ import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) -// ModelApplyConfiguration represents an declarative configuration of the Model type for use +// OpenModelApplyConfiguration represents an declarative configuration of the OpenModel type for use // with apply. -type ModelApplyConfiguration struct { +type OpenModelApplyConfiguration struct { v1.TypeMetaApplyConfiguration `json:",inline"` *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` Spec *ModelSpecApplyConfiguration `json:"spec,omitempty"` Status *ModelStatusApplyConfiguration `json:"status,omitempty"` } -// Model constructs an declarative configuration of the Model type for use with +// OpenModel constructs an declarative configuration of the OpenModel type for use with // apply. -func Model(name, namespace string) *ModelApplyConfiguration { - b := &ModelApplyConfiguration{} +func OpenModel(name, namespace string) *OpenModelApplyConfiguration { + b := &OpenModelApplyConfiguration{} b.WithName(name) b.WithNamespace(namespace) - b.WithKind("Model") + b.WithKind("OpenModel") b.WithAPIVersion("llmaz.io/v1alpha1") return b } @@ -46,7 +46,7 @@ func Model(name, namespace string) *ModelApplyConfiguration { // WithKind sets the Kind field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Kind field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithKind(value string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithKind(value string) *OpenModelApplyConfiguration { b.Kind = &value return b } @@ -54,7 +54,7 @@ func (b *ModelApplyConfiguration) WithKind(value string) *ModelApplyConfiguratio // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the APIVersion field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithAPIVersion(value string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithAPIVersion(value string) *OpenModelApplyConfiguration { b.APIVersion = &value return b } @@ -62,7 +62,7 @@ func (b *ModelApplyConfiguration) WithAPIVersion(value string) *ModelApplyConfig // WithName sets the Name field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Name field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithName(value string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithName(value string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.Name = &value return b @@ -71,7 +71,7 @@ func (b *ModelApplyConfiguration) WithName(value string) *ModelApplyConfiguratio // WithGenerateName sets the GenerateName field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the GenerateName field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithGenerateName(value string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithGenerateName(value string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.GenerateName = &value return b @@ -80,7 +80,7 @@ func (b *ModelApplyConfiguration) WithGenerateName(value string) *ModelApplyConf // WithNamespace sets the Namespace field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Namespace field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithNamespace(value string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithNamespace(value string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.Namespace = &value return b @@ -89,7 +89,7 @@ func (b *ModelApplyConfiguration) WithNamespace(value string) *ModelApplyConfigu // WithUID sets the UID field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the UID field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithUID(value types.UID) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithUID(value types.UID) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.UID = &value return b @@ -98,7 +98,7 @@ func (b *ModelApplyConfiguration) WithUID(value types.UID) *ModelApplyConfigurat // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ResourceVersion field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithResourceVersion(value string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithResourceVersion(value string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ResourceVersion = &value return b @@ -107,7 +107,7 @@ func (b *ModelApplyConfiguration) WithResourceVersion(value string) *ModelApplyC // WithGeneration sets the Generation field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Generation field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithGeneration(value int64) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithGeneration(value int64) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.Generation = &value return b @@ -116,7 +116,7 @@ func (b *ModelApplyConfiguration) WithGeneration(value int64) *ModelApplyConfigu // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the CreationTimestamp field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithCreationTimestamp(value metav1.Time) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.CreationTimestamp = &value return b @@ -125,7 +125,7 @@ func (b *ModelApplyConfiguration) WithCreationTimestamp(value metav1.Time) *Mode // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the DeletionTimestamp field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.DeletionTimestamp = &value return b @@ -134,7 +134,7 @@ func (b *ModelApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *Mode // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.DeletionGracePeriodSeconds = &value return b @@ -144,7 +144,7 @@ func (b *ModelApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *M // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, the entries provided by each call will be put on the Labels field, // overwriting an existing map entries in Labels field with the same key. -func (b *ModelApplyConfiguration) WithLabels(entries map[string]string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithLabels(entries map[string]string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() if b.Labels == nil && len(entries) > 0 { b.Labels = make(map[string]string, len(entries)) @@ -159,7 +159,7 @@ func (b *ModelApplyConfiguration) WithLabels(entries map[string]string) *ModelAp // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, the entries provided by each call will be put on the Annotations field, // overwriting an existing map entries in Annotations field with the same key. -func (b *ModelApplyConfiguration) WithAnnotations(entries map[string]string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithAnnotations(entries map[string]string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() if b.Annotations == nil && len(entries) > 0 { b.Annotations = make(map[string]string, len(entries)) @@ -173,7 +173,7 @@ func (b *ModelApplyConfiguration) WithAnnotations(entries map[string]string) *Mo // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the OwnerReferences field. -func (b *ModelApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { if values[i] == nil { @@ -187,7 +187,7 @@ func (b *ModelApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferen // WithFinalizers adds the given value to the Finalizers field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the Finalizers field. -func (b *ModelApplyConfiguration) WithFinalizers(values ...string) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithFinalizers(values ...string) *OpenModelApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { b.Finalizers = append(b.Finalizers, values[i]) @@ -195,7 +195,7 @@ func (b *ModelApplyConfiguration) WithFinalizers(values ...string) *ModelApplyCo return b } -func (b *ModelApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { +func (b *OpenModelApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { if b.ObjectMetaApplyConfiguration == nil { b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} } @@ -204,7 +204,7 @@ func (b *ModelApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { // WithSpec sets the Spec field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Spec field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithSpec(value *ModelSpecApplyConfiguration) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithSpec(value *ModelSpecApplyConfiguration) *OpenModelApplyConfiguration { b.Spec = value return b } @@ -212,7 +212,7 @@ func (b *ModelApplyConfiguration) WithSpec(value *ModelSpecApplyConfiguration) * // WithStatus sets the Status field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Status field is set to the value of the last call. -func (b *ModelApplyConfiguration) WithStatus(value *ModelStatusApplyConfiguration) *ModelApplyConfiguration { +func (b *OpenModelApplyConfiguration) WithStatus(value *ModelStatusApplyConfiguration) *OpenModelApplyConfiguration { b.Status = value return b } diff --git a/client-go/applyconfiguration/utils.go b/client-go/applyconfiguration/utils.go index f71fd87..39e2b54 100644 --- a/client-go/applyconfiguration/utils.go +++ b/client-go/applyconfiguration/utils.go @@ -52,8 +52,6 @@ func ForKind(kind schema.GroupVersionKind) interface{} { // Group=llmaz.io, Version=v1alpha1 case corev1alpha1.SchemeGroupVersion.WithKind("Flavor"): return &applyconfigurationcorev1alpha1.FlavorApplyConfiguration{} - case corev1alpha1.SchemeGroupVersion.WithKind("Model"): - return &applyconfigurationcorev1alpha1.ModelApplyConfiguration{} case corev1alpha1.SchemeGroupVersion.WithKind("ModelClaim"): return &applyconfigurationcorev1alpha1.ModelClaimApplyConfiguration{} case corev1alpha1.SchemeGroupVersion.WithKind("ModelHub"): @@ -66,6 +64,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &applyconfigurationcorev1alpha1.ModelStatusApplyConfiguration{} case corev1alpha1.SchemeGroupVersion.WithKind("MultiModelsClaim"): return &applyconfigurationcorev1alpha1.MultiModelsClaimApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("OpenModel"): + return &applyconfigurationcorev1alpha1.OpenModelApplyConfiguration{} } return nil diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go b/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go index e21101d..95f317f 100644 --- a/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go +++ b/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go @@ -27,7 +27,7 @@ import ( type LlmazV1alpha1Interface interface { RESTClient() rest.Interface - ModelsGetter + OpenModelsGetter } // LlmazV1alpha1Client is used to interact with features provided by the llmaz.io group. @@ -35,8 +35,8 @@ type LlmazV1alpha1Client struct { restClient rest.Interface } -func (c *LlmazV1alpha1Client) Models(namespace string) ModelInterface { - return newModels(c, namespace) +func (c *LlmazV1alpha1Client) OpenModels(namespace string) OpenModelInterface { + return newOpenModels(c, namespace) } // NewForConfig creates a new LlmazV1alpha1Client for the given config. diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go index 5f1fa65..443fe8a 100644 --- a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go +++ b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go @@ -27,8 +27,8 @@ type FakeLlmazV1alpha1 struct { *testing.Fake } -func (c *FakeLlmazV1alpha1) Models(namespace string) v1alpha1.ModelInterface { - return &FakeModels{c, namespace} +func (c *FakeLlmazV1alpha1) OpenModels(namespace string) v1alpha1.OpenModelInterface { + return &FakeOpenModels{c, namespace} } // RESTClient returns a RESTClient that is used to communicate diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go deleted file mode 100644 index b243d0b..0000000 --- a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go +++ /dev/null @@ -1,188 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - json "encoding/json" - "fmt" - - v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" - corev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeModels implements ModelInterface -type FakeModels struct { - Fake *FakeLlmazV1alpha1 - ns string -} - -var modelsResource = v1alpha1.SchemeGroupVersion.WithResource("models") - -var modelsKind = v1alpha1.SchemeGroupVersion.WithKind("Model") - -// Get takes name of the model, and returns the corresponding model object, and an error if there is any. -func (c *FakeModels) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Model, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(modelsResource, c.ns, name), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} - -// List takes label and field selectors, and returns the list of Models that match those selectors. -func (c *FakeModels) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ModelList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(modelsResource, modelsKind, c.ns, opts), &v1alpha1.ModelList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ModelList{ListMeta: obj.(*v1alpha1.ModelList).ListMeta} - for _, item := range obj.(*v1alpha1.ModelList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested models. -func (c *FakeModels) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(modelsResource, c.ns, opts)) - -} - -// Create takes the representation of a model and creates it. Returns the server's representation of the model, and an error, if there is any. -func (c *FakeModels) Create(ctx context.Context, model *v1alpha1.Model, opts v1.CreateOptions) (result *v1alpha1.Model, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(modelsResource, c.ns, model), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} - -// Update takes the representation of a model and updates it. Returns the server's representation of the model, and an error, if there is any. -func (c *FakeModels) Update(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (result *v1alpha1.Model, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(modelsResource, c.ns, model), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeModels) UpdateStatus(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (*v1alpha1.Model, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(modelsResource, "status", c.ns, model), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} - -// Delete takes name of the model and deletes it. Returns an error if one occurs. -func (c *FakeModels) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(modelsResource, c.ns, name, opts), &v1alpha1.Model{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeModels) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(modelsResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.ModelList{}) - return err -} - -// Patch applies the patch and returns the patched model. -func (c *FakeModels) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Model, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(modelsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} - -// Apply takes the given apply declarative configuration, applies it and returns the applied model. -func (c *FakeModels) Apply(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { - if model == nil { - return nil, fmt.Errorf("model provided to Apply must not be nil") - } - data, err := json.Marshal(model) - if err != nil { - return nil, err - } - name := model.Name - if name == nil { - return nil, fmt.Errorf("model.Name must be provided to Apply") - } - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(modelsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} - -// ApplyStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -func (c *FakeModels) ApplyStatus(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { - if model == nil { - return nil, fmt.Errorf("model provided to Apply must not be nil") - } - data, err := json.Marshal(model) - if err != nil { - return nil, err - } - name := model.Name - if name == nil { - return nil, fmt.Errorf("model.Name must be provided to Apply") - } - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(modelsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Model{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Model), err -} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_openmodel.go b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_openmodel.go new file mode 100644 index 0000000..a9ebb4a --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_openmodel.go @@ -0,0 +1,188 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + corev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeOpenModels implements OpenModelInterface +type FakeOpenModels struct { + Fake *FakeLlmazV1alpha1 + ns string +} + +var openmodelsResource = v1alpha1.SchemeGroupVersion.WithResource("openmodels") + +var openmodelsKind = v1alpha1.SchemeGroupVersion.WithKind("OpenModel") + +// Get takes name of the openModel, and returns the corresponding openModel object, and an error if there is any. +func (c *FakeOpenModels) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.OpenModel, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(openmodelsResource, c.ns, name), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} + +// List takes label and field selectors, and returns the list of OpenModels that match those selectors. +func (c *FakeOpenModels) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.OpenModelList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(openmodelsResource, openmodelsKind, c.ns, opts), &v1alpha1.OpenModelList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.OpenModelList{ListMeta: obj.(*v1alpha1.OpenModelList).ListMeta} + for _, item := range obj.(*v1alpha1.OpenModelList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested openModels. +func (c *FakeOpenModels) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(openmodelsResource, c.ns, opts)) + +} + +// Create takes the representation of a openModel and creates it. Returns the server's representation of the openModel, and an error, if there is any. +func (c *FakeOpenModels) Create(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.CreateOptions) (result *v1alpha1.OpenModel, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(openmodelsResource, c.ns, openModel), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} + +// Update takes the representation of a openModel and updates it. Returns the server's representation of the openModel, and an error, if there is any. +func (c *FakeOpenModels) Update(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.UpdateOptions) (result *v1alpha1.OpenModel, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(openmodelsResource, c.ns, openModel), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeOpenModels) UpdateStatus(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.UpdateOptions) (*v1alpha1.OpenModel, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(openmodelsResource, "status", c.ns, openModel), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} + +// Delete takes name of the openModel and deletes it. Returns an error if one occurs. +func (c *FakeOpenModels) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(openmodelsResource, c.ns, name, opts), &v1alpha1.OpenModel{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeOpenModels) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(openmodelsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.OpenModelList{}) + return err +} + +// Patch applies the patch and returns the patched openModel. +func (c *FakeOpenModels) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OpenModel, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(openmodelsResource, c.ns, name, pt, data, subresources...), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied openModel. +func (c *FakeOpenModels) Apply(ctx context.Context, openModel *corev1alpha1.OpenModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.OpenModel, err error) { + if openModel == nil { + return nil, fmt.Errorf("openModel provided to Apply must not be nil") + } + data, err := json.Marshal(openModel) + if err != nil { + return nil, err + } + name := openModel.Name + if name == nil { + return nil, fmt.Errorf("openModel.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(openmodelsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeOpenModels) ApplyStatus(ctx context.Context, openModel *corev1alpha1.OpenModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.OpenModel, err error) { + if openModel == nil { + return nil, fmt.Errorf("openModel provided to Apply must not be nil") + } + data, err := json.Marshal(openModel) + if err != nil { + return nil, err + } + name := openModel.Name + if name == nil { + return nil, fmt.Errorf("openModel.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(openmodelsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.OpenModel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.OpenModel), err +} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go b/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go index 0d589e9..9dee52b 100644 --- a/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go +++ b/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go @@ -17,4 +17,4 @@ limitations under the License. package v1alpha1 -type ModelExpansion interface{} +type OpenModelExpansion interface{} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/model.go b/client-go/clientset/versioned/typed/core/v1alpha1/model.go deleted file mode 100644 index 4344174..0000000 --- a/client-go/clientset/versioned/typed/core/v1alpha1/model.go +++ /dev/null @@ -1,255 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - json "encoding/json" - "fmt" - "time" - - v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" - corev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" - scheme "inftyai.com/llmaz/client-go/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ModelsGetter has a method to return a ModelInterface. -// A group's client should implement this interface. -type ModelsGetter interface { - Models(namespace string) ModelInterface -} - -// ModelInterface has methods to work with Model resources. -type ModelInterface interface { - Create(ctx context.Context, model *v1alpha1.Model, opts v1.CreateOptions) (*v1alpha1.Model, error) - Update(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (*v1alpha1.Model, error) - UpdateStatus(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (*v1alpha1.Model, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Model, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ModelList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Model, err error) - Apply(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) - ApplyStatus(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) - ModelExpansion -} - -// models implements ModelInterface -type models struct { - client rest.Interface - ns string -} - -// newModels returns a Models -func newModels(c *LlmazV1alpha1Client, namespace string) *models { - return &models{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the model, and returns the corresponding model object, and an error if there is any. -func (c *models) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Model, err error) { - result = &v1alpha1.Model{} - err = c.client.Get(). - Namespace(c.ns). - Resource("models"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Models that match those selectors. -func (c *models) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ModelList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ModelList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("models"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested models. -func (c *models) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("models"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a model and creates it. Returns the server's representation of the model, and an error, if there is any. -func (c *models) Create(ctx context.Context, model *v1alpha1.Model, opts v1.CreateOptions) (result *v1alpha1.Model, err error) { - result = &v1alpha1.Model{} - err = c.client.Post(). - Namespace(c.ns). - Resource("models"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(model). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a model and updates it. Returns the server's representation of the model, and an error, if there is any. -func (c *models) Update(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (result *v1alpha1.Model, err error) { - result = &v1alpha1.Model{} - err = c.client.Put(). - Namespace(c.ns). - Resource("models"). - Name(model.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(model). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *models) UpdateStatus(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (result *v1alpha1.Model, err error) { - result = &v1alpha1.Model{} - err = c.client.Put(). - Namespace(c.ns). - Resource("models"). - Name(model.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(model). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the model and deletes it. Returns an error if one occurs. -func (c *models) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("models"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *models) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("models"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched model. -func (c *models) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Model, err error) { - result = &v1alpha1.Model{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("models"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} - -// Apply takes the given apply declarative configuration, applies it and returns the applied model. -func (c *models) Apply(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { - if model == nil { - return nil, fmt.Errorf("model provided to Apply must not be nil") - } - patchOpts := opts.ToPatchOptions() - data, err := json.Marshal(model) - if err != nil { - return nil, err - } - name := model.Name - if name == nil { - return nil, fmt.Errorf("model.Name must be provided to Apply") - } - result = &v1alpha1.Model{} - err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). - Resource("models"). - Name(*name). - VersionedParams(&patchOpts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} - -// ApplyStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -func (c *models) ApplyStatus(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { - if model == nil { - return nil, fmt.Errorf("model provided to Apply must not be nil") - } - patchOpts := opts.ToPatchOptions() - data, err := json.Marshal(model) - if err != nil { - return nil, err - } - - name := model.Name - if name == nil { - return nil, fmt.Errorf("model.Name must be provided to Apply") - } - - result = &v1alpha1.Model{} - err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). - Resource("models"). - Name(*name). - SubResource("status"). - VersionedParams(&patchOpts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/openmodel.go b/client-go/clientset/versioned/typed/core/v1alpha1/openmodel.go new file mode 100644 index 0000000..e25a9dc --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/openmodel.go @@ -0,0 +1,255 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + corev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + scheme "inftyai.com/llmaz/client-go/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// OpenModelsGetter has a method to return a OpenModelInterface. +// A group's client should implement this interface. +type OpenModelsGetter interface { + OpenModels(namespace string) OpenModelInterface +} + +// OpenModelInterface has methods to work with OpenModel resources. +type OpenModelInterface interface { + Create(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.CreateOptions) (*v1alpha1.OpenModel, error) + Update(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.UpdateOptions) (*v1alpha1.OpenModel, error) + UpdateStatus(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.UpdateOptions) (*v1alpha1.OpenModel, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.OpenModel, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.OpenModelList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OpenModel, err error) + Apply(ctx context.Context, openModel *corev1alpha1.OpenModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.OpenModel, err error) + ApplyStatus(ctx context.Context, openModel *corev1alpha1.OpenModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.OpenModel, err error) + OpenModelExpansion +} + +// openModels implements OpenModelInterface +type openModels struct { + client rest.Interface + ns string +} + +// newOpenModels returns a OpenModels +func newOpenModels(c *LlmazV1alpha1Client, namespace string) *openModels { + return &openModels{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the openModel, and returns the corresponding openModel object, and an error if there is any. +func (c *openModels) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.OpenModel, err error) { + result = &v1alpha1.OpenModel{} + err = c.client.Get(). + Namespace(c.ns). + Resource("openmodels"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of OpenModels that match those selectors. +func (c *openModels) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.OpenModelList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.OpenModelList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("openmodels"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested openModels. +func (c *openModels) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("openmodels"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a openModel and creates it. Returns the server's representation of the openModel, and an error, if there is any. +func (c *openModels) Create(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.CreateOptions) (result *v1alpha1.OpenModel, err error) { + result = &v1alpha1.OpenModel{} + err = c.client.Post(). + Namespace(c.ns). + Resource("openmodels"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(openModel). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a openModel and updates it. Returns the server's representation of the openModel, and an error, if there is any. +func (c *openModels) Update(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.UpdateOptions) (result *v1alpha1.OpenModel, err error) { + result = &v1alpha1.OpenModel{} + err = c.client.Put(). + Namespace(c.ns). + Resource("openmodels"). + Name(openModel.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(openModel). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *openModels) UpdateStatus(ctx context.Context, openModel *v1alpha1.OpenModel, opts v1.UpdateOptions) (result *v1alpha1.OpenModel, err error) { + result = &v1alpha1.OpenModel{} + err = c.client.Put(). + Namespace(c.ns). + Resource("openmodels"). + Name(openModel.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(openModel). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the openModel and deletes it. Returns an error if one occurs. +func (c *openModels) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("openmodels"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *openModels) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("openmodels"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched openModel. +func (c *openModels) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OpenModel, err error) { + result = &v1alpha1.OpenModel{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("openmodels"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied openModel. +func (c *openModels) Apply(ctx context.Context, openModel *corev1alpha1.OpenModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.OpenModel, err error) { + if openModel == nil { + return nil, fmt.Errorf("openModel provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(openModel) + if err != nil { + return nil, err + } + name := openModel.Name + if name == nil { + return nil, fmt.Errorf("openModel.Name must be provided to Apply") + } + result = &v1alpha1.OpenModel{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("openmodels"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *openModels) ApplyStatus(ctx context.Context, openModel *corev1alpha1.OpenModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.OpenModel, err error) { + if openModel == nil { + return nil, fmt.Errorf("openModel provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(openModel) + if err != nil { + return nil, err + } + + name := openModel.Name + if name == nil { + return nil, fmt.Errorf("openModel.Name must be provided to Apply") + } + + result = &v1alpha1.OpenModel{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("openmodels"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/informers/externalversions/core/v1alpha1/interface.go b/client-go/informers/externalversions/core/v1alpha1/interface.go index 3aa3188..b58fd8c 100644 --- a/client-go/informers/externalversions/core/v1alpha1/interface.go +++ b/client-go/informers/externalversions/core/v1alpha1/interface.go @@ -23,8 +23,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // Models returns a ModelInformer. - Models() ModelInformer + // OpenModels returns a OpenModelInformer. + OpenModels() OpenModelInformer } type version struct { @@ -38,7 +38,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// Models returns a ModelInformer. -func (v *version) Models() ModelInformer { - return &modelInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +// OpenModels returns a OpenModelInformer. +func (v *version) OpenModels() OpenModelInformer { + return &openModelInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } diff --git a/client-go/informers/externalversions/core/v1alpha1/model.go b/client-go/informers/externalversions/core/v1alpha1/openmodel.go similarity index 56% rename from client-go/informers/externalversions/core/v1alpha1/model.go rename to client-go/informers/externalversions/core/v1alpha1/openmodel.go index 52a504f..a2e9971 100644 --- a/client-go/informers/externalversions/core/v1alpha1/model.go +++ b/client-go/informers/externalversions/core/v1alpha1/openmodel.go @@ -31,59 +31,59 @@ import ( cache "k8s.io/client-go/tools/cache" ) -// ModelInformer provides access to a shared informer and lister for -// Models. -type ModelInformer interface { +// OpenModelInformer provides access to a shared informer and lister for +// OpenModels. +type OpenModelInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.ModelLister + Lister() v1alpha1.OpenModelLister } -type modelInformer struct { +type openModelInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } -// NewModelInformer constructs a new informer for Model type. +// NewOpenModelInformer constructs a new informer for OpenModel type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewModelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredModelInformer(client, namespace, resyncPeriod, indexers, nil) +func NewOpenModelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredOpenModelInformer(client, namespace, resyncPeriod, indexers, nil) } -// NewFilteredModelInformer constructs a new informer for Model type. +// NewFilteredOpenModelInformer constructs a new informer for OpenModel type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredModelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredOpenModelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.LlmazV1alpha1().Models(namespace).List(context.TODO(), options) + return client.LlmazV1alpha1().OpenModels(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.LlmazV1alpha1().Models(namespace).Watch(context.TODO(), options) + return client.LlmazV1alpha1().OpenModels(namespace).Watch(context.TODO(), options) }, }, - &corev1alpha1.Model{}, + &corev1alpha1.OpenModel{}, resyncPeriod, indexers, ) } -func (f *modelInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredModelInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +func (f *openModelInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredOpenModelInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } -func (f *modelInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&corev1alpha1.Model{}, f.defaultInformer) +func (f *openModelInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.OpenModel{}, f.defaultInformer) } -func (f *modelInformer) Lister() v1alpha1.ModelLister { - return v1alpha1.NewModelLister(f.Informer().GetIndexer()) +func (f *openModelInformer) Lister() v1alpha1.OpenModelLister { + return v1alpha1.NewOpenModelLister(f.Informer().GetIndexer()) } diff --git a/client-go/informers/externalversions/generic.go b/client-go/informers/externalversions/generic.go index 8c3b7bf..9f3df80 100644 --- a/client-go/informers/externalversions/generic.go +++ b/client-go/informers/externalversions/generic.go @@ -59,8 +59,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Inference().V1alpha1().Services().Informer()}, nil // Group=llmaz.io, Version=v1alpha1 - case corev1alpha1.SchemeGroupVersion.WithResource("models"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Llmaz().V1alpha1().Models().Informer()}, nil + case corev1alpha1.SchemeGroupVersion.WithResource("openmodels"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Llmaz().V1alpha1().OpenModels().Informer()}, nil } diff --git a/client-go/listers/core/v1alpha1/expansion_generated.go b/client-go/listers/core/v1alpha1/expansion_generated.go index 044089d..d23a8b1 100644 --- a/client-go/listers/core/v1alpha1/expansion_generated.go +++ b/client-go/listers/core/v1alpha1/expansion_generated.go @@ -17,10 +17,10 @@ limitations under the License. package v1alpha1 -// ModelListerExpansion allows custom methods to be added to -// ModelLister. -type ModelListerExpansion interface{} +// OpenModelListerExpansion allows custom methods to be added to +// OpenModelLister. +type OpenModelListerExpansion interface{} -// ModelNamespaceListerExpansion allows custom methods to be added to -// ModelNamespaceLister. -type ModelNamespaceListerExpansion interface{} +// OpenModelNamespaceListerExpansion allows custom methods to be added to +// OpenModelNamespaceLister. +type OpenModelNamespaceListerExpansion interface{} diff --git a/client-go/listers/core/v1alpha1/model.go b/client-go/listers/core/v1alpha1/model.go deleted file mode 100644 index 833ca03..0000000 --- a/client-go/listers/core/v1alpha1/model.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ModelLister helps list Models. -// All objects returned here must be treated as read-only. -type ModelLister interface { - // List lists all Models in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Model, err error) - // Models returns an object that can list and get Models. - Models(namespace string) ModelNamespaceLister - ModelListerExpansion -} - -// modelLister implements the ModelLister interface. -type modelLister struct { - indexer cache.Indexer -} - -// NewModelLister returns a new ModelLister. -func NewModelLister(indexer cache.Indexer) ModelLister { - return &modelLister{indexer: indexer} -} - -// List lists all Models in the indexer. -func (s *modelLister) List(selector labels.Selector) (ret []*v1alpha1.Model, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Model)) - }) - return ret, err -} - -// Models returns an object that can list and get Models. -func (s *modelLister) Models(namespace string) ModelNamespaceLister { - return modelNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ModelNamespaceLister helps list and get Models. -// All objects returned here must be treated as read-only. -type ModelNamespaceLister interface { - // List lists all Models in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Model, err error) - // Get retrieves the Model from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.Model, error) - ModelNamespaceListerExpansion -} - -// modelNamespaceLister implements the ModelNamespaceLister -// interface. -type modelNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Models in the indexer for a given namespace. -func (s modelNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Model, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Model)) - }) - return ret, err -} - -// Get retrieves the Model from the indexer for a given namespace and name. -func (s modelNamespaceLister) Get(name string) (*v1alpha1.Model, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("model"), name) - } - return obj.(*v1alpha1.Model), nil -} diff --git a/client-go/listers/core/v1alpha1/openmodel.go b/client-go/listers/core/v1alpha1/openmodel.go new file mode 100644 index 0000000..02aafc5 --- /dev/null +++ b/client-go/listers/core/v1alpha1/openmodel.go @@ -0,0 +1,98 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// OpenModelLister helps list OpenModels. +// All objects returned here must be treated as read-only. +type OpenModelLister interface { + // List lists all OpenModels in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.OpenModel, err error) + // OpenModels returns an object that can list and get OpenModels. + OpenModels(namespace string) OpenModelNamespaceLister + OpenModelListerExpansion +} + +// openModelLister implements the OpenModelLister interface. +type openModelLister struct { + indexer cache.Indexer +} + +// NewOpenModelLister returns a new OpenModelLister. +func NewOpenModelLister(indexer cache.Indexer) OpenModelLister { + return &openModelLister{indexer: indexer} +} + +// List lists all OpenModels in the indexer. +func (s *openModelLister) List(selector labels.Selector) (ret []*v1alpha1.OpenModel, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.OpenModel)) + }) + return ret, err +} + +// OpenModels returns an object that can list and get OpenModels. +func (s *openModelLister) OpenModels(namespace string) OpenModelNamespaceLister { + return openModelNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// OpenModelNamespaceLister helps list and get OpenModels. +// All objects returned here must be treated as read-only. +type OpenModelNamespaceLister interface { + // List lists all OpenModels in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.OpenModel, err error) + // Get retrieves the OpenModel from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.OpenModel, error) + OpenModelNamespaceListerExpansion +} + +// openModelNamespaceLister implements the OpenModelNamespaceLister +// interface. +type openModelNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all OpenModels in the indexer for a given namespace. +func (s openModelNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.OpenModel, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.OpenModel)) + }) + return ret, err +} + +// Get retrieves the OpenModel from the indexer for a given namespace and name. +func (s openModelNamespaceLister) Get(name string) (*v1alpha1.OpenModel, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("openmodel"), name) + } + return obj.(*v1alpha1.OpenModel), nil +} diff --git a/cmd/main.go b/cmd/main.go index f1b5dc3..ba04442 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -157,7 +157,7 @@ func setupControllers(mgr ctrl.Manager, certsReady chan struct{}) { } if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err := webhook.SetupModelWebhook(mgr); err != nil { + if err := webhook.SetupOpenModelWebhook(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "Model") os.Exit(1) } diff --git a/config/crd/bases/llmaz.io_models.yaml b/config/crd/bases/llmaz.io_openmodels.yaml similarity index 98% rename from config/crd/bases/llmaz.io_models.yaml rename to config/crd/bases/llmaz.io_openmodels.yaml index a18a73d..2327ccd 100644 --- a/config/crd/bases/llmaz.io_models.yaml +++ b/config/crd/bases/llmaz.io_openmodels.yaml @@ -4,20 +4,20 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 - name: models.llmaz.io + name: openmodels.llmaz.io spec: group: llmaz.io names: - kind: Model - listKind: ModelList - plural: models - singular: model + kind: OpenModel + listKind: OpenModelList + plural: openmodels + singular: openmodel scope: Cluster versions: - name: v1alpha1 schema: openAPIV3Schema: - description: Model is the Schema for the models API + description: OpenModel is the Schema for the open models API properties: apiVersion: description: |- diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 7ee5bd0..fa8f701 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -4,7 +4,7 @@ resources: - bases/inference.llmaz.io_services.yaml - bases/inference.llmaz.io_playgrounds.yaml -- bases/llmaz.io_models.yaml +- bases/llmaz.io_openmodels.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: @@ -12,14 +12,14 @@ patches: # patches here are for enabling the conversion webhook for each CRD # - path: patches/webhook_in_inference_services.yaml # - path: patches/webhook_in_inference_playgrounds.yaml -- path: patches/webhook_in__models.yaml +- path: patches/webhook_in__openmodels.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- path: patches/cainjection_in_inference_services.yaml #- path: patches/cainjection_in_inference_playgrounds.yaml -#- path: patches/cainjection_in__models.yaml +#- path: patches/cainjection_in__openmodels.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/config/crd/patches/cainjection_in__models.yaml b/config/crd/patches/cainjection_in__openmodels.yaml similarity index 89% rename from config/crd/patches/cainjection_in__models.yaml rename to config/crd/patches/cainjection_in__openmodels.yaml index 33675f7..acef01d 100644 --- a/config/crd/patches/cainjection_in__models.yaml +++ b/config/crd/patches/cainjection_in__openmodels.yaml @@ -4,4 +4,4 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: models.llmaz.io + name: openmodels.llmaz.io diff --git a/config/crd/patches/webhook_in__models.yaml b/config/crd/patches/webhook_in__openmodels.yaml similarity index 92% rename from config/crd/patches/webhook_in__models.yaml rename to config/crd/patches/webhook_in__openmodels.yaml index af01869..f06cd32 100644 --- a/config/crd/patches/webhook_in__models.yaml +++ b/config/crd/patches/webhook_in__openmodels.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: models.llmaz.io + name: openmodels.llmaz.io spec: conversion: strategy: Webhook diff --git a/config/rbac/_model_editor_role.yaml b/config/rbac/_openmodel_editor_role.yaml similarity index 73% rename from config/rbac/_model_editor_role.yaml rename to config/rbac/_openmodel_editor_role.yaml index 7c51e1a..f410894 100644 --- a/config/rbac/_model_editor_role.yaml +++ b/config/rbac/_openmodel_editor_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to edit models. +# permissions for end users to edit openmodels. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: model-editor-role + app.kubernetes.io/instance: openmodel-editor-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: llmaz app.kubernetes.io/part-of: llmaz app.kubernetes.io/managed-by: kustomize - name: model-editor-role + name: openmodel-editor-role rules: - apiGroups: - llmaz.io resources: - - models + - openmodels verbs: - create - delete @@ -26,6 +26,6 @@ rules: - apiGroups: - llmaz.io resources: - - models/status + - openmodels/status verbs: - get diff --git a/config/rbac/_model_viewer_role.yaml b/config/rbac/_openmodel_viewer_role.yaml similarity index 71% rename from config/rbac/_model_viewer_role.yaml rename to config/rbac/_openmodel_viewer_role.yaml index b8741f4..8b102fb 100644 --- a/config/rbac/_model_viewer_role.yaml +++ b/config/rbac/_openmodel_viewer_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to view models. +# permissions for end users to view openmodels. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: model-viewer-role + app.kubernetes.io/instance: openmodel-viewer-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: llmaz app.kubernetes.io/part-of: llmaz app.kubernetes.io/managed-by: kustomize - name: model-viewer-role + name: openmodel-viewer-role rules: - apiGroups: - llmaz.io resources: - - models + - openmodels verbs: - get - list @@ -22,6 +22,6 @@ rules: - apiGroups: - llmaz.io resources: - - models/status + - openmodels/status verbs: - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 53bb424..f840a8a 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -106,7 +106,7 @@ rules: - apiGroups: - llmaz.io resources: - - models + - openmodels verbs: - create - delete @@ -118,13 +118,13 @@ rules: - apiGroups: - llmaz.io resources: - - models/finalizers + - openmodels/finalizers verbs: - update - apiGroups: - llmaz.io resources: - - models/status + - openmodels/status verbs: - get - patch diff --git a/config/samples/_v1alpha1_model.yaml b/config/samples/_v1alpha1_openmodel.yaml similarity index 97% rename from config/samples/_v1alpha1_model.yaml rename to config/samples/_v1alpha1_openmodel.yaml index de008c7..6f6b130 100644 --- a/config/samples/_v1alpha1_model.yaml +++ b/config/samples/_v1alpha1_openmodel.yaml @@ -1,5 +1,5 @@ apiVersion: llmaz.io/v1alpha1 -kind: Model +kind: OpenModel metadata: labels: app.kubernetes.io/name: model diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index ec30f21..e11d63b 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -10,9 +10,9 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-llmaz-io-v1alpha1-model + path: /mutate-llmaz-io-v1alpha1-openmodel failurePolicy: Fail - name: mmodel.kb.io + name: mopenmodel.kb.io rules: - apiGroups: - llmaz.io @@ -22,7 +22,7 @@ webhooks: - CREATE - UPDATE resources: - - models + - openmodels sideEffects: None - admissionReviewVersions: - v1 @@ -76,9 +76,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-llmaz-io-v1alpha1-model + path: /validate-llmaz-io-v1alpha1-openmodel failurePolicy: Fail - name: vmodel.kb.io + name: vopenmodel.kb.io rules: - apiGroups: - llmaz.io @@ -88,7 +88,7 @@ webhooks: - CREATE - UPDATE resources: - - models + - openmodels sideEffects: None - admissionReviewVersions: - v1 diff --git a/docs/examples/sglang/model.yaml b/docs/examples/sglang/model.yaml index c65da4e..0658832 100644 --- a/docs/examples/sglang/model.yaml +++ b/docs/examples/sglang/model.yaml @@ -1,5 +1,5 @@ apiVersion: llmaz.io/v1alpha1 -kind: Model +kind: OpenModel metadata: name: qwen2-05b spec: diff --git a/docs/examples/vllm-huggingface/model.yaml b/docs/examples/vllm-huggingface/model.yaml index 76a5d26..169cd92 100644 --- a/docs/examples/vllm-huggingface/model.yaml +++ b/docs/examples/vllm-huggingface/model.yaml @@ -1,5 +1,5 @@ apiVersion: llmaz.io/v1alpha1 -kind: Model +kind: OpenModel metadata: name: opt-125m spec: diff --git a/docs/examples/vllm-modelscope/model.yaml b/docs/examples/vllm-modelscope/model.yaml index f4bb50b..86593fb 100644 --- a/docs/examples/vllm-modelscope/model.yaml +++ b/docs/examples/vllm-modelscope/model.yaml @@ -1,5 +1,5 @@ apiVersion: llmaz.io/v1alpha1 -kind: Model +kind: OpenModel metadata: name: opt-125m spec: diff --git a/docs/installation.md b/docs/installation.md index 53fb786..4cbdb9f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -14,7 +14,7 @@ LWS_VERSION=v0.3.0 kubectl apply --server-side -f https://github.com/kubernetes-sigs/lws/releases/download/$LWS_VERSION/manifests.yaml # llmaz runs in llmaz-system -LLMAZ_VERSION=v0.0.2 +LLMAZ_VERSION=v0.0.3 kubectl apply --server-side -f https://github.com/inftyai/llmaz/releases/download/$LLMAZ_VERSION/manifests.yaml ``` @@ -24,7 +24,7 @@ kubectl apply --server-side -f https://github.com/inftyai/llmaz/releases/downloa LWS_VERSION=v0.3.0 kubectl delete -f https://github.com/kubernetes-sigs/lws/releases/download/$LWS_VERSION/manifests.yaml -LLMAZ_VERSION=v0.0.2 +LLMAZ_VERSION=v0.0.3 kubectl delete -f https://github.com/inftyai/llmaz/releases/download/$LLMAZ_VERSION/manifests.yaml ``` diff --git a/pkg/controller/inference/playground_controller.go b/pkg/controller/inference/playground_controller.go index a9ac8f3..cc82020 100644 --- a/pkg/controller/inference/playground_controller.go +++ b/pkg/controller/inference/playground_controller.go @@ -82,7 +82,7 @@ func (r *PlaygroundReconciler) Reconcile(ctx context.Context, req ctrl.Request) if playground.Spec.ModelClaim != nil { modelName := playground.Spec.ModelClaim.ModelName - model := &coreapi.Model{} + model := &coreapi.OpenModel{} if err := r.Get(ctx, types.NamespacedName{Name: string(modelName)}, model); err != nil { return ctrl.Result{}, err @@ -129,7 +129,7 @@ func (r *PlaygroundReconciler) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } -func buildServiceApplyConfiguration(model *coreapi.Model, playground *inferenceapi.Playground) *inferenceclientgo.ServiceApplyConfiguration { +func buildServiceApplyConfiguration(model *coreapi.OpenModel, playground *inferenceapi.Playground) *inferenceclientgo.ServiceApplyConfiguration { // Build metadata serviceApplyConfiguration := inferenceclientgo.Service(playground.Name, playground.Namespace) @@ -155,7 +155,7 @@ func buildServiceApplyConfiguration(model *coreapi.Model, playground *inferencea // to cover both single-host and multi-host cases. There're some shortages for lws like can not force rolling // update when one replica failed, we'll fix this in the kubernetes upstream. // Model flavors will not be considered but in inferenceService controller to support accelerator fungibility. -func buildWorkloadTemplate(model *coreapi.Model, playground *inferenceapi.Playground) lws.LeaderWorkerSetSpec { +func buildWorkloadTemplate(model *coreapi.OpenModel, playground *inferenceapi.Playground) lws.LeaderWorkerSetSpec { // TODO: this should be leaderWorkerSetTemplateSpec, we should support in the lws upstream. workload := lws.LeaderWorkerSetSpec{ // Use the default policy defined in lws. @@ -174,7 +174,7 @@ func buildWorkloadTemplate(model *coreapi.Model, playground *inferenceapi.Playgr return workload } -func buildWorkerTemplate(model *coreapi.Model, playground *inferenceapi.Playground) corev1.PodTemplateSpec { +func buildWorkerTemplate(model *coreapi.OpenModel, playground *inferenceapi.Playground) corev1.PodTemplateSpec { backendName := inferenceapi.DefaultBackend if playground.Spec.BackendConfig != nil && playground.Spec.BackendConfig.Name != nil { backendName = *playground.Spec.BackendConfig.Name diff --git a/pkg/controller/inference/service_controller.go b/pkg/controller/inference/service_controller.go index 51b4a10..228ef24 100644 --- a/pkg/controller/inference/service_controller.go +++ b/pkg/controller/inference/service_controller.go @@ -77,7 +77,7 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if err := r.Get(ctx, types.NamespacedName{Name: req.Name, Namespace: req.Namespace}, service); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } - model := &coreapi.Model{} + model := &coreapi.OpenModel{} // TODO: multiModelsClaim modelName := service.Spec.MultiModelsClaims[0].ModelNames[0] if err := r.Get(ctx, types.NamespacedName{Name: string(modelName)}, model); err != nil { @@ -124,7 +124,7 @@ func (r *ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } -func buildWorkloadApplyConfiguration(service *inferenceapi.Service, model *coreapi.Model) *applyconfigurationv1.LeaderWorkerSetApplyConfiguration { +func buildWorkloadApplyConfiguration(service *inferenceapi.Service, model *coreapi.OpenModel) *applyconfigurationv1.LeaderWorkerSetApplyConfiguration { workload := applyconfigurationv1.LeaderWorkerSet(service.Name, service.Namespace) leaderWorkerTemplate := applyconfigurationv1.LeaderWorkerTemplate() @@ -141,7 +141,7 @@ func buildWorkloadApplyConfiguration(service *inferenceapi.Service, model *corea return workload } -func injectModelProperties(template *applyconfigurationv1.LeaderWorkerTemplateApplyConfiguration, model *coreapi.Model) { +func injectModelProperties(template *applyconfigurationv1.LeaderWorkerTemplateApplyConfiguration, model *coreapi.OpenModel) { source := modelSource.NewModelSourceProvider(model) template.WorkerTemplate.Labels = util.MergeKVs(template.WorkerTemplate.Labels, modelLabels(model)) @@ -154,7 +154,7 @@ func injectModelLoader(template *applyconfigurationv1.LeaderWorkerTemplateApplyC source.InjectModelLoader(template.WorkerTemplate) } -func injectModelFlavor(template *applyconfigurationv1.LeaderWorkerTemplateApplyConfiguration, model *coreapi.Model) { +func injectModelFlavor(template *applyconfigurationv1.LeaderWorkerTemplateApplyConfiguration, model *coreapi.OpenModel) { if len(model.Spec.InferenceFlavors) == 0 { return } @@ -203,7 +203,7 @@ func injectModelFlavor(template *applyconfigurationv1.LeaderWorkerTemplateApplyC } -func modelLabels(model *coreapi.Model) map[string]string { +func modelLabels(model *coreapi.OpenModel) map[string]string { return map[string]string{ coreapi.ModelNameLabelKey: model.Name, coreapi.ModelFamilyNameLabelKey: string(model.Spec.FamilyName), diff --git a/pkg/controller/model_controller.go b/pkg/controller/model_controller.go index f1dda10..9ff8cfd 100644 --- a/pkg/controller/model_controller.go +++ b/pkg/controller/model_controller.go @@ -28,7 +28,7 @@ import ( api "inftyai.com/llmaz/api/core/v1alpha1" ) -// ModelReconciler reconciles a Model object +// OpenModelReconciler reconciles a Model object type ModelReconciler struct { client.Client Scheme *runtime.Scheme @@ -43,9 +43,9 @@ func NewModelReconciler(client client.Client, scheme *runtime.Scheme, record rec } } -//+kubebuilder:rbac:groups=llmaz.io,resources=models,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=llmaz.io,resources=models/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=llmaz.io,resources=models/finalizers,verbs=update +//+kubebuilder:rbac:groups=llmaz.io,resources=openmodels,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=llmaz.io,resources=openmodels/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=llmaz.io,resources=openmodels/finalizers,verbs=update // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. @@ -62,6 +62,6 @@ func (r *ModelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl // SetupWithManager sets up the controller with the Manager. func (r *ModelReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&api.Model{}). + For(&api.OpenModel{}). Complete(r) } diff --git a/pkg/controller_helper/backend/backend.go b/pkg/controller_helper/backend/backend.go index 1aa0ca1..64738c0 100644 --- a/pkg/controller_helper/backend/backend.go +++ b/pkg/controller_helper/backend/backend.go @@ -35,7 +35,7 @@ type Backend interface { // DefaultCommands returns the default command to start the inference backend. DefaultCommands() []string // DefaultArgs returns the default bootstrap arguments to start the backend. - DefaultArgs(*coreapi.Model) []string + DefaultArgs(*coreapi.OpenModel) []string } func SwitchBackend(name inferenceapi.BackendName) Backend { diff --git a/pkg/controller_helper/backend/sglang.go b/pkg/controller_helper/backend/sglang.go index dee0fd7..ce182a0 100644 --- a/pkg/controller_helper/backend/sglang.go +++ b/pkg/controller_helper/backend/sglang.go @@ -65,7 +65,7 @@ func (s *SGLANG) DefaultCommands() []string { return []string{"python3", "-m", "sglang.launch_server"} } -func (s *SGLANG) DefaultArgs(model *coreapi.Model) []string { +func (s *SGLANG) DefaultArgs(model *coreapi.OpenModel) []string { source := modelSource.NewModelSourceProvider(model) return []string{ "--model-path", source.ModelPath(), diff --git a/pkg/controller_helper/backend/vllm.go b/pkg/controller_helper/backend/vllm.go index 3fae166..c42f79b 100644 --- a/pkg/controller_helper/backend/vllm.go +++ b/pkg/controller_helper/backend/vllm.go @@ -65,7 +65,7 @@ func (v *VLLM) DefaultCommands() []string { return []string{"python3", "-m", "vllm.entrypoints.openai.api_server"} } -func (v *VLLM) DefaultArgs(model *coreapi.Model) []string { +func (v *VLLM) DefaultArgs(model *coreapi.OpenModel) []string { source := modelSource.NewModelSourceProvider(model) return []string{ "--model", source.ModelPath(), diff --git a/pkg/controller_helper/model_source/modelhub.go b/pkg/controller_helper/model_source/modelhub.go index 6af54da..3a9d065 100644 --- a/pkg/controller_helper/model_source/modelhub.go +++ b/pkg/controller_helper/model_source/modelhub.go @@ -28,7 +28,7 @@ import ( var _ ModelSourceProvider = &ModelHubProvider{} type ModelHubProvider struct { - model *coreapi.Model + model *coreapi.OpenModel } func (p *ModelHubProvider) ModelName() string { diff --git a/pkg/controller_helper/model_source/modelsource.go b/pkg/controller_helper/model_source/modelsource.go index b04cad9..c161735 100644 --- a/pkg/controller_helper/model_source/modelsource.go +++ b/pkg/controller_helper/model_source/modelsource.go @@ -28,7 +28,7 @@ type ModelSourceProvider interface { InjectModelLoader(*corev1.PodTemplateSpec) } -func NewModelSourceProvider(model *coreapi.Model) ModelSourceProvider { +func NewModelSourceProvider(model *coreapi.OpenModel) ModelSourceProvider { if model.Spec.Source.ModelHub != nil { return &ModelHubProvider{model: model} } diff --git a/pkg/controller_helper/model_source/modelsource_test.go b/pkg/controller_helper/model_source/modelsource_test.go index a6bcc8e..6b2df9b 100644 --- a/pkg/controller_helper/model_source/modelsource_test.go +++ b/pkg/controller_helper/model_source/modelsource_test.go @@ -26,7 +26,7 @@ import ( func Test_ModelSourceProvider(t *testing.T) { testCases := []struct { name string - model *coreapi.Model + model *coreapi.OpenModel wantModelName string wantModelPath string }{ diff --git a/pkg/webhook/model_webhook.go b/pkg/webhook/openmodel_webhook.go similarity index 58% rename from pkg/webhook/model_webhook.go rename to pkg/webhook/openmodel_webhook.go index 0999951..c75a274 100644 --- a/pkg/webhook/model_webhook.go +++ b/pkg/webhook/openmodel_webhook.go @@ -29,24 +29,24 @@ import ( coreapi "inftyai.com/llmaz/api/core/v1alpha1" ) -type ModelWebhook struct{} +type OpenModelWebhook struct{} -// SetupModelWebhook will setup the manager to manage the webhooks -func SetupModelWebhook(mgr ctrl.Manager) error { +// SetupOpenModelWebhook will setup the manager to manage the webhooks +func SetupOpenModelWebhook(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). - For(&coreapi.Model{}). - WithDefaulter(&ModelWebhook{}). - WithValidator(&ModelWebhook{}). + For(&coreapi.OpenModel{}). + WithDefaulter(&OpenModelWebhook{}). + WithValidator(&OpenModelWebhook{}). Complete() } -//+kubebuilder:webhook:path=/mutate-llmaz-io-v1alpha1-model,mutating=true,failurePolicy=fail,sideEffects=None,groups=llmaz.io,resources=models,verbs=create;update,versions=v1alpha1,name=mmodel.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/mutate-llmaz-io-v1alpha1-openmodel,mutating=true,failurePolicy=fail,sideEffects=None,groups=llmaz.io,resources=openmodels,verbs=create;update,versions=v1alpha1,name=mopenmodel.kb.io,admissionReviewVersions=v1 -var _ webhook.CustomDefaulter = &ModelWebhook{} +var _ webhook.CustomDefaulter = &OpenModelWebhook{} // Default implements webhook.Defaulter so a webhook will be registered for the type -func (w *ModelWebhook) Default(ctx context.Context, obj runtime.Object) error { - model := obj.(*coreapi.Model) +func (w *OpenModelWebhook) Default(ctx context.Context, obj runtime.Object) error { + model := obj.(*coreapi.OpenModel) if model.Labels == nil { model.Labels = map[string]string{} } @@ -54,14 +54,14 @@ func (w *ModelWebhook) Default(ctx context.Context, obj runtime.Object) error { return nil } -//+kubebuilder:webhook:path=/validate-llmaz-io-v1alpha1-model,mutating=false,failurePolicy=fail,sideEffects=None,groups=llmaz.io,resources=models,verbs=create;update,versions=v1alpha1,name=vmodel.kb.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/validate-llmaz-io-v1alpha1-openmodel,mutating=false,failurePolicy=fail,sideEffects=None,groups=llmaz.io,resources=openmodels,verbs=create;update,versions=v1alpha1,name=vopenmodel.kb.io,admissionReviewVersions=v1 -var _ webhook.CustomValidator = &ModelWebhook{} +var _ webhook.CustomValidator = &OpenModelWebhook{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (w *ModelWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (w *OpenModelWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { allErrs := w.generateValidate(obj) - model := obj.(*coreapi.Model) + model := obj.(*coreapi.OpenModel) for _, err := range validation.IsDNS1123Label(model.Name) { allErrs = append(allErrs, field.Invalid(field.NewPath("metadata.name"), model.Name, err)) } @@ -69,18 +69,18 @@ func (w *ModelWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) ( } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (w *ModelWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (w *OpenModelWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { allErrs := w.generateValidate(newObj) return nil, allErrs.ToAggregate() } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (w *ModelWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (w *OpenModelWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { return nil, nil } -func (w *ModelWebhook) generateValidate(obj runtime.Object) field.ErrorList { - model := obj.(*coreapi.Model) +func (w *OpenModelWebhook) generateValidate(obj runtime.Object) field.ErrorList { + model := obj.(*coreapi.OpenModel) dataSourcePath := field.NewPath("spec", "dataSource") var allErrs field.ErrorList diff --git a/test/e2e/playground_test.go b/test/e2e/playground_test.go index 5c46114..ef6d60d 100644 --- a/test/e2e/playground_test.go +++ b/test/e2e/playground_test.go @@ -22,7 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" testing "sigs.k8s.io/lws/test/testutils" - api "inftyai.com/llmaz/api/core/v1alpha1" + coreapi "inftyai.com/llmaz/api/core/v1alpha1" "inftyai.com/llmaz/test/util" ) @@ -30,7 +30,7 @@ var _ = ginkgo.Describe("playground e2e tests", func() { // Each test runs in a separate namespace. var ns *corev1.Namespace - var model *api.Model + var model *coreapi.OpenModel ginkgo.BeforeEach(func() { // Create test namespace before each test. diff --git a/test/e2e/suit_test.go b/test/e2e/suit_test.go index 31dfac2..4cc886b 100644 --- a/test/e2e/suit_test.go +++ b/test/e2e/suit_test.go @@ -102,6 +102,6 @@ func readyForTesting(client client.Client) { // Delete this model before beginning tests. Expect(client.Delete(ctx, model)) Eventually(func() error { - return client.Get(ctx, types.NamespacedName{Name: model.Name, Namespace: model.Namespace}, &coreapi.Model{}) + return client.Get(ctx, types.NamespacedName{Name: model.Name, Namespace: model.Namespace}, &coreapi.OpenModel{}) }).ShouldNot(Succeed()) } diff --git a/test/integration/controller/inference/playground_test.go b/test/integration/controller/inference/playground_test.go index c00ba92..5d8a723 100644 --- a/test/integration/controller/inference/playground_test.go +++ b/test/integration/controller/inference/playground_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - api "inftyai.com/llmaz/api/core/v1alpha1" + coreapi "inftyai.com/llmaz/api/core/v1alpha1" inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" "inftyai.com/llmaz/test/util" "inftyai.com/llmaz/test/util/validation" @@ -37,7 +37,7 @@ import ( var _ = ginkgo.Describe("playground controller test", func() { // Each test runs in a separate namespace. var ns *corev1.Namespace - var model *api.Model + var model *coreapi.OpenModel type update struct { playgroundUpdateFn func(*inferenceapi.Playground) diff --git a/test/integration/controller/inference/service_test.go b/test/integration/controller/inference/service_test.go index ec936e2..bfefe95 100644 --- a/test/integration/controller/inference/service_test.go +++ b/test/integration/controller/inference/service_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - api "inftyai.com/llmaz/api/core/v1alpha1" + coreapi "inftyai.com/llmaz/api/core/v1alpha1" inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" "inftyai.com/llmaz/test/util" "inftyai.com/llmaz/test/util/validation" @@ -36,7 +36,7 @@ import ( var _ = ginkgo.Describe("inferenceService controller test", func() { // Each test runs in a separate namespace. var ns *corev1.Namespace - var model *api.Model + var model *coreapi.OpenModel type update struct { serviceUpdateFn func(*inferenceapi.Service) diff --git a/test/integration/webhook/model_test.go b/test/integration/webhook/model_test.go index 023c761..607f7e2 100644 --- a/test/integration/webhook/model_test.go +++ b/test/integration/webhook/model_test.go @@ -22,7 +22,7 @@ import ( "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - core "inftyai.com/llmaz/api/core/v1alpha1" + coreapi "inftyai.com/llmaz/api/core/v1alpha1" "inftyai.com/llmaz/test/util/wrapper" ) @@ -30,7 +30,7 @@ var _ = ginkgo.Describe("model default and validation", func() { // Delete all the Models for each case. ginkgo.AfterEach(func() { - var models core.ModelList + var models coreapi.OpenModelList gomega.Expect(k8sClient.List(ctx, &models)).To(gomega.Succeed()) for _, model := range models.Items { @@ -39,37 +39,37 @@ var _ = ginkgo.Describe("model default and validation", func() { }) type testDefaultingCase struct { - model func() *core.Model - wantModel func() *core.Model + model func() *coreapi.OpenModel + wantModel func() *coreapi.OpenModel } ginkgo.DescribeTable("Defaulting test", func(tc *testDefaultingCase) { model := tc.model() gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) gomega.Expect(model).To(gomega.BeComparableTo(tc.wantModel(), - cmpopts.IgnoreTypes(core.ModelStatus{}), + cmpopts.IgnoreTypes(coreapi.ModelStatus{}), cmpopts.IgnoreFields(metav1.ObjectMeta{}, "UID", "ResourceVersion", "Generation", "CreationTimestamp", "ManagedFields"))) }, ginkgo.Entry("apply model family name", &testDefaultingCase{ - model: func() *core.Model { + model: func() *coreapi.OpenModel { return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("meta-llama/Meta-Llama-3-8B").FamilyName("llama3").Obj() }, - wantModel: func() *core.Model { - return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("meta-llama/Meta-Llama-3-8B").DataSourceWithModelHub("Huggingface").FamilyName("llama3").Label(core.ModelFamilyNameLabelKey, "llama3").Obj() + wantModel: func() *coreapi.OpenModel { + return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("meta-llama/Meta-Llama-3-8B").DataSourceWithModelHub("Huggingface").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").Obj() }, }), ginkgo.Entry("apply modelscope model hub name", &testDefaultingCase{ - model: func() *core.Model { + model: func() *coreapi.OpenModel { return wrapper.MakeModel("llama3-8b").FamilyName("llama3").DataSourceWithModelHub("ModelScope").DataSourceWithModelID("LLM-Research/Meta-Llama-3-8B").Obj() }, - wantModel: func() *core.Model { - return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("LLM-Research/Meta-Llama-3-8B").DataSourceWithModelHub("ModelScope").FamilyName("llama3").Label(core.ModelFamilyNameLabelKey, "llama3").Obj() + wantModel: func() *coreapi.OpenModel { + return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("LLM-Research/Meta-Llama-3-8B").DataSourceWithModelHub("ModelScope").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").Obj() }, }), ) type testValidatingCase struct { - model func() *core.Model + model func() *coreapi.OpenModel failed bool } // TODO: add more testCases to cover update. @@ -82,19 +82,19 @@ var _ = ginkgo.Describe("model default and validation", func() { } }, ginkgo.Entry("default normal huggingface model creation", &testValidatingCase{ - model: func() *core.Model { + model: func() *coreapi.OpenModel { return wrapper.MakeModel("llama3-8b").FamilyName("llama3").DataSourceWithModelID("meta-llama/Meta-Llama-3-8B").Obj() }, failed: false, }), ginkgo.Entry("normal modelScope model creation", &testValidatingCase{ - model: func() *core.Model { + model: func() *coreapi.OpenModel { return wrapper.MakeModel("llama3-8b").FamilyName("llama3").DataSourceWithModelHub("ModelScope").DataSourceWithModelID("LLM-Research/Meta-Llama-3-8B").Obj() }, failed: false, }), ginkgo.Entry("invalid model name", &testValidatingCase{ - model: func() *core.Model { + model: func() *coreapi.OpenModel { return wrapper.MakeModel("qwen-2-0.5b").FamilyName("qwen2").DataSourceWithModelID("Qwen/Qwen2-0.5B-Instruct").Obj() }, failed: true, @@ -106,7 +106,7 @@ var _ = ginkgo.Describe("model default and validation", func() { // failed: false, // }), ginkgo.Entry("no data source configured", &testValidatingCase{ - model: func() *core.Model { + model: func() *coreapi.OpenModel { return wrapper.MakeModel("llama3-8b").FamilyName("llama3").Obj() }, failed: true, diff --git a/test/integration/webhook/suit_test.go b/test/integration/webhook/suit_test.go index 65eede6..125370c 100644 --- a/test/integration/webhook/suit_test.go +++ b/test/integration/webhook/suit_test.go @@ -122,7 +122,7 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - err = apiwebhook.SetupModelWebhook(mgr) + err = apiwebhook.SetupOpenModelWebhook(mgr) Expect(err).NotTo(HaveOccurred()) err = apiwebhook.SetupPlaygroundWebhook(mgr) Expect(err).NotTo(HaveOccurred()) diff --git a/test/util/mock.go b/test/util/mock.go index fcb2459..a201e3c 100644 --- a/test/util/mock.go +++ b/test/util/mock.go @@ -25,7 +25,7 @@ const ( sampleModelName = "llama3-8b" ) -func MockASampleModel() *api.Model { +func MockASampleModel() *api.OpenModel { return wrapper.MakeModel(sampleModelName).FamilyName("llama3").DataSourceWithModelID("meta-llama/Meta-Llama-3-8B").Obj() } diff --git a/test/util/validation/validate_playground.go b/test/util/validation/validate_playground.go index 0b53b37..741ebf3 100644 --- a/test/util/validation/validate_playground.go +++ b/test/util/validation/validate_playground.go @@ -47,7 +47,7 @@ func ValidatePlayground(ctx context.Context, k8sClient client.Client, playground return fmt.Errorf("expected replicas: %d, got %d", *playground.Spec.Replicas, *service.Spec.WorkloadTemplate.Replicas) } - model := coreapi.Model{} + model := coreapi.OpenModel{} if playground.Spec.ModelClaim != nil { if err := k8sClient.Get(ctx, types.NamespacedName{Name: string(playground.Spec.ModelClaim.ModelName), Namespace: playground.Namespace}, &model); err != nil { diff --git a/test/util/validation/validate_service.go b/test/util/validation/validate_service.go index 744fe44..424aa75 100644 --- a/test/util/validation/validate_service.go +++ b/test/util/validation/validate_service.go @@ -50,7 +50,7 @@ func ValidateService(ctx context.Context, k8sClient client.Client, service *infe // TODO: multi-host modelName := string(service.Spec.MultiModelsClaims[0].ModelNames[0]) - model := coreapi.Model{} + model := coreapi.OpenModel{} if err := k8sClient.Get(ctx, types.NamespacedName{Name: modelName}, &model); err != nil { return errors.New("failed to get model") } @@ -78,7 +78,7 @@ func ValidateService(ctx context.Context, k8sClient client.Client, service *infe }, util.IntegrationTimeout, util.Interval).Should(gomega.Succeed()) } -func ValidateModelLoader(model *coreapi.Model, workload *lws.LeaderWorkerSet, service *inferenceapi.Service) error { +func ValidateModelLoader(model *coreapi.OpenModel, workload *lws.LeaderWorkerSet, service *inferenceapi.Service) error { if model.Spec.Source.ModelHub != nil { if len(workload.Spec.LeaderWorkerTemplate.WorkerTemplate.Spec.InitContainers) == 0 { return errors.New("no initContainer configured") @@ -133,7 +133,7 @@ func ValidateModelLoader(model *coreapi.Model, workload *lws.LeaderWorkerSet, se return nil } -func ValidateModelFlavor(model *coreapi.Model, workload *lws.LeaderWorkerSet) error { +func ValidateModelFlavor(model *coreapi.OpenModel, workload *lws.LeaderWorkerSet) error { // TODO: Use the 0-index flavor for validation right now. flavor := model.Spec.InferenceFlavors[0] diff --git a/test/util/wrapper/model.go b/test/util/wrapper/model.go index 9576d60..391199b 100644 --- a/test/util/wrapper/model.go +++ b/test/util/wrapper/model.go @@ -21,16 +21,16 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - core "inftyai.com/llmaz/api/core/v1alpha1" + coreapi "inftyai.com/llmaz/api/core/v1alpha1" ) type ModelWrapper struct { - core.Model + coreapi.OpenModel } func MakeModel(name string) *ModelWrapper { return &ModelWrapper{ - core.Model{ + coreapi.OpenModel{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -38,19 +38,19 @@ func MakeModel(name string) *ModelWrapper { } } -func (w *ModelWrapper) Obj() *core.Model { - return &w.Model +func (w *ModelWrapper) Obj() *coreapi.OpenModel { + return &w.OpenModel } func (w *ModelWrapper) FamilyName(name string) *ModelWrapper { - w.Spec.FamilyName = core.ModelName(name) + w.Spec.FamilyName = coreapi.ModelName(name) return w } func (w *ModelWrapper) DataSourceWithModelID(modelID string) *ModelWrapper { if modelID != "" { if w.Spec.Source.ModelHub == nil { - w.Spec.Source.ModelHub = &core.ModelHub{} + w.Spec.Source.ModelHub = &coreapi.ModelHub{} } w.Spec.Source.ModelHub.ModelID = modelID } @@ -60,7 +60,7 @@ func (w *ModelWrapper) DataSourceWithModelID(modelID string) *ModelWrapper { func (w *ModelWrapper) DataSourceWithModelHub(modelHub string) *ModelWrapper { if modelHub != "" { if w.Spec.Source.ModelHub == nil { - w.Spec.Source.ModelHub = &core.ModelHub{} + w.Spec.Source.ModelHub = &coreapi.ModelHub{} } w.Spec.Source.ModelHub.Name = &modelHub } @@ -87,24 +87,24 @@ func (w *ModelWrapper) Label(k, v string) *ModelWrapper { } type FlavorWrapper struct { - core.Flavor + coreapi.Flavor } -func (w *FlavorWrapper) Obj() *core.Flavor { +func (w *FlavorWrapper) Obj() *coreapi.Flavor { return &w.Flavor } -func (w *FlavorWrapper) SetName(name string) *core.Flavor { - w.Name = core.FlavorName(name) +func (w *FlavorWrapper) SetName(name string) *coreapi.Flavor { + w.Name = coreapi.FlavorName(name) return &w.Flavor } -func (w *FlavorWrapper) SetRequest(r, v string) *core.Flavor { +func (w *FlavorWrapper) SetRequest(r, v string) *coreapi.Flavor { w.Requests[v1.ResourceName(r)] = resource.MustParse(v) return &w.Flavor } -func (w *FlavorWrapper) SetNodeSelector(k, v string) *core.Flavor { +func (w *FlavorWrapper) SetNodeSelector(k, v string) *coreapi.Flavor { if w.NodeSelector == nil { w.NodeSelector = map[string]string{} } @@ -112,7 +112,7 @@ func (w *FlavorWrapper) SetNodeSelector(k, v string) *core.Flavor { return &w.Flavor } -func (w *FlavorWrapper) SetParams(k, v string) *core.Flavor { +func (w *FlavorWrapper) SetParams(k, v string) *coreapi.Flavor { w.Params[k] = v return &w.Flavor }