Skip to content

Commit 8e01f68

Browse files
committed
Update predictor error wrapping
1 parent 8756000 commit 8e01f68

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

pkg/operator/api/userconfig/apis.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ func (predictor *Predictor) UserConfigStr() string {
303303
if predictor.Model != nil {
304304
sb.WriteString(fmt.Sprintf("%s: %s\n", ModelKey, *predictor.Model))
305305
}
306+
if predictor.SignatureKey != nil {
307+
sb.WriteString(fmt.Sprintf("%s: %s\n", SignatureKeyKey, *predictor.SignatureKey))
308+
}
306309
if predictor.PythonPath != nil {
307310
sb.WriteString(fmt.Sprintf("%s: %s\n", PythonPathKey, *predictor.PythonPath))
308311
}
@@ -316,9 +319,6 @@ func (predictor *Predictor) UserConfigStr() string {
316319
d, _ := yaml.Marshal(&predictor.Env)
317320
sb.WriteString(s.Indent(string(d), " "))
318321
}
319-
if predictor.SignatureKey != nil {
320-
sb.WriteString(fmt.Sprintf("%s: %s\n", SignatureKeyKey, *predictor.SignatureKey))
321-
}
322322
return sb.String()
323323
}
324324

@@ -364,12 +364,12 @@ func (predictor *Predictor) TensorFlowValidate() error {
364364
}
365365
if strings.HasSuffix(model, ".zip") {
366366
if ok, err := awsClient.IsS3PathFile(model); err != nil || !ok {
367-
return errors.Wrap(ErrorExternalNotFound(model), TensorFlowKey, ModelKey)
367+
return errors.Wrap(ErrorExternalNotFound(model), ModelKey)
368368
}
369369
} else {
370370
path, err := GetTFServingExportFromS3Path(model, awsClient)
371371
if path == "" || err != nil {
372-
return errors.Wrap(ErrorInvalidTensorFlowDir(model), TensorFlowKey, ModelKey)
372+
return errors.Wrap(ErrorInvalidTensorFlowDir(model), ModelKey)
373373
}
374374
predictor.Model = pointer.String(path)
375375
}
@@ -389,7 +389,7 @@ func (predictor *Predictor) ONNXValidate() error {
389389
return err
390390
}
391391
if ok, err := awsClient.IsS3PathFile(model); err != nil || !ok {
392-
return errors.Wrap(ErrorExternalNotFound(model), ONNXKey, ModelKey)
392+
return errors.Wrap(ErrorExternalNotFound(model), ModelKey)
393393
}
394394

395395
if predictor.SignatureKey != nil {

pkg/operator/api/userconfig/config_key.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ const (
3232
TrackerKey = "tracker"
3333
ModelTypeKey = "model_type"
3434
KeyKey = "key"
35-
TensorFlowKey = "tensorflow"
36-
ONNXKey = "onnx"
37-
PythonKey = "python"
3835
ConfigKey = "config"
3936
PythonPathKey = "python_path"
4037
EnvKey = "env"

pkg/operator/api/userconfig/errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ var tfExpectedStructMessage = `For TensorFlow models, the path must contain a di
270270
└── variables.data-00002-of-...`
271271

272272
func ErrorInvalidTensorFlowDir(path string) error {
273-
message := "invalid TF export directory.\n"
273+
message := "invalid TensorFlow export directory.\n"
274274
message += tfExpectedStructMessage
275275
return Error{
276276
Kind: ErrInvalidTensorFlowDir,
@@ -281,14 +281,14 @@ func ErrorInvalidTensorFlowDir(path string) error {
281281
func ErrorFieldMustBeDefinedForPredictorType(fieldKey string, predictorType PredictorType) error {
282282
return Error{
283283
Kind: ErrFieldMustBeDefinedForPredictorType,
284-
message: fmt.Sprintf("%s field must be defined for predictor type %s", fieldKey, predictorType.String()),
284+
message: fmt.Sprintf("%s field must be defined for the %s predictor type", fieldKey, predictorType.String()),
285285
}
286286
}
287287

288288
func ErrorFieldNotSupportedByPredictorType(fieldKey string, predictorType PredictorType) error {
289289
return Error{
290290
Kind: ErrFieldNotSupportedByPredictorType,
291-
message: fmt.Sprintf("%s is not supported field for predictor type %s", fieldKey, predictorType.String()),
291+
message: fmt.Sprintf("%s is not a supported field for the %s predictor type", fieldKey, predictorType.String()),
292292
}
293293
}
294294

0 commit comments

Comments
 (0)