Skip to content

Commit

Permalink
fix validation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
samos123 committed Dec 5, 2024
1 parent 8c177b5 commit d193614
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions api/v1/model_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (
)

// ModelSpec defines the desired state of Model.
// +kubebuilder:validation:XValidation:rule="!has(self.cacheProfile) || self.url.startsWith(\"hf://\") || self.url.startsWith(\"pvc://\") || self.url.startsWith(\"s3://\") || self.url.startsWith(\"gs://\") || self.url.startsWith(\"oss://\")", message="cacheProfile is only supported with urls of format \"hf://...\", \"pvc://...\", \"s3://...\", \"gs://...\", or \"oss://...\" at the moment."
// +kubebuilder:validation:XValidation:rule="!has(self.cacheProfile) || self.url.startsWith(\"hf://\") || self.url.startsWith(\"s3://\") || self.url.startsWith(\"gs://\") || self.url.startsWith(\"oss://\")", message="cacheProfile is only supported with urls of format \"hf://...\", \"s3://...\", \"gs://...\", or \"oss://...\" at the moment."
// +kubebuilder:validation:XValidation:rule="!self.url.startsWith(\"s3://\") || has(self.cacheProfile)", message="urls of format \"s3://...\" only supported when using a cacheProfile"
// +kubebuilder:validation:XValidation:rule="!self.url.startsWith(\"gs://\") || has(self.cacheProfile)", message="urls of format \"gs://...\" only supported when using a cacheProfile"
// +kubebuilder:validation:XValidation:rule="!self.url.startsWith(\"oss://\") || has(self.cacheProfile)", message="urls of format \"oss://...\" only supported when using a cacheProfile"
// +kubebuilder:validation:XValidation:rule="self.url.startsWith(\"pvc://\") || has(self.cacheProfile)", message="urls of format \"pvc://...\" do not support cacheProfile. Remove cacheProfile or use a different url."
// +kubebuilder:validation:XValidation:rule="!has(self.maxReplicas) || self.minReplicas <= self.maxReplicas", message="minReplicas should be less than or equal to maxReplicas."
// +kubebuilder:validation:XValidation:rule="!has(self.adapters) || self.engine == \"VLLM\"", message="adapters only supported with VLLM engine."
type ModelSpec struct {
Expand Down
10 changes: 3 additions & 7 deletions charts/kubeai/templates/crds/kubeai.org_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,15 @@ spec:
type: object
x-kubernetes-validations:
- message: cacheProfile is only supported with urls of format "hf://...",
"pvc://...", "s3://...", "gs://...", or "oss://..." at the moment.
rule: '!has(self.cacheProfile) || self.url.startsWith("hf://") || self.url.startsWith("pvc://")
|| self.url.startsWith("s3://") || self.url.startsWith("gs://") ||
self.url.startsWith("oss://")'
"s3://...", "gs://...", or "oss://..." at the moment.
rule: '!has(self.cacheProfile) || self.url.startsWith("hf://") || self.url.startsWith("s3://")
|| self.url.startsWith("gs://") || self.url.startsWith("oss://")'
- message: urls of format "s3://..." only supported when using a cacheProfile
rule: '!self.url.startsWith("s3://") || has(self.cacheProfile)'
- message: urls of format "gs://..." only supported when using a cacheProfile
rule: '!self.url.startsWith("gs://") || has(self.cacheProfile)'
- message: urls of format "oss://..." only supported when using a cacheProfile
rule: '!self.url.startsWith("oss://") || has(self.cacheProfile)'
- message: urls of format "pvc://..." do not support cacheProfile. Remove
cacheProfile or use a different url.
rule: self.url.startsWith("pvc://") || has(self.cacheProfile)
- message: minReplicas should be less than or equal to maxReplicas.
rule: '!has(self.maxReplicas) || self.minReplicas <= self.maxReplicas'
- message: adapters only supported with VLLM engine.
Expand Down
1 change: 0 additions & 1 deletion internal/modelcontroller/engine_vllm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func (r *ModelReconciler) vLLMPodForModel(m *kubeaiv1.Model, c ModelConfig) *cor
if m.Spec.CacheProfile != "" {
vllmModelFlag = modelCacheDir(m)
}
// TODO we should throw an error if cache profile is set AND the model is on PVC.
if c.Source.url.scheme == "pvc" {
vllmModelFlag = "/model"
}
Expand Down

0 comments on commit d193614

Please sign in to comment.