Skip to content

Commit

Permalink
Merge pull request #689 from cliveseldon/standalone_servers
Browse files Browse the repository at this point in the history
Model servers
  • Loading branch information
ukclivecox authored Jul 15, 2019
2 parents 32de461 + 35eb69b commit 6a66d7b
Show file tree
Hide file tree
Showing 43 changed files with 3,205 additions and 100 deletions.
1 change: 1 addition & 0 deletions doc/source/examples/notebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Notebooks
SKLearn Iris Classifier <iris>
SKLearn MNIST <sklearn_mnist>
SKLearn SpaCy Reddit Text Classifier Example <sklearn_spacy_text_classifier_example>
Sklearn, Xgboost, Tensorflow Server Examples <server_examples>
Tensorflow MNIST <deep_mnist>
TFserving MNIST <tfserving_mnist>

3 changes: 3 additions & 0 deletions doc/source/examples/server_examples.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../notebooks/server_examples.ipynb"
}
9 changes: 9 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ Seldon Core is an open source platform for deploying machine learning models on
Usage reporting <workflow/usage-reporting.md>
Upgrading <reference/upgrading.md>

.. toctree::
:maxdepth: 1
:caption: Servers

Inference Servers Overview <servers/overview.md>
SKLearn server <servers/sklearn.md>
XGBoost server <servers/xgboost.md>
Tensorflow Serving <servers/tensorflow.md>

.. toctree::
:maxdepth: 1
:caption: Wrappers
Expand Down
8 changes: 8 additions & 0 deletions doc/source/python/api/seldon_core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ seldon\_core.seldon\_methods module
:undoc-members:
:show-inheritance:

seldon\_core.storage module
---------------------------

.. automodule:: seldon_core.storage
:members:
:undoc-members:
:show-inheritance:

seldon\_core.user\_model module
-------------------------------

Expand Down
68 changes: 68 additions & 0 deletions doc/source/servers/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Prepackaged Model Servers

Seldon provides several prepacked servers you can use to deploy trained models:

* [SKLearn Server](./sklearn.html)
* [XGBoost Server](xgboost.html)
* [Tensorflow Serving](tensorflow.html)


For these servers you only need the location of the saved model in a local filestore, Google bucket or S3 bucket. An example manifest with an sklearn server is shown below:

```
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: sklearn
spec:
name: iris
predictors:
- graph:
children: []
implementation: SKLEARN_SERVER
modelUri: gs://seldon-models/sklearn/iris
name: classifier
name: default
replicas: 1
```

The `modelUri` specifies the bucket containing the saved model, in this case `gs://seldon-models/sklearn/iris`.

If you want to customize the resources for the server you can add a skeleton `Container` with the same name to your podSpecs, e.g.

```
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: sklearn
spec:
name: iris
predictors:
- componentSpecs:
- spec:
containers:
- name: classifier
resources:
requests:
memory: 50Mi
graph:
children: []
implementation: SKLEARN_SERVER
modelUri: gs://seldon-models/sklearn/iris
name: classifier
name: default
replicas: 1
```

The image name and other details will be added when this is deployed automatically.

Next steps:

* [Worked notebook](../examples/server_examples.html)
* [SKLearn Server](./sklearn.html)
* [XGBoost Server](xgboost.html)
* [Tensorflow Serving](tensorflow.html)

If your use case does not fall into the above standard servers then you can create your own component using our wrappers.

31 changes: 31 additions & 0 deletions doc/source/servers/sklearn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SKLearn Server

If you have a trained SKLearn model saved as a pickle you can deploy it simply using Seldon's prepackaged SKLearn server.

Prequisites:

* The model pickle must be saved using joblib and presently be named `model.joblib`
* We presently use sklearn version 0.20.3. Your pickled model must be compatbible with this version

An example for a saved Iris prediction model:

```
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: sklearn
spec:
name: iris
predictors:
- graph:
children: []
implementation: SKLEARN_SERVER
modelUri: gs://seldon-models/sklearn/iris
name: classifier
name: default
replicas: 1
```


Try out a [worked notebook](../examples/server_examples.html)
82 changes: 82 additions & 0 deletions doc/source/servers/tensorflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Tensorflow Serving

If you have a trained Tensorflow model you can deploy this directly via REST or gRPC servers.

## MNIST Example

### REST MNIST Example

For REST you need to specify paramaters for:

* signature_name
* model_name

```
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: tfserving
spec:
name: mnist
predictors:
- graph:
children: []
implementation: TENSORFLOW_SERVER
modelUri: gs://seldon-tfserving-store/mnist-model
name: mnist-model
parameters:
- name: signature_name
type: STRING
value: predict_images
- name: model_name
type: STRING
value: mnist-model
name: default
replicas: 1
```

### gRPC MNIST Example

For gRPC you need to specify the following parameters:

* signature_name
* model_name
* model_input
* model_output

```
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: tfserving
spec:
name: mnist
predictors:
- graph:
children: []
implementation: TENSORFLOW_SERVER
modelUri: gs://seldon-tfserving-store/mnist-model
name: mnist-model
endpoint:
type: GRPC
parameters:
- name: signature_name
type: STRING
value: predict_images
- name: model_name
type: STRING
value: mnist-model
- name: model_input
type: STRING
value: images
- name: model_output
type: STRING
value: scores
name: default
replicas: 1
```


Try out a [worked notebook](../examples/server_examples.html)
30 changes: 30 additions & 0 deletions doc/source/servers/xgboost.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# XGBoost Server

If you have a trained XGBoost model saved you can deploy it simply using Seldon's prepackaged XGBoost server.

Prequisites:

* The model pickle must be named `model.bst`

An example for a saved Iris prediction model:

```
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
name: xgboost
spec:
name: iris
predictors:
- graph:
children: []
implementation: XGBOOST_SERVER
modelUri: gs://seldon-models/xgboost/iris
name: classifier
name: default
replicas: 1
```


Try out a [worked notebook](../examples/server_examples.html)
12 changes: 10 additions & 2 deletions doc/source/workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ You can use ```kubectl``` to deploy your ML service like any other Kubernetes re

## Next Steps

We have created a set of [notebook step-by-step tutorials](../examples/helm_examples.html) which you can follow to get started with Seldon core.
If you have a saved model for SKLearn, XGBoost or Tensorflow then you can use oneof our [prepackaged model servers](../servers/overview.html).

### Recommended starter tutorials
If you want to wrap your custom inference code then follow one of our stater tutorials below for the framework you are using.

### Prepacked Model Servers

* [SKLearn](../servers/sklearn.html)
* [XGBoost](../servers/xgboost.html)
* [Tensorflow](../servers/tensorflow.html)

### Recommended starter tutorials for custom inference code

* [Tensorflow Deep MNIST Tutorial](https://docs.seldon.io/projects/seldon-core/en/latest/examples/deep_mnist.html) (Try it also in [AWS](https://docs.seldon.io/projects/seldon-core/en/latest/examples/aws_eks_deep_mnist.html), [Azure](https://docs.seldon.io/projects/seldon-core/en/latest/examples/azure_aks_deep_mnist.html) and [GKE with GPU](https://github.com/SeldonIO/seldon-core/tree/master/examples/models/gpu_tensorflow_deep_mnist))
* [SKlearn SpaCy Reddit Text Classification Tutorial](https://docs.seldon.io/projects/seldon-core/en/latest/examples/sklearn_spacy_text_classifier_example.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public PredictorConfigBean(
}

public boolean hasMethod(PredictiveUnitState state) {
return (state.implementation == PredictiveUnitImplementation.UNKNOWN_IMPLEMENTATION);
return (state.implementation == PredictiveUnitImplementation.UNKNOWN_IMPLEMENTATION || !nodeImplementationMap.containsKey(state.implementation));
}

public PredictiveUnitImpl getImplementation(PredictiveUnitState state){
Expand All @@ -93,7 +93,8 @@ public PredictiveUnitImpl getImplementation(PredictiveUnitState state){
}

public Boolean hasMethod(PredictiveUnitMethod method, PredictiveUnitState state){
if (state.implementation != PredictiveUnitImplementation.UNKNOWN_IMPLEMENTATION){
if (state.implementation != PredictiveUnitImplementation.UNKNOWN_IMPLEMENTATION &&
nodeImplementationMap.containsKey(state.implementation)){
return false;
}
if (state.type == PredictiveUnitType.UNKNOWN_TYPE) {
Expand Down
Loading

0 comments on commit 6a66d7b

Please sign in to comment.