Skip to content

Commit a8efe9b

Browse files
authored
Make predictor top-level key, update documentation and examples (#704)
1 parent 8d00653 commit a8efe9b

File tree

33 files changed

+427
-380
lines changed

33 files changed

+427
-380
lines changed

cli/cmd/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func describeAPI(name string, resourcesRes *schema.GetResourcesResponse, flagVer
272272

273273
out += fmt.Sprintf("\n%s curl %s?debug=true -X POST -H \"Content-Type: application/json\" -d @sample.json", console.Bold("curl:"), apiEndpoint)
274274

275-
if api.TensorFlow != nil || api.ONNX != nil {
275+
if api.Predictor.Type == userconfig.TensorFlowPredictorType || api.Predictor.Type == userconfig.ONNXPredictorType {
276276
out += "\n\n" + describeModelInput(groupStatus, apiEndpoint)
277277
}
278278

docs/deployments/onnx.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ You can deploy ONNX models as web services by defining a class that implements C
1010
- kind: api
1111
name: <string> # API name (required)
1212
endpoint: <string> # the endpoint for the API (default: /<deployment_name>/<api_name>)
13-
onnx:
13+
predictor:
14+
type: onnx
15+
path: <string> # path to a python file with an ONNXPredictor class definition, relative to the Cortex root (required)
1416
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model.onnx) (required)
15-
predictor: <string> # path to a python file with an ONNXPredictor class definition, relative to the Cortex root (required)
1617
config: <string: value> # dictionary passed to the constructor of a Predictor (optional)
1718
python_path: <string> # path to the root of your Python folder that will be appended to PYTHONPATH (default: folder containing cortex.yaml)
1819
env: <string: string> # dictionary of environment variables
@@ -36,9 +37,10 @@ See [packaging ONNX models](../packaging-models/onnx.md) for information about e
3637
```yaml
3738
- kind: api
3839
name: my-api
39-
onnx:
40+
predictor:
41+
type: onnx
42+
path: predictor.py
4043
model: s3://my-bucket/my-model.onnx
41-
predictor: predictor.py
4244
compute:
4345
gpu: 1
4446
```

docs/deployments/prediction-monitoring.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ For classification models, the tracker should be configured with `model_type: cl
2121
```yaml
2222
- kind: api
2323
name: iris
24-
python:
25-
predictor: predictor.py
24+
predictor:
25+
type: python
26+
path: predictor.py
2627
tracker:
2728
model_type: classification
2829
```

docs/deployments/python.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ In addition to supporting Python models via the Python Predictor interface, Cort
1515
- kind: api
1616
name: <string> # API name (required)
1717
endpoint: <string> # the endpoint for the API (default: /<deployment_name>/<api_name>)
18-
python:
19-
predictor: <string> # path to a python file with a PythonPredictor class definition, relative to the Cortex root (required)
18+
predictor:
19+
type: python
20+
path: <string> # path to a python file with a PythonPredictor class definition, relative to the Cortex root (required)
2021
config: <string: value> # dictionary passed to the constructor of a Predictor (optional)
2122
python_path: <string> # path to the root of your Python folder that will be appended to PYTHONPATH (default: folder containing cortex.yaml)
2223
env: <string: string> # dictionary of environment variables

docs/deployments/tensorflow.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ You can deploy TensorFlow models as web services by defining a class that implem
1010
- kind: api
1111
name: <string> # API name (required)
1212
endpoint: <string> # the endpoint for the API (default: /<deployment_name>/<api_name>)
13-
tensorflow:
13+
predictor:
14+
type: tensorflow
15+
path: <string> # path to a python file with a TensorFlowPredictor class definition, relative to the Cortex root (required)
1416
model: <string> # S3 path to an exported model (e.g. s3://my-bucket/exported_model) (required)
15-
predictor: <string> # path to a python file with a TensorFlowPredictor class definition, relative to the Cortex root (required)
1617
signature_key: <string> # name of the signature def to use for prediction (required if your model has more than one signature def)
1718
config: <string: value> # dictionary that can be used to configure custom values (optional)
1819
python_path: <string> # path to the root of your Python folder that will be appended to PYTHONPATH (default: folder containing cortex.yaml)
@@ -37,9 +38,10 @@ See [packaging TensorFlow models](../packaging-models/tensorflow.md) for how to
3738
```yaml
3839
- kind: api
3940
name: my-api
40-
tensorflow:
41+
predictor:
42+
type: tensorflow
43+
path: predictor.py
4144
model: s3://my-bucket/my-model
42-
predictor: predictor.py
4345
compute:
4446
gpu: 1
4547
```

docs/packaging-models/onnx.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Reference your model in an `api`:
3131
```yaml
3232
- kind: api
3333
name: my-api
34-
onnx:
34+
predictor:
35+
type: onnx
3536
model: s3://my-bucket/model.onnx
3637
predictor: predictor.py
3738
```

docs/packaging-models/tensorflow.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Reference your model in an `api`:
3838
```yaml
3939
- kind: api
4040
name: my-api
41-
tensorflow:
41+
predictor:
42+
type: tensorflow
4243
model: s3://my-bucket/bert
4344
predictor: predictor.py
4445
```
@@ -56,7 +57,8 @@ Reference the zipped model in an `api`:
5657
```yaml
5758
- kind: api
5859
name: my-api
59-
tensorflow:
60+
predictor:
61+
type: tensorflow
6062
model: s3://my-bucket/bert.zip
6163
predictor: predictor.py
6264
```

examples/pytorch/answer-generator/cortex.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
- kind: api
77
name: generator
8-
python:
9-
predictor: predictor.py
8+
predictor:
9+
type: python
10+
path: predictor.py
1011
config:
1112
device: cuda # use "cpu" to run on CPUs
1213
compute:

examples/pytorch/image-classifier/cortex.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
- kind: api
77
name: classifier
8-
python:
9-
predictor: predictor.py
8+
predictor:
9+
type: python
10+
path: predictor.py
1011
compute:
1112
cpu: 1
1213
gpu: 1

examples/pytorch/iris-classifier/cortex.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
- kind: api
77
name: classifier
8-
python:
9-
predictor: predictor.py
8+
predictor:
9+
type: python
10+
path: predictor.py
1011
config:
1112
model: s3://cortex-examples/pytorch/iris-classifier/weights.pth
1213
tracker:

0 commit comments

Comments
 (0)