Skip to content

Rename model to model_path #1150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2020
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
2 changes: 1 addition & 1 deletion cli/local/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func UpdateAPI(apiConfig *userconfig.API, cortexYAMLPath string, projectID strin

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

// apiConfig.Predictor.Model was already added to apiConfig.Predictor.Models for ease of use
// apiConfig.Predictor.ModelPath was already added to apiConfig.Predictor.Models for ease of use
if len(apiConfig.Predictor.Models) > 0 {
localModelCaches, err := CacheModels(newAPISpec, awsClient)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cli/local/model_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ import (
func CacheModels(apiSpec *spec.API, awsClient *aws.Client) ([]*spec.LocalModelCache, error) {
modelPaths := make([]string, len(apiSpec.Predictor.Models))
for i, modelResource := range apiSpec.Predictor.Models {
modelPaths[i] = modelResource.Model
modelPaths[i] = modelResource.ModelPath
}

localModelCaches := make([]*spec.LocalModelCache, len(modelPaths))
for i, modelPath := range modelPaths {
var err error
localModelCaches[i], err = CacheModel(modelPath, awsClient)
if err != nil {
if apiSpec.Predictor.Model != nil {
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelKey)
if apiSpec.Predictor.ModelPath != nil {
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelPathKey)
}
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelsKey, apiSpec.Predictor.Models[i].Name, userconfig.ModelKey)
return nil, errors.Wrap(err, apiSpec.Identify(), userconfig.PredictorKey, userconfig.ModelsKey, apiSpec.Predictor.Models[i].Name, userconfig.ModelPathKey)
}
localModelCaches[i].TargetPath = apiSpec.Predictor.Models[i].Name
}
Expand Down
12 changes: 6 additions & 6 deletions docs/deployments/api-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ See additional documentation for [autoscaling](autoscaling.md), [compute](comput
predictor:
type: tensorflow
path: <string> # path to a python file with a TensorFlowPredictor class definition, relative to the Cortex root (required)
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (either this or 'models' must be provided)
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (either this or 'models' must be provided)
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
models: # use this when multiple models per API are desired (either this or 'model' must be provided)
models: # use this when multiple models per API are desired (either this or 'model_path' must be provided)
- name: <string> # unique name for the model (e.g. iris-classifier) (required)
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (required)
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (required)
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
...
config: <string: value> # arbitrary dictionary passed to the constructor of the Predictor (optional)
Expand Down Expand Up @@ -113,10 +113,10 @@ See additional documentation for [autoscaling](autoscaling.md), [compute](comput
predictor:
type: onnx
path: <string> # path to a python file with an ONNXPredictor class definition, relative to the Cortex root (required)
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (either this or 'models' must be provided)
models: # use this when multiple models per API are desired (either this or 'model' must be provided)
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (either this or 'models' must be provided)
models: # use this when multiple models per API are desired (either this or 'model_path' must be provided)
- name: <string> # unique name for the model (e.g. iris-classifier) (required)
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (required)
model_path: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (required)
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
...
config: <string: value> # arbitrary dictionary passed to the constructor of the Predictor (optional)
Expand Down
12 changes: 6 additions & 6 deletions docs/guides/multi-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ The following template is based on the [tensorflow/multi-model-classifier](https
path: predictor.py
models:
- name: iris
model: s3://cortex-examples/tensorflow/iris-classifier/nn
model_path: s3://cortex-examples/tensorflow/iris-classifier/nn
- name: inception
model: s3://cortex-examples/tensorflow/image-classifier/inception
model_path: s3://cortex-examples/tensorflow/image-classifier/inception
- name: resnet50
model: s3://cortex-examples/tensorflow/multi-model-classifier/resnet50
model_path: s3://cortex-examples/tensorflow/multi-model-classifier/resnet50
...
```

Expand Down Expand Up @@ -180,11 +180,11 @@ The following template is based on the [onnx/multi-model-classifier](https://git
path: predictor.py
models:
- name: resnet50
model: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
model_path: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
- name: mobilenet
model: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
model_path: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
- name: shufflenet
model: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
model_path: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
...
```

Expand Down
2 changes: 1 addition & 1 deletion examples/onnx/iris-classifier/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
predictor:
type: onnx
path: predictor.py
model: s3://cortex-examples/onnx/iris-classifier/gbtree.onnx
model_path: s3://cortex-examples/onnx/iris-classifier/gbtree.onnx
monitoring:
model_type: classification
6 changes: 3 additions & 3 deletions examples/onnx/multi-model-classifier/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
path: predictor.py
models:
- name: resnet50
model: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
model_path: s3://cortex-examples/onnx/resnet50/resnet50-v2-7.onnx
- name: mobilenet
model: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
model_path: s3://cortex-examples/onnx/mobilenet/mobilenetv2-7.onnx
- name: shufflenet
model: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
model_path: s3://cortex-examples/onnx/shufflenet/shufflenet-v2-10.onnx
config:
image-classifier-classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
image-resize: 224
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorflow/image-classifier-inception/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/image-classifier/inception
model_path: s3://cortex-examples/tensorflow/image-classifier/inception
monitoring:
model_type: classification
compute:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/resnet50
model_path: s3://cortex-examples/tensorflow/resnet50
config:
classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
input_shape: [224, 224]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/resnet50
model_path: s3://cortex-examples/tensorflow/resnet50
config:
classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
input_shape: [224, 224]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/resnet50_neuron
model_path: s3://cortex-examples/tensorflow/resnet50_neuron
config:
classes: https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
input_shape: [224, 224]
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorflow/iris-classifier/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/iris-classifier/nn
model_path: s3://cortex-examples/tensorflow/iris-classifier/nn
monitoring:
model_type: classification
2 changes: 1 addition & 1 deletion examples/tensorflow/license-plate-reader/cortex_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor_yolo.py
model: s3://cortex-examples/tensorflow/license-plate-reader/yolov3_tf
model_path: s3://cortex-examples/tensorflow/license-plate-reader/yolov3_tf
signature_key: serving_default
config:
model_config: config.json
Expand Down
6 changes: 3 additions & 3 deletions examples/tensorflow/multi-model-classifier/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
path: predictor.py
models:
- name: inception
model: s3://cortex-examples/tensorflow/image-classifier/inception
model_path: s3://cortex-examples/tensorflow/image-classifier/inception
- name: iris
model: s3://cortex-examples/tensorflow/iris-classifier/nn
model_path: s3://cortex-examples/tensorflow/iris-classifier/nn
- name: resnet50
model: s3://cortex-examples/tensorflow/resnet50
model_path: s3://cortex-examples/tensorflow/resnet50
config:
models:
iris:
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorflow/sentiment-analyzer/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/sentiment-analyzer/bert
model_path: s3://cortex-examples/tensorflow/sentiment-analyzer/bert
monitoring:
model_type: classification
compute:
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorflow/text-generator/cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
predictor:
type: tensorflow
path: predictor.py
model: s3://cortex-examples/tensorflow/text-generator/gpt-2/124M
model_path: s3://cortex-examples/tensorflow/text-generator/gpt-2/124M
compute:
cpu: 1
gpu: 1
6 changes: 3 additions & 3 deletions pkg/operator/operator/k8s_specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ func tfDownloadArgs(api *spec.API) string {
itemName = fmt.Sprintf("model %s", model.Name)
}
downloadConfig.DownloadArgs = append(downloadConfig.DownloadArgs, downloadContainerArg{
From: model.Model,
From: model.ModelPath,
To: path.Join(rootModelPath, model.Name),
Unzip: strings.HasSuffix(model.Model, ".zip"),
Unzip: strings.HasSuffix(model.ModelPath, ".zip"),
ItemName: itemName,
TFModelVersionRename: path.Join(rootModelPath, model.Name, "1"),
})
Expand Down Expand Up @@ -531,7 +531,7 @@ func onnxDownloadArgs(api *spec.API) string {
itemName = fmt.Sprintf("model %s", model.Name)
}
downloadConfig.DownloadArgs = append(downloadConfig.DownloadArgs, downloadContainerArg{
From: model.Model,
From: model.ModelPath,
To: path.Join(rootModelPath, model.Name),
ItemName: itemName,
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/spec/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ func ErrorInvalidTensorFlowModelPath() error {
})
}

func ErrorMissingModel(singleModelField string, multiModelField string, predictorType userconfig.PredictorType) error {
func ErrorMissingModel(predictorType userconfig.PredictorType) error {
return errors.WithStack(&errors.Error{
Kind: ErrMissingModel,
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),
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),
})
}

Expand Down
Loading