mirror of https://github.com/kubeflow/examples.git
				
				
				
			Fix model serving part of xgboost_ams_housing example. (#478)
* Fix model serving for ames house example * change the step instructions * add public image
This commit is contained in:
		
							parent
							
								
									46a795693a
								
							
						
					
					
						commit
						1ed08b9af2
					
				|  | @ -93,30 +93,18 @@ The model is exported to the location `/tmp/ames/housing.dat`. We will use [Seld | ||||||
|  * `requirements.txt` |  * `requirements.txt` | ||||||
| 
 | 
 | ||||||
| ## Model Serving Locally | ## Model Serving Locally | ||||||
| We are going to use [seldon-core](https://github.com/SeldonIO/seldon-core/) to serve the model. [HousingServe.py](seldon_serve/HousingServe.py) contains the code to serve the model. Run the following command to create a microservice  | We are going to use [seldon-core](https://github.com/SeldonIO/seldon-core/) to serve the model. [HoussingServe.py](seldon_serve/HousingServe.py) contains the code to serve the model. You can find seldon core model wrapping details [here](https://github.com/SeldonIO/seldon-core/blob/master/docs/wrappers/python.md). The seldon-core microservice image can be built by the following command. | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| docker run -v $(pwd):/seldon_serve seldonio/core-python-wrapper:0.7 /seldon_serve HousingServe 0.1 gcr.io --base-image=python:3.6 --image-name=${PROJECT_ID}/housingserve | cd seldon_serve && s2i build . seldonio/seldon-core-s2i-python2:0.4 gcr.io/${PROJECT_ID}/housingserve:latest --loglevel=3 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Let's build the seldon-core microservice image. You can find seldon core model wrapping details [here](https://github.com/SeldonIO/seldon-core/blob/master/docs/wrappers/python.md). | 
 | ||||||
|  | 
 | ||||||
|  | Let's run the docker image locally. | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| cd build | docker run -p 5000:5000 gcr.io/${PROJECT_ID}/housingserve:latest | ||||||
| ./build_image.sh |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| You should see the docker image locally `gcr.io/cloudmlplat/housingserve` which can be run locally to serve the model. Before running the image locally push it to `gcr.io` |  | ||||||
| 
 |  | ||||||
| ``` |  | ||||||
| gcloud auth configure-docker |  | ||||||
| docker push gcr.io/${PROJECT_ID}/housingserve:0.1 |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| Let's run the docker image now |  | ||||||
| 
 |  | ||||||
| ``` |  | ||||||
| docker run -p 5000:5000 gcr.io/cloudmlplat/housingserve:0.1 |  | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Now you are ready to send requests on `localhost:5000` | Now you are ready to send requests on `localhost:5000` | ||||||
|  | @ -125,6 +113,7 @@ Now you are ready to send requests on `localhost:5000` | ||||||
| curl -H "Content-Type: application/x-www-form-urlencoded" -d 'json={"data":{"tensor":{"shape":[1,37],"values":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]}}}' http://localhost:5000/predict | curl -H "Content-Type: application/x-www-form-urlencoded" -d 'json={"data":{"tensor":{"shape":[1,37],"values":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]}}}' http://localhost:5000/predict | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | The response looks like this. | ||||||
| ``` | ``` | ||||||
| { | { | ||||||
|   "data": { |   "data": { | ||||||
|  | @ -163,12 +152,19 @@ tf-hub-0                                  1/1       Running   0          16m | ||||||
| tf-job-dashboard-7b57c549c8-bfpp8         1/1       Running   0          16m | tf-job-dashboard-7b57c549c8-bfpp8         1/1       Running   0          16m | ||||||
| tf-job-operator-594d8c7ddd-lqn8r          1/1       Running   0          16m | tf-job-operator-594d8c7ddd-lqn8r          1/1       Running   0          16m | ||||||
| ``` | ``` | ||||||
| Deploy the XGBoost model | 
 | ||||||
|  | Second, we need to upload our previously built docker image to `gcr.io`. A public image is available at `gcr.io/kubeflow-examples/housingserve:latest` | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| ks generate seldon-serve-simple xgboost-ames   \ | gcloud auth configure-docker | ||||||
|  | docker push gcr.io/${PROJECT_ID}/housingserve:latest | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | Finally, we can deploy the XGBoost model | ||||||
|  | ``` | ||||||
|  | ks generate seldon-serve-simple-v1alpha2 xgboost-ames   \ | ||||||
|                                 --name=xgboost-ames   \ |                                 --name=xgboost-ames   \ | ||||||
|                                 --image=gcr.io/cloudmlplat/housingserve:0.1   \ |                                 --image=gcr.io/${PROJECT_ID}/housingserve:latest   \ | ||||||
|                                 --namespace=${NAMESPACE}   \ |                                 --namespace=${NAMESPACE}   \ | ||||||
|                                 --replicas=1 |                                 --replicas=1 | ||||||
|                                  |                                  | ||||||
|  |  | ||||||
|  | @ -0,0 +1,4 @@ | ||||||
|  | MODEL_NAME=HousingServe | ||||||
|  | API_TYPE=REST | ||||||
|  | SERVICE_TYPE=MODEL | ||||||
|  | PERSISTENCE=0 | ||||||
		Loading…
	
		Reference in New Issue