Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/lib/configreader/float32.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Float32Validation struct {
Default float32
TreatNullAsZero bool // `<field>: ` and `<field>: null` will be read as `<field>: 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
Expand Down Expand Up @@ -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:]...)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/configreader/float32_ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/lib/configreader/float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Float64Validation struct {
Default float64
TreatNullAsZero bool // `<field>: ` and `<field>: null` will be read as `<field>: 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
Expand Down Expand Up @@ -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:]...)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/configreader/float64_ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/lib/configreader/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type IntValidation struct {
Default int
TreatNullAsZero bool // `<field>: ` and `<field>: null` will be read as `<field>: 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
Expand Down Expand Up @@ -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:]...)
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/lib/configreader/int32.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Int32Validation struct {
Default int32
TreatNullAsZero bool // `<field>: ` and `<field>: null` will be read as `<field>: 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
Expand Down Expand Up @@ -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:]...)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/configreader/int32_ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/lib/configreader/int64.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Int64Validation struct {
Default int64
TreatNullAsZero bool // `<field>: ` and `<field>: null` will be read as `<field>: 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
Expand Down Expand Up @@ -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:]...)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/configreader/int64_ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/configreader/int_ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/lib/configreader/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type StringValidation struct {
AllowEmpty bool // Allow `<field>: ""`
TreatNullAsEmpty bool // `<field>: ` and `<field>: null` will be read as `<field>: ""`
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
Expand Down Expand Up @@ -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:]...)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/lib/configreader/string_ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions pkg/types/spec/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down Expand Up @@ -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)",
})
}
8 changes: 6 additions & 2 deletions pkg/types/spec/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
Expand Down