Skip to content

Commit e3d755e

Browse files
authored
Rename model to model_path (#1150)
1 parent f155100 commit e3d755e

File tree

23 files changed

+118
-119
lines changed

23 files changed

+118
-119
lines changed

Diff for: cli/local/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func UpdateAPI(apiConfig *userconfig.API, cortexYAMLPath string, projectID strin
4848

4949
newAPISpec := spec.GetAPISpec(apiConfig, projectID, _deploymentID)
5050

51-
// apiConfig.Predictor.Model was already added to apiConfig.Predictor.Models for ease of use
51+
// apiConfig.Predictor.ModelPath was already added to apiConfig.Predictor.Models for ease of use
5252
if len(apiConfig.Predictor.Models) > 0 {
5353
localModelCaches, err := CacheModels(newAPISpec, awsClient)
5454
if err != nil {

Diff for: cli/local/model_cache.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ import (
3838
func CacheModels(apiSpec *spec.API, awsClient *aws.Client) ([]*spec.LocalModelCache, error) {
3939
modelPaths := make([]string, len(apiSpec.Predictor.Models))
4040
for i, modelResource := range apiSpec.Predictor.Models {
41-
modelPaths[i] = modelResource.Model
41+
modelPaths[i] = modelResource.ModelPath
4242
}
4343

4444
localModelCaches := make([]*spec.LocalModelCache, len(modelPaths))
4545
for i, modelPath := range modelPaths {
4646
var err error
4747
localModelCaches[i], err = CacheModel(modelPath, awsClient)
4848
if err != nil {
49-
if apiSpec.Predictor.Model != nil {
50-
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelKey)
49+
if apiSpec.Predictor.ModelPath != nil {
50+
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelPathKey)
5151
}
52-
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelsKey, apiSpec.Predictor.Models[i].Name, userconfig.ModelKey)
52+
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelsKey, apiSpec.Predictor.Models[i].Name, userconfig.ModelPathKey)
5353
}
5454
localModelCaches[i].TargetPath = apiSpec.Predictor.Models[i].Name
5555
}

Diff for: docs/deployments/api-configuration.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ See additional documentation for [autoscaling](autoscaling.md), [compute](comput
6060
predictor:
6161
type: tensorflow
6262
path: <string> # path to a python file with a TensorFlowPredictor class definition, relative to the Cortex root (required)
63-
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (either this or 'models' must be provided)
63+
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (either this or 'models' must be provided)
6464
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
65-
models: # use this when multiple models per API are desired (either this or 'model' must be provided)
65+
models: # use this when multiple models per API are desired (either this or 'model_path' must be provided)
6666
- name: <string> # unique name for the model (e.g. iris-classifier) (required)
67-
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (required)
67+
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (required)
6868
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
6969
...
7070
config: <string: value> # arbitrary dictionary passed to the constructor of the Predictor (optional)
@@ -113,10 +113,10 @@ See additional documentation for [autoscaling](autoscaling.md), [compute](comput
113113
predictor:
114114
type: onnx
115115
path: <string> # path to a python file with an ONNXPredictor class definition, relative to the Cortex root (required)
116-
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (either this or 'models' must be provided)
117-
models: # use this when multiple models per API are desired (either this or 'model' must be provided)
116+
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (either this or 'models' must be provided)
117+
models: # use this when multiple models per API are desired (either this or 'model_path' must be provided)
118118
- name: <string> # unique name for the model (e.g. iris-classifier) (required)
119-
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (required)
119+
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (required)
120120
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
121121
...
122122
config: <string: value> # arbitrary dictionary passed to the constructor of the Predictor (optional)

Diff for: docs/guides/multi-model.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ The following template is based on the [tensorflow/multi-model-classifier](https
9898
path: predictor.py
9999
models:
100100
- name: iris
101-
model: s3://cortex-examples/tensorflow/iris-classifier/nn
101+
model_path: s3://cortex-examples/tensorflow/iris-classifier/nn
102102
- name: inception
103-
model: s3://cortex-examples/tensorflow/image-classifier/inception
103+
model_path: s3://cortex-examples/tensorflow/image-classifier/inception
104104
- name: resnet50
105-
model: s3://cortex-examples/tensorflow/multi-model-classifier/resnet50
105+
model_path: s3://cortex-examples/tensorflow/multi-model-classifier/resnet50
106106
...
107107
```
108108

@@ -180,11 +180,11 @@ The following template is based on the [onnx/multi-model-classifier](https://git
180180
path: predictor.py
181181
models:
182182
- name: resnet50
183-
model: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
183+
model_path: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
184184
- name: mobilenet
185-
model: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
185+
model_path: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
186186
- name: shufflenet
187-
model: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
187+
model_path: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
188188
...
189189
```
190190

Diff for: examples/onnx/iris-classifier/cortex.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
predictor:
55
type: onnx
66
path: predictor.py
7-
model: s3://cortex-examples/onnx/iris-classifier/gbtree.onnx
7+
model_path: s3://cortex-examples/onnx/iris-classifier/gbtree.onnx
88
monitoring:
99
model_type: classification

Diff for: examples/onnx/multi-model-classifier/cortex.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
path: predictor.py
77
models:
88
- name: resnet50
9-
model: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
9+
model_path: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
1010
- name: mobilenet
11-
model: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
11+
model_path: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
1212
- name: shufflenet
13-
model: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
13+
model_path: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
1414
config:
1515
image-classifier-classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
1616
image-resize: 224

Diff for: examples/tensorflow/image-classifier-inception/cortex.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/image-classifier/inception
7+
model_path: s3://cortex-examples/tensorflow/image-classifier/inception
88
monitoring:
99
model_type: classification
1010
compute:

Diff for: examples/tensorflow/image-classifier-resnet50/cortex_cpu.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/resnet50
7+
model_path: s3://cortex-examples/tensorflow/resnet50
88
config:
99
classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
1010
input_shape: [224, 224]

Diff for: examples/tensorflow/image-classifier-resnet50/cortex_gpu.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/resnet50
7+
model_path: s3://cortex-examples/tensorflow/resnet50
88
config:
99
classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
1010
input_shape: [224, 224]

Diff for: examples/tensorflow/image-classifier-resnet50/cortex_inf.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/resnet50_neuron
7+
model_path: s3://cortex-examples/tensorflow/resnet50_neuron
88
config:
99
classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
1010
input_shape: [224, 224]

Diff for: examples/tensorflow/iris-classifier/cortex.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/iris-classifier/nn
7+
model_path: s3://cortex-examples/tensorflow/iris-classifier/nn
88
monitoring:
99
model_type: classification

Diff for: examples/tensorflow/license-plate-reader/cortex_full.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor_yolo.py
7-
model: s3://cortex-examples/tensorflow/license-plate-reader/yolov3_tf
7+
model_path: s3://cortex-examples/tensorflow/license-plate-reader/yolov3_tf
88
signature_key: serving_default
99
config:
1010
model_config: config.json

Diff for: examples/tensorflow/multi-model-classifier/cortex.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
path: predictor.py
77
models:
88
- name: inception
9-
model: s3://cortex-examples/tensorflow/image-classifier/inception
9+
model_path: s3://cortex-examples/tensorflow/image-classifier/inception
1010
- name: iris
11-
model: s3://cortex-examples/tensorflow/iris-classifier/nn
11+
model_path: s3://cortex-examples/tensorflow/iris-classifier/nn
1212
- name: resnet50
13-
model: s3://cortex-examples/tensorflow/resnet50
13+
model_path: s3://cortex-examples/tensorflow/resnet50
1414
config:
1515
models:
1616
iris:

Diff for: examples/tensorflow/sentiment-analyzer/cortex.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/sentiment-analyzer/bert
7+
model_path: s3://cortex-examples/tensorflow/sentiment-analyzer/bert
88
monitoring:
99
model_type: classification
1010
compute:

Diff for: examples/tensorflow/text-generator/cortex.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
predictor:
55
type: tensorflow
66
path: predictor.py
7-
model: s3://cortex-examples/tensorflow/text-generator/gpt-2/124M
7+
model_path: s3://cortex-examples/tensorflow/text-generator/gpt-2/124M
88
compute:
99
cpu: 1
1010
gpu: 1

Diff for: pkg/operator/operator/k8s_specs.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ func tfDownloadArgs(api *spec.API) string {
261261
itemName = fmt.Sprintf("model %s", model.Name)
262262
}
263263
downloadConfig.DownloadArgs = append(downloadConfig.DownloadArgs, downloadContainerArg{
264-
From: model.Model,
264+
From: model.ModelPath,
265265
To: path.Join(rootModelPath, model.Name),
266-
Unzip: strings.HasSuffix(model.Model, ".zip"),
266+
Unzip: strings.HasSuffix(model.ModelPath, ".zip"),
267267
ItemName: itemName,
268268
TFModelVersionRename: path.Join(rootModelPath, model.Name, "1"),
269269
})
@@ -531,7 +531,7 @@ func onnxDownloadArgs(api *spec.API) string {
531531
itemName = fmt.Sprintf("model %s", model.Name)
532532
}
533533
downloadConfig.DownloadArgs = append(downloadConfig.DownloadArgs, downloadContainerArg{
534-
From: model.Model,
534+
From: model.ModelPath,
535535
To: path.Join(rootModelPath, model.Name),
536536
ItemName: itemName,
537537
})

Diff for: pkg/types/spec/errors.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ func ErrorInvalidTensorFlowModelPath() error {
241241
})
242242
}
243243

244-
func ErrorMissingModel(singleModelField string, multiModelField string, predictorType userconfig.PredictorType) error {
244+
func ErrorMissingModel(predictorType userconfig.PredictorType) error {
245245
return errors.WithStack(&errors.Error{
246246
Kind: ErrMissingModel,
247-
Message: fmt.Sprintf("at least one model must be specified for %s predictor type; use fields %s:%s or %s:%s to add model(s)", predictorType, userconfig.PredictorKey, singleModelField, userconfig.PredictorKey, multiModelField),
247+
Message: fmt.Sprintf("at least one model must be specified for %s predictor type; use fields %s:%s or %s:%s to add model(s)", predictorType, userconfig.PredictorKey, userconfig.ModelPathKey, userconfig.PredictorKey, userconfig.ModelsKey),
248248
})
249249
}
250250

0 commit comments

Comments
 (0)