Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Timeouts Notebook #2753

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/examples/notebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Production Configurations and Integrations

Example Helm Deployments <helm_examples>
Max gRPC Message Size <max_grpc_msg_size>
REST timeouts <rest_timeouts>
Configurable timeouts <timeouts>
Deploy Multiple Seldon Core Operators <multiple_operators>
Protocol Examples <protocol_examples>
Custom Protobuf Data Example <customdata_example>
Expand Down
19 changes: 15 additions & 4 deletions examples/models/mean_classifier/MeanClassifier.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import numpy as np
import math
import time
import logging

def f(x):
return 1/(1+math.exp(-x))

class MeanClassifier(object):

def __init__(self, intValue=0):
def __init__(self, intValue=0, delaySecs=0):
self.class_names = ["proba"]
assert type(intValue) == int, "intValue parameters must be an integer"
assert type(intValue) == int, "intValue parameter must be an integer"
self.int_value = intValue
logging.info("intValue set to %d",intValue)

print("Loading model here")
assert type(delaySecs) == int, "delaySecs parameter must be an integer"
self.delay_secs = delaySecs
logging.info("Delay secs set to %d",delaySecs)

logging.info("loading model here")

X = np.load(open("model.npy",'rb'), encoding='latin1')
self.threshold_ = X.mean() + self.int_value
Expand All @@ -20,10 +27,14 @@ def _meaning(self, x):
return f(x.mean()-self.threshold_)

def predict(self, X, feature_names):
print(X)
logging.info("Input %s",X)
X = np.array(X)
assert len(X.shape) == 2, "Incorrect shape"

if self.delay_secs > 0:
logging.info("Delaying %d secs",self.delay_secs)
time.sleep(self.delay_secs)

return [[self._meaning(x)] for x in X]

def health_status(self):
Expand Down
73 changes: 24 additions & 49 deletions notebooks/resources/model_long_timeouts.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
{
"apiVersion": "machinelearning.seldon.io/v1alpha2",
"kind": "SeldonDeployment",
"metadata": {
"labels": {
"app": "seldon"
},
"name": "model-long-timeout"
},
"spec": {
"annotations": {
"deployment_version": "v1",
"seldon.io/rest-timeout":"100000",
"seldon.io/grpc-timeout":"100000"
},
"name": "long-to",
"predictors": [
{
"componentSpecs": [{
"spec": {
"containers": [
{
"image": "seldonio/mock_classifier:1.5.0-dev",
"imagePullPolicy": "IfNotPresent",
"name": "classifier",
"resources": {
"requests": {
"memory": "1Mi"
}
}
}
],
"terminationGracePeriodSeconds": 20
}
}],
"graph": {
"children": [],
"name": "classifier",
"type": "MODEL"
},
"name": "test",
"replicas": 1,
"annotations": {
"predictor_version" : "v1"
}
}
]
}
}
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
name: seldon-model
spec:
annotations:
seldon.io/rest-timeout: "5000"
seldon.io/grpc-timeout: "5000"
predictors:
- componentSpecs:
- spec:
containers:
- image: seldonio/mock_classifier:1.6.0-dev
name: classifier
graph:
children: []
name: classifier
type: MODEL
parameters:
- name: delaySecs
type: INT
value: "2"
name: example
replicas: 1
78 changes: 24 additions & 54 deletions notebooks/resources/model_short_timeouts.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,24 @@
{
"apiVersion": "machinelearning.seldon.io/v1alpha2",
"kind": "SeldonDeployment",
"metadata": {
"labels": {
"app": "seldon"
},
"name": "seldon-deployment-example"
},
"spec": {
"annotations": {
"project_name": "FX Market Prediction",
"deployment_version": "v1",
"seldon.io/rest-read-timeout": "1"
},
"name": "test-deployment",
"predictors": [
{
"componentSpecs": [
{
"spec": {
"containers": [
{
"image": "seldonio/mock_classifier:1.0",
"imagePullPolicy": "IfNotPresent",
"name": "classifier",
"resources": {
"requests": {
"memory": "1Mi"
}
}
}
],
"terminationGracePeriodSeconds": 20
}
}
],
"graph": {
"children": [],
"name": "classifier",
"endpoint": {
"type": "REST"
},
"type": "MODEL"
},
"name": "fx-market-predictor",
"replicas": 1,
"annotations": {
"predictor_version": "v1"
}
}
]
}
}
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
name: seldon-model
spec:
annotations:
seldon.io/rest-timeout: "1000"
seldon.io/grpc-timeout: "1000"
predictors:
- componentSpecs:
- spec:
containers:
- image: seldonio/mock_classifier:1.6.0-dev
name: classifier
graph:
children: []
name: classifier
type: MODEL
parameters:
- name: delaySecs
type: INT
value: "2"
name: example
replicas: 1
Loading