-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41569bd
commit 473b30a
Showing
13 changed files
with
550 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"apiVersion": "machinelearning.seldon.io/v1alpha2", | ||
"kind": "SeldonDeployment", | ||
"metadata": { | ||
"labels": { | ||
"app": "seldon" | ||
}, | ||
"name": "mnist-classifier" | ||
}, | ||
"spec": { | ||
"annotations": { | ||
"project_name": "Mnist classification" | ||
}, | ||
"name": "mnist-deployment", | ||
"oauth_key": "oauth-key", | ||
"oauth_secret": "oauth-secret", | ||
"predictors": [ | ||
{ | ||
"componentSpecs": [{ | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"image": "seldonio/deep-mnist:0.1", | ||
"imagePullPolicy": "IfNotPresent", | ||
"name": "tf-mnist-classifier", | ||
"resources": { | ||
"requests": { | ||
"memory": "1Mi" | ||
} | ||
} | ||
} | ||
], | ||
"terminationGracePeriodSeconds": 20 | ||
} | ||
}], | ||
"graph": { | ||
"children": [], | ||
"name": "tf-mnist-classifier", | ||
"endpoint": { | ||
"type" : "REST" | ||
}, | ||
"type": "MODEL" | ||
}, | ||
"name": "tf-mnist-predictor", | ||
"replicas": 1, | ||
"labels":{ | ||
"version":"v2" | ||
} | ||
} | ||
|
||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Ambassador | ||
kubectl port-forward $(kubectl get pods -n seldon -l service=ambassador -o jsonpath='{.items[0].metadata.name}') -n seldon 8002:8080 & | ||
|
||
#Seldon Grafana | ||
kubectl port-forward $(kubectl get pods -n seldon -l app=grafana-prom-server -o jsonpath='{.items[0].metadata.name}') -n seldon 3001:3000 & | ||
|
||
#Istio grafana | ||
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import graphviz | ||
import json | ||
|
||
def _populate_graph(dot, root, suffix=''): | ||
name = root.get("name") | ||
id = name+suffix | ||
if root.get("implementation"): | ||
dot.node(id, label=name, shape="box", style="filled", color="lightgrey") | ||
else: | ||
dot.node(id, label=name, shape="box") | ||
endpoint_type = root.get("endpoint",{}).get("type") | ||
if endpoint_type is not None: | ||
dot.node(id+'endpoint', label=endpoint_type) | ||
dot.edge(id,id+'endpoint') | ||
for child in root.get("children",[]): | ||
child_id = _populate_graph(dot,child) | ||
dot.edge(id, child_id) | ||
return id | ||
|
||
def get_graph(filename,predictor=0): | ||
deployment = json.load(open(filename,'r')) | ||
predictors = deployment.get("spec").get("predictors") | ||
dot = graphviz.Digraph() | ||
|
||
with dot.subgraph(name="cluster_0") as pdot: | ||
graph = predictors[0].get("graph") | ||
_populate_graph(pdot, graph, suffix='0') | ||
pdot.attr(label="predictor") | ||
|
||
if len(predictors)>1: | ||
with dot.subgraph(name="cluster_1") as cdot: | ||
graph = predictors[1].get("graph") | ||
_populate_graph(cdot, graph, suffix='1') | ||
cdot.attr(label="canary") | ||
|
||
return dot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MODEL_NAME=SkMnist | ||
API_TYPE=REST | ||
SERVICE_TYPE=MODEL | ||
PERSISTENCE=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from sklearn.externals import joblib | ||
|
||
class SkMnist(object): | ||
def __init__(self): | ||
self.class_names = ["class:{}".format(str(i)) for i in range(10)] | ||
self.clf = joblib.load('sk.pkl') | ||
|
||
def predict(self,X,feature_names): | ||
predictions = self.clf.predict_proba(X) | ||
return predictions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"features":[ | ||
{ | ||
"name":"x", | ||
"dtype":"FLOAT", | ||
"ftype":"continuous", | ||
"range":[0,1], | ||
"repeat":784 | ||
} | ||
], | ||
"targets":[ | ||
{ | ||
"name":"class", | ||
"dtype":"FLOAT", | ||
"ftype":"continuous", | ||
"range":[0,1], | ||
"repeat":10 | ||
} | ||
] | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
scipy>= 0.13.3 | ||
scikit-learn>=0.18 |
Oops, something went wrong.