@@ -61,16 +61,14 @@ $ python3 trainer.py
6161
6262import boto3
6363import pickle
64- import re
6564
6665labels = [" setosa" , " versicolor" , " virginica" ]
6766
6867
6968class PythonPredictor :
7069 def __init__ (self , config ):
71- bucket, key = re.match(" s3://(.+?)/(.+)" , config[" model" ]).groups()
7270 s3 = boto3.client(" s3" )
73- s3.download_file(bucket, key, " model.pkl" )
71+ s3.download_file(config[ " bucket" ], config[ " key" ] , " model.pkl" )
7472
7573 self .model = pickle.load(open (" model.pkl" , " rb" ))
7674
@@ -117,7 +115,8 @@ Create a `cortex.yaml` file and add the configuration below. A `deployment` spec
117115 python :
118116 predictor : predictor.py
119117 config :
120- model : s3://cortex-examples/sklearn/iris-classifier/model.pkl
118+ bucket : cortex-examples
119+ key : sklearn/iris-classifier/model.pkl
121120` ` `
122121
123122<br>
@@ -182,7 +181,8 @@ Add a `tracker` to your `cortex.yaml` and specify that this is a classification
182181 python:
183182 predictor: predictor.py
184183 config:
185- model: s3://cortex-examples/sklearn/iris-classifier/model.pkl
184+ bucket: cortex-examples
185+ key: sklearn/iris-classifier/model.pkl
186186 tracker:
187187 model_type: classification
188188` ` `
@@ -224,7 +224,8 @@ This model is fairly small but larger models may require more compute resources.
224224 python:
225225 predictor: predictor.py
226226 config:
227- model: s3://cortex-examples/sklearn/iris-classifier/model.pkl
227+ bucket: cortex-examples
228+ key: sklearn/iris-classifier/model.pkl
228229 tracker:
229230 model_type: classification
230231 compute:
@@ -269,7 +270,8 @@ If you trained another model and want to A/B test it with your previous model, s
269270 python:
270271 predictor: predictor.py
271272 config:
272- model: s3://cortex-examples/sklearn/iris-classifier/model.pkl
273+ bucket: cortex-examples
274+ key: sklearn/iris-classifier/model.pkl
273275 tracker:
274276 model_type: classification
275277 compute:
@@ -281,7 +283,8 @@ If you trained another model and want to A/B test it with your previous model, s
281283 python:
282284 predictor: predictor.py
283285 config:
284- model: s3://cortex-examples/sklearn/iris-classifier/another-model.pkl
286+ bucket: cortex-examples
287+ key: sklearn/iris-classifier/another-model.pkl
285288 tracker:
286289 model_type: classification
287290 compute:
@@ -316,16 +319,14 @@ First, implement `batch-predictor.py` with a `predict` function that can process
316319
317320import boto3
318321import pickle
319- import re
320322
321323labels = ["setosa", "versicolor", "virginica"]
322324
323325
324326class PythonPredictor:
325327 def __init__(self, config):
326- bucket, key = re.match("s3://(.+?)/(.+)", config["model"]).groups()
327328 s3 = boto3.client("s3")
328- s3.download_file(bucket, key, "model.pkl")
329+ s3.download_file(config[" bucket"], config[" key"] , "model.pkl")
329330
330331 self.model = pickle.load(open("model.pkl", "rb"))
331332
@@ -355,7 +356,8 @@ Next, add the `api` to `cortex.yaml`:
355356 python:
356357 predictor: predictor.py
357358 config:
358- model: s3://cortex-examples/sklearn/iris-classifier/model.pkl
359+ bucket: cortex-examples
360+ key: sklearn/iris-classifier/model.pkl
359361 tracker:
360362 model_type: classification
361363 compute:
@@ -367,7 +369,8 @@ Next, add the `api` to `cortex.yaml`:
367369 python:
368370 predictor: predictor.py
369371 config:
370- model: s3://cortex-examples/sklearn/iris-classifier/another-model.pkl
372+ bucket: cortex-examples
373+ key: sklearn/iris-classifier/another-model.pkl
371374 tracker:
372375 model_type: classification
373376 compute:
@@ -380,7 +383,8 @@ Next, add the `api` to `cortex.yaml`:
380383 python:
381384 predictor: batch-predictor.py
382385 config:
383- model: s3://cortex-examples/sklearn/iris-classifier/model.pkl
386+ bucket: cortex-examples
387+ key: sklearn/iris-classifier/model.pkl
384388 compute:
385389 cpu: 0.5
386390 mem: 1G
0 commit comments