diff --git a/pkg/lib/configreader/float32.go b/pkg/lib/configreader/float32.go index 5da2f2f63f..69d937270b 100644 --- a/pkg/lib/configreader/float32.go +++ b/pkg/lib/configreader/float32.go @@ -31,6 +31,7 @@ type Float32Validation struct { Default float32 TreatNullAsZero bool // `: ` and `: null` will be read as `: 0.0` AllowedValues []float32 + HiddenAllowedValues []float32 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []float32 CantBeSpecifiedErrStr *string GreaterThan *float32 @@ -207,7 +208,7 @@ func ValidateFloat32Val(val float32, v *Float32Validation) error { } if len(v.AllowedValues) > 0 { - if !slices.HasFloat32(v.AllowedValues, val) { + if !slices.HasFloat32(append(v.AllowedValues, v.HiddenAllowedValues...), val) { return ErrorInvalidFloat32(val, v.AllowedValues[0], v.AllowedValues[1:]...) } } diff --git a/pkg/lib/configreader/float32_ptr.go b/pkg/lib/configreader/float32_ptr.go index bb1dcb903e..ce50f77801 100644 --- a/pkg/lib/configreader/float32_ptr.go +++ b/pkg/lib/configreader/float32_ptr.go @@ -29,6 +29,7 @@ type Float32PtrValidation struct { Default *float32 AllowExplicitNull bool AllowedValues []float32 + HiddenAllowedValues []float32 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []float32 CantBeSpecifiedErrStr *string GreaterThan *float32 @@ -41,6 +42,7 @@ type Float32PtrValidation struct { func makeFloat32ValValidation(v *Float32PtrValidation) *Float32Validation { return &Float32Validation{ AllowedValues: v.AllowedValues, + HiddenAllowedValues: v.HiddenAllowedValues, DisallowedValues: v.DisallowedValues, GreaterThan: v.GreaterThan, GreaterThanOrEqualTo: v.GreaterThanOrEqualTo, diff --git a/pkg/lib/configreader/float64.go b/pkg/lib/configreader/float64.go index 8b7b796a1a..a8cf20557e 100644 --- a/pkg/lib/configreader/float64.go +++ b/pkg/lib/configreader/float64.go @@ -31,6 +31,7 @@ type Float64Validation struct { Default float64 TreatNullAsZero bool // `: ` and `: null` will be read as `: 0.0` AllowedValues []float64 + HiddenAllowedValues []float64 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []float64 CantBeSpecifiedErrStr *string GreaterThan *float64 @@ -207,7 +208,7 @@ func ValidateFloat64Val(val float64, v *Float64Validation) error { } if len(v.AllowedValues) > 0 { - if !slices.HasFloat64(v.AllowedValues, val) { + if !slices.HasFloat64(append(v.AllowedValues, v.HiddenAllowedValues...), val) { return ErrorInvalidFloat64(val, v.AllowedValues[0], v.AllowedValues[1:]...) } } diff --git a/pkg/lib/configreader/float64_ptr.go b/pkg/lib/configreader/float64_ptr.go index a31300cc8b..ea4bb3aede 100644 --- a/pkg/lib/configreader/float64_ptr.go +++ b/pkg/lib/configreader/float64_ptr.go @@ -29,6 +29,7 @@ type Float64PtrValidation struct { Default *float64 AllowExplicitNull bool AllowedValues []float64 + HiddenAllowedValues []float64 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []float64 CantBeSpecifiedErrStr *string GreaterThan *float64 @@ -41,6 +42,7 @@ type Float64PtrValidation struct { func makeFloat64ValValidation(v *Float64PtrValidation) *Float64Validation { return &Float64Validation{ AllowedValues: v.AllowedValues, + HiddenAllowedValues: v.HiddenAllowedValues, DisallowedValues: v.DisallowedValues, GreaterThan: v.GreaterThan, GreaterThanOrEqualTo: v.GreaterThanOrEqualTo, diff --git a/pkg/lib/configreader/int.go b/pkg/lib/configreader/int.go index afe3aca30b..13d3fb591d 100644 --- a/pkg/lib/configreader/int.go +++ b/pkg/lib/configreader/int.go @@ -31,6 +31,7 @@ type IntValidation struct { Default int TreatNullAsZero bool // `: ` and `: null` will be read as `: 0` AllowedValues []int + HiddenAllowedValues []int // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []int CantBeSpecifiedErrStr *string GreaterThan *int @@ -207,7 +208,7 @@ func ValidateIntVal(val int, v *IntValidation) error { } if len(v.AllowedValues) > 0 { - if !slices.HasInt(v.AllowedValues, val) { + if !slices.HasInt(append(v.AllowedValues, v.HiddenAllowedValues...), val) { return ErrorInvalidInt(val, v.AllowedValues[0], v.AllowedValues[1:]...) } } diff --git a/pkg/lib/configreader/int32.go b/pkg/lib/configreader/int32.go index 8950ce8a2b..ee82eb6d96 100644 --- a/pkg/lib/configreader/int32.go +++ b/pkg/lib/configreader/int32.go @@ -31,6 +31,7 @@ type Int32Validation struct { Default int32 TreatNullAsZero bool // `: ` and `: null` will be read as `: 0` AllowedValues []int32 + HiddenAllowedValues []int32 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []int32 CantBeSpecifiedErrStr *string GreaterThan *int32 @@ -207,7 +208,7 @@ func ValidateInt32Val(val int32, v *Int32Validation) error { } if len(v.AllowedValues) > 0 { - if !slices.HasInt32(v.AllowedValues, val) { + if !slices.HasInt32(append(v.AllowedValues, v.HiddenAllowedValues...), val) { return ErrorInvalidInt32(val, v.AllowedValues[0], v.AllowedValues[1:]...) } } diff --git a/pkg/lib/configreader/int32_ptr.go b/pkg/lib/configreader/int32_ptr.go index c916ceeb50..4667d40fe1 100644 --- a/pkg/lib/configreader/int32_ptr.go +++ b/pkg/lib/configreader/int32_ptr.go @@ -29,6 +29,7 @@ type Int32PtrValidation struct { Default *int32 AllowExplicitNull bool AllowedValues []int32 + HiddenAllowedValues []int32 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []int32 CantBeSpecifiedErrStr *string GreaterThan *int32 @@ -41,6 +42,7 @@ type Int32PtrValidation struct { func makeInt32ValValidation(v *Int32PtrValidation) *Int32Validation { return &Int32Validation{ AllowedValues: v.AllowedValues, + HiddenAllowedValues: v.HiddenAllowedValues, DisallowedValues: v.DisallowedValues, GreaterThan: v.GreaterThan, GreaterThanOrEqualTo: v.GreaterThanOrEqualTo, diff --git a/pkg/lib/configreader/int64.go b/pkg/lib/configreader/int64.go index 5380ea45b4..ef8e85ffca 100644 --- a/pkg/lib/configreader/int64.go +++ b/pkg/lib/configreader/int64.go @@ -31,6 +31,7 @@ type Int64Validation struct { Default int64 TreatNullAsZero bool // `: ` and `: null` will be read as `: 0` AllowedValues []int64 + HiddenAllowedValues []int64 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []int64 CantBeSpecifiedErrStr *string GreaterThan *int64 @@ -207,7 +208,7 @@ func ValidateInt64Val(val int64, v *Int64Validation) error { } if len(v.AllowedValues) > 0 { - if !slices.HasInt64(v.AllowedValues, val) { + if !slices.HasInt64(append(v.AllowedValues, v.HiddenAllowedValues...), val) { return ErrorInvalidInt64(val, v.AllowedValues[0], v.AllowedValues[1:]...) } } diff --git a/pkg/lib/configreader/int64_ptr.go b/pkg/lib/configreader/int64_ptr.go index ec7fb3eb6f..ab2f87c442 100644 --- a/pkg/lib/configreader/int64_ptr.go +++ b/pkg/lib/configreader/int64_ptr.go @@ -29,6 +29,7 @@ type Int64PtrValidation struct { Default *int64 AllowExplicitNull bool AllowedValues []int64 + HiddenAllowedValues []int64 // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []int64 CantBeSpecifiedErrStr *string GreaterThan *int64 @@ -41,6 +42,7 @@ type Int64PtrValidation struct { func makeInt64ValValidation(v *Int64PtrValidation) *Int64Validation { return &Int64Validation{ AllowedValues: v.AllowedValues, + HiddenAllowedValues: v.HiddenAllowedValues, DisallowedValues: v.DisallowedValues, GreaterThan: v.GreaterThan, GreaterThanOrEqualTo: v.GreaterThanOrEqualTo, diff --git a/pkg/lib/configreader/int_ptr.go b/pkg/lib/configreader/int_ptr.go index 6ac2e81238..65cb8907c1 100644 --- a/pkg/lib/configreader/int_ptr.go +++ b/pkg/lib/configreader/int_ptr.go @@ -29,6 +29,7 @@ type IntPtrValidation struct { Default *int AllowExplicitNull bool AllowedValues []int + HiddenAllowedValues []int // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []int CantBeSpecifiedErrStr *string GreaterThan *int @@ -41,6 +42,7 @@ type IntPtrValidation struct { func makeIntValValidation(v *IntPtrValidation) *IntValidation { return &IntValidation{ AllowedValues: v.AllowedValues, + HiddenAllowedValues: v.HiddenAllowedValues, DisallowedValues: v.DisallowedValues, GreaterThan: v.GreaterThan, GreaterThanOrEqualTo: v.GreaterThanOrEqualTo, diff --git a/pkg/lib/configreader/string.go b/pkg/lib/configreader/string.go index 85140037bd..974cc6c27c 100644 --- a/pkg/lib/configreader/string.go +++ b/pkg/lib/configreader/string.go @@ -37,6 +37,7 @@ type StringValidation struct { AllowEmpty bool // Allow `: ""` TreatNullAsEmpty bool // `: ` and `: null` will be read as `: ""` AllowedValues []string + HiddenAllowedValues []string // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []string CantBeSpecifiedErrStr *string Prefix string @@ -239,7 +240,7 @@ func ValidateStringVal(val string, v *StringValidation) error { } if len(v.AllowedValues) > 0 { - if !slices.HasString(v.AllowedValues, val) { + if !slices.HasString(append(v.AllowedValues, v.HiddenAllowedValues...), val) { return ErrorInvalidStr(val, v.AllowedValues[0], v.AllowedValues[1:]...) } } diff --git a/pkg/lib/configreader/string_ptr.go b/pkg/lib/configreader/string_ptr.go index 9dfb0b31bd..6fdaa9c3ca 100644 --- a/pkg/lib/configreader/string_ptr.go +++ b/pkg/lib/configreader/string_ptr.go @@ -30,6 +30,7 @@ type StringPtrValidation struct { AllowExplicitNull bool AllowEmpty bool AllowedValues []string + HiddenAllowedValues []string // allowed, but will not be listed as valid values (must be used in conjunction with AllowedValues) DisallowedValues []string CantBeSpecifiedErrStr *string Prefix string @@ -59,6 +60,7 @@ func makeStringValValidation(v *StringPtrValidation) *StringValidation { return &StringValidation{ AllowEmpty: v.AllowEmpty, AllowedValues: v.AllowedValues, + HiddenAllowedValues: v.HiddenAllowedValues, DisallowedValues: v.DisallowedValues, Prefix: v.Prefix, Suffix: v.Suffix, diff --git a/pkg/types/spec/errors.go b/pkg/types/spec/errors.go index a51169263e..3d76ce4f6a 100644 --- a/pkg/types/spec/errors.go +++ b/pkg/types/spec/errors.go @@ -95,6 +95,7 @@ const ( ErrTrafficSplitterAPIsNotUnique = "spec.traffic_splitter_apis_not_unique" ErrOneShadowPerTrafficSplitter = "spec.one_shadow_per_traffic_splitter" ErrUnexpectedDockerSecretData = "spec.unexpected_docker_secret_data" + ErrInvalidONNXPredictorType = "spec.invalid_onnx_predictor_type" ) var _modelCurrentStructure = ` @@ -612,3 +613,10 @@ func ErrorUnexpectedDockerSecretData(reason string, secretData map[string][]byte Message: fmt.Sprintf("docker registry secret named \"%s\" was found, but contains unexpected data (%s); got: %s", _dockerPullSecretName, reason, s.UserStr(secretDataStrMap)), }) } + +func ErrorInvalidONNXPredictorType() error { + return errors.WithStack(&errors.Error{ + Kind: ErrInvalidONNXPredictorType, + Message: "the onnx predictor type has been replaced by the python predictor type; please use the python predictor type instead (all onnx models are fully supported by the python predictor type)", + }) +} diff --git a/pkg/types/spec/validations.go b/pkg/types/spec/validations.go index 7013a3776d..7c7d83fcdf 100644 --- a/pkg/types/spec/validations.go +++ b/pkg/types/spec/validations.go @@ -155,10 +155,14 @@ func predictorValidation() *cr.StructFieldValidation { { StructField: "Type", StringValidation: &cr.StringValidation{ - Required: true, - AllowedValues: userconfig.PredictorTypeStrings(), + Required: true, + AllowedValues: userconfig.PredictorTypeStrings(), + HiddenAllowedValues: []string{"onnx"}, }, Parser: func(str string) (interface{}, error) { + if str == "onnx" { + return nil, ErrorInvalidONNXPredictorType() + } return userconfig.PredictorTypeFromString(str), nil }, },