Skip to content

Commit

Permalink
Created new complex deployment examples, created new notebook advance…
Browse files Browse the repository at this point in the history
…d_graphs, created visualizer tool for displaying graphs
  • Loading branch information
Maximophone committed Jan 4, 2018
1 parent ed1247a commit ee76cde
Show file tree
Hide file tree
Showing 6 changed files with 810 additions and 0 deletions.
345 changes: 345 additions & 0 deletions notebooks/advanced_graphs.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,345 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"!helm init"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import requests\n",
"from requests.auth import HTTPBasicAuth\n",
"from proto import prediction_pb2\n",
"from proto import prediction_pb2_grpc\n",
"import grpc\n",
"import commands\n",
"from visualizer import get_graph\n",
"\n",
"MINIKUBE_IP=commands.getoutput('minikube ip')\n",
"\n",
"def get_token():\n",
" payload = {'grant_type': 'client_credentials'}\n",
" response = requests.post(\n",
" \"http://\"+MINIKUBE_IP+\":30032/oauth/token\",\n",
" auth=HTTPBasicAuth('oauth-key', 'oauth-secret'),\n",
" data=payload)\n",
" token = response.json()[\"access_token\"]\n",
" return token\n",
"\n",
"def rest_request():\n",
" token = get_token()\n",
" headers = {'Authorization': 'Bearer '+token}\n",
" payload = {\"data\":{\"names\":[\"a\",\"b\"],\"tensor\":{\"shape\":[2,2],\"values\":[0,0,1,1]}}}\n",
" response = requests.post(\n",
" \"http://\"+MINIKUBE_IP+\":30032/api/v0.1/predictions\",\n",
" headers=headers,\n",
" json=payload)\n",
" print response.text\n",
" \n",
"def grpc_request():\n",
" token = get_token()\n",
" datadef = prediction_pb2.DefaultData(\n",
" names = [\"a\",\"b\"],\n",
" tensor = prediction_pb2.Tensor(\n",
" shape = [3,2],\n",
" values = [1.0,1.0,2.0,3.0,4.0,5.0]\n",
" )\n",
" )\n",
" request = prediction_pb2.SeldonMessage(data = datadef)\n",
" channel = grpc.insecure_channel(MINIKUBE_IP+\":30033\")\n",
" stub = prediction_pb2_grpc.SeldonStub(channel)\n",
" metadata = [('oauth_token', token)]\n",
" response = stub.Predict(request=request,metadata=metadata)\n",
" print response\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [],
"source": [
"%%bash\n",
"cd ../helm-charts\n",
"helm install seldon-core --name seldon-core \\\n",
" --set grafana_prom_admin_password=password \\\n",
" --set persistence.enabled=false"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl get pods"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"get_graph(\"resources/model.json\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl apply -f resources/model.json"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl get seldondeployments seldon-deployment-example -o jsonpath=\"{.status}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"rest_request()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"grpc_request()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl delete -f resources/model.json"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"get_graph(\"resources/random_ab_test.json\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl apply -f resources/random_ab_test.json"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl get seldondeployments seldon-deployment-example -o jsonpath='{.status}'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"rest_request()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"grpc_request()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl delete -f resources/random_ab_test.json"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"get_graph(\"resources/ensemble.json\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl apply -f resources/ensemble.json"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl get seldondeployments seldon-deployment-example-ensembles -o jsonpath='{.status}'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"rest_request()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"grpc_request()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!kubectl delete -f resources/ensemble.json"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"!helm delete seldon-core --purge"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit ee76cde

Please sign in to comment.