Skip to content

Commit

Permalink
Merge pull request #201 from cliveseldon/python_wrappers_versioning
Browse files Browse the repository at this point in the history
Change wrappers to be versioned and update examples and docs
  • Loading branch information
ukclivecox authored Aug 7, 2018
2 parents c1f7262 + 965344c commit dd0ff81
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 53 deletions.
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ examples/models/h2o_mojo/src/main/resources/model.zip
examples/models/deep_mnist/MNIST_data/
examples/models/deep_mnist/model/
examples/models/sklearn_iris/IrisClassifier.sav
examples/istio/canary_update/MNIST_data/
examples/istio/canary_update/tmp/
examples/models/keras_mnist/MnistClassifier.h5
examples/models/keras_mnist/data/
examples/models/keras_mnist/tensorboardlogs_test/
examples/models/r_iris/model.Rds
examples/models/r_mnist/model.Rds
examples/models/r_mnist/t10k-images-idx3-ubyte
examples/models/r_mnist/t10k-labels-idx1-ubyte
examples/models/r_mnist/train-images-idx3-ubyte
examples/models/r_mnist/train-labels-idx1-ubyte
examples/models/sk_mnist/MNIST_data/
examples/models/sk_mnist/sk.pkl

# api tester created proto folder
util/api_tester/proto/
util/api_tester/proto/
12 changes: 6 additions & 6 deletions docs/wrappers/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you are not familar with s2i you can read [general instructions on using s2i]
To check everything is working you can run

```bash
s2i usage seldonio/seldon-core-s2i-java-build
s2i usage seldonio/seldon-core-s2i-java-build:0.1
```

# Step 2 - Create your source code
Expand Down Expand Up @@ -149,14 +149,14 @@ Use ```s2i build``` to create your Docker image from source code. You will need
Using s2i you can build directly from a git repo or from a local source folder. See the [s2i docs](https://github.com/openshift/source-to-image/blob/master/docs/cli.md#s2i-build) for further details. The general format is:

```bash
s2i build <git-repo> seldonio/seldon-core-s2i-java-build <my-image-name> --runtime-image seldonio/seldon-core-s2i-java-runtime
s2i build <src-folder> seldonio/seldon-core-s2i-java-build <my-image-name> --runtime-image seldonio/seldon-core-s2i-java-runtime
s2i build <git-repo> seldonio/seldon-core-s2i-java-build:0.1 <my-image-name> --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1
s2i build <src-folder> seldonio/seldon-core-s2i-java-build:0.1 <my-image-name> --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1
```

An example invocation using the test template model inside seldon-core:

```bash
s2i build https://github.com/seldonio/seldon-core.git --context-dir=wrappers/s2i/python/test/model-template-app seldonio/seldon-core-s2i-java-build h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime
s2i build https://github.com/seldonio/seldon-core.git --context-dir=wrappers/s2i/python/test/model-template-app seldonio/seldon-core-s2i-java-build:0.1 h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1
```

The above s2i build invocation:
Expand All @@ -172,13 +172,13 @@ For building from a local source folder, an example where we clone the seldon-co
```bash
git clone https://github.com/seldonio/seldon-core.git
cd seldon-core
s2i build wrappers/s2i/R/test/model-template-app seldonio/seldon-core-s2i-java-build h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime
s2i build wrappers/s2i/R/test/model-template-app seldonio/seldon-core-s2i-java-build:0.1 h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1
```

For more help see:

```
s2i usage seldonio/seldon-core-s2i-java-build
s2i usage seldonio/seldon-core-s2i-java-build:0.1
s2i build --help
```

Expand Down
6 changes: 5 additions & 1 deletion docs/wrappers/python-docker.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Packaging a python model for Seldon Core using Seldon Wrapper
In this guide, we illustrate the steps needed to wrap your own python model in a docker image ready for deployment with Seldon Core, using the Seldon wrapper script. This script is designed to take your python model and turn it into a dockerised microservice that conforms to Seldon's internal API, thus avoiding the hassle to write your own dockerised microservice.
In this guide, we illustrate the steps needed to wrap your own python model in a docker image ready for deployment with Seldon Core, using the Seldon wrapper script.

We suggest you look at using the [S2I tool for python models](python.md) before choosing this method.

This script is designed to take your python model and turn it into a dockerised microservice that conforms to Seldon's internal API, thus avoiding the hassle to write your own dockerised microservice.

You can use these wrappers with any model that offers a python API. Some examples are:

Expand Down
18 changes: 9 additions & 9 deletions docs/wrappers/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you are not familar with s2i you can read [general instructions on using s2i]
To check everything is working you can run

```bash
s2i usage seldonio/seldon-core-s2i-python3
s2i usage seldonio/seldon-core-s2i-python3:0.1
```


Expand Down Expand Up @@ -83,22 +83,22 @@ These values can also be provided or overriden on the command line when building
# Step 3 - Build your image
Use ```s2i build``` to create your Docker image from source code. You will need Docker installed on the machine and optionally git if your source code is in a public git repo. You can choose from two python builder images

* Python 2 : seldonio/seldon-core-s2i-python2
* Python 3 : seldonio/seldon-core-s2i-python3
* Python 2 : seldonio/seldon-core-s2i-python2:0.1
* Python 3 : seldonio/seldon-core-s2i-python3:0.1

Using s2i you can build directly from a git repo or from a local source folder. See the [s2i docs](https://github.com/openshift/source-to-image/blob/master/docs/cli.md#s2i-build) for further details. The general format is:

```bash
s2i build <git-repo> seldonio/seldon-core-s2i-python2 <my-image-name>
s2i build <src-folder> seldonio/seldon-core-s2i-python2 <my-image-name>
s2i build <git-repo> seldonio/seldon-core-s2i-python2:0.1 <my-image-name>
s2i build <src-folder> seldonio/seldon-core-s2i-python2:0.1 <my-image-name>
```

Change to seldonio/seldon-core-s2i-python3 if using python 3.

An example invocation using the test template model inside seldon-core:

```bash
s2i build https://github.com/seldonio/seldon-core.git --context-dir=wrappers/s2i/python/test/model-template-app seldonio/seldon-core-s2i-python2 seldon-core-template-model
s2i build https://github.com/seldonio/seldon-core.git --context-dir=wrappers/s2i/python/test/model-template-app seldonio/seldon-core-s2i-python2:0.1 seldon-core-template-model
```

The above s2i build invocation:
Expand All @@ -113,14 +113,14 @@ For building from a local source folder, an example where we clone the seldon-co
```bash
git clone https://github.com/seldonio/seldon-core.git
cd seldon-core
s2i build wrappers/s2i/python/test/model-template-app seldonio/seldon-core-s2i-python2 seldon-core-template-model
s2i build wrappers/s2i/python/test/model-template-app seldonio/seldon-core-s2i-python2:0.1 seldon-core-template-model
```

For more help see:

```
s2i usage seldonio/seldon-core-s2i-python2
s2i usage seldonio/seldon-core-s2i-python3
s2i usage seldonio/seldon-core-s2i-python2:0.1
s2i usage seldonio/seldon-core-s2i-python3:0.1
s2i build --help
```

Expand Down
12 changes: 6 additions & 6 deletions docs/wrappers/r.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you are not familar with s2i you can read [general instructions on using s2i]
To check everything is working you can run

```bash
s2i usage seldonio/seldon-core-s2i-r
s2i usage seldonio/seldon-core-s2i-r:0.1
```

# Step 2 - Create your source code
Expand Down Expand Up @@ -84,14 +84,14 @@ Use ```s2i build``` to create your Docker image from source code. You will need
Using s2i you can build directly from a git repo or from a local source folder. See the [s2i docs](https://github.com/openshift/source-to-image/blob/master/docs/cli.md#s2i-build) for further details. The general format is:

```bash
s2i build <git-repo> seldonio/seldon-core-s2i-r <my-image-name>
s2i build <src-folder> seldonio/seldon-core-s2i-r <my-image-name>
s2i build <git-repo> seldonio/seldon-core-s2i-r:0.1 <my-image-name>
s2i build <src-folder> seldonio/seldon-core-s2i-r:0.1 <my-image-name>
```

An example invocation using the test template model inside seldon-core:

```bash
s2i build https://github.com/seldonio/seldon-core.git --context-dir=wrappers/s2i/R/test/model-template-app seldonio/seldon-core-s2i-r seldon-core-template-model
s2i build https://github.com/seldonio/seldon-core.git --context-dir=wrappers/s2i/R/test/model-template-app seldonio/seldon-core-s2i-r:0.1 seldon-core-template-model
```

The above s2i build invocation:
Expand All @@ -106,13 +106,13 @@ For building from a local source folder, an example where we clone the seldon-co
```bash
git clone https://github.com/seldonio/seldon-core.git
cd seldon-core
s2i build wrappers/s2i/R/test/model-template-app seldonio/seldon-core-s2i-r seldon-core-template-model
s2i build wrappers/s2i/R/test/model-template-app seldonio/seldon-core-s2i-r:0.1 seldon-core-template-model
```

For more help see:

```
s2i usage seldonio/seldon-core-s2i-r
s2i usage seldonio/seldon-core-s2i-r:0.1
s2i build --help
```

Expand Down
4 changes: 2 additions & 2 deletions examples/models/deep_mnist/deep_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-python2 deep-mnist:0.1"
"!s2i build . seldonio/seldon-core-s2i-python2:0.1 deep-mnist:0.1"
]
},
{
Expand Down Expand Up @@ -172,7 +172,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python2 deep-mnist:0.1"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python2:0.1 deep-mnist:0.1"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/models/h2o_mojo/h2o_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-java-build h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime"
"!s2i build . seldonio/seldon-core-s2i-java-build:0.1 h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1"
]
},
{
Expand Down Expand Up @@ -166,7 +166,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-java-build h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-java-build:0.1 h2o-test:0.1 --runtime-image seldonio/seldon-core-s2i-java-runtime:0.1"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions examples/models/keras_mnist/MnistClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class MnistClassifier(object):

def __init__(self):
self.model = load_model('MnistClassifier.h5')
self.model._make_predict_function()

def predict(self,X,features_names):
return self.model.predict(X)
4 changes: 2 additions & 2 deletions examples/models/keras_mnist/keras_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-python3 keras-mnist:0.1"
"!s2i build . seldonio/seldon-core-s2i-python3:0.1 keras-mnist:0.1"
]
},
{
Expand Down Expand Up @@ -340,7 +340,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python3 keras-mnist:0.1"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python3:0.1 keras-mnist:0.1"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/models/r_iris/r_iris.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-r r-iris:0.1"
"!s2i build . seldonio/seldon-core-s2i-r:0.1 r-iris:0.1"
]
},
{
Expand Down Expand Up @@ -137,7 +137,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-r r-iris:0.1"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-r:0.1 r-iris:0.1"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/models/r_mnist/r_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-r r-mnist:0.1"
"!s2i build . seldonio/seldon-core-s2i-r:0.1 r-mnist:0.1"
]
},
{
Expand Down Expand Up @@ -137,7 +137,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-r r-mnist:0.1"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-r:0.1 r-mnist:0.1"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/models/sk_mnist/skmnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-python3 sk-mnist:0.1"
"!s2i build . seldonio/seldon-core-s2i-python3:0.1 sk-mnist:0.1"
]
},
{
Expand Down Expand Up @@ -172,7 +172,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python3 sk-mnist:0.1"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python3:0.1 sk-mnist:0.1"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/models/sklearn_iris/sklearn_iris.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build . seldonio/seldon-core-s2i-python3 sklearn-iris:0.1"
"!s2i build . seldonio/seldon-core-s2i-python3:0.1 sklearn-iris:0.1"
]
},
{
Expand Down Expand Up @@ -137,7 +137,7 @@
"metadata": {},
"outputs": [],
"source": [
"!s2i build -E .s2i/environment_grpc . seldonio/seldon-core-s2i-python3 sklearn-iris:0.1"
"!s2i build -E .s2i/environment_grpc . seldonio/seldon-core-s2i-python3:0.1 sklearn-iris:0.1"
]
},
{
Expand Down Expand Up @@ -240,7 +240,7 @@
"metadata": {},
"outputs": [],
"source": [
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python3 sklearn-iris:0.1"
"!eval $(minikube docker-env) && s2i build . seldonio/seldon-core-s2i-python3:0.1 sklearn-iris:0.1"
]
},
{
Expand Down
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
| Branch | Status |
|-------------|-------|
| master | [![Build Status](https://travis-ci.org/SeldonIO/seldon-core.svg?branch=master)](https://travis-ci.org/SeldonIO/seldon-core) |
| release-0.2 | [![Build Status](https://travis-ci.org/SeldonIO/seldon-core.svg?branch=release-0.2)](https://travis-ci.org/SeldonIO/seldon-core) |
| release-0.1 | [![Build Status](https://travis-ci.org/SeldonIO/seldon-core.svg?branch=release-0.1)](https://travis-ci.org/SeldonIO/seldon-core) |


Seldon Core is an open source platform for deploying machine learning models on Kubernetes.

- [Goals](#goals)
Expand Down Expand Up @@ -148,3 +150,17 @@ Three steps:

- [CHANGELOG](CHANGELOG.md)
- [Developer Guide](./docs/developer/readme.md)

## Latest Seldon Images

|Description | Image URL | Version |
|------------|-----------|---------|
| Seldon Operator | [seldonio/cluster-manager](https://hub.docker.com/r/seldonio/cluster-manager/tags/) | 0.2.2 |
| Seldon Service Orchestrator | [seldonio/engine](https://hub.docker.com/r/seldonio/engine/tags/) | 0.2.2 |
| Seldon API Gateway | [seldonio/apife](https://hub.docker.com/r/seldonio/apife/tags/) | 0.2.2 |
| [Seldon Python 3 Wrapper for S2I](docs/wrappers/python.md) | [seldonio/seldon-core-s2i-python3](https://hub.docker.com/r/seldonio/seldon-core-s2i-python3/tags/) | 0.1 |
| [Seldon Python 2 Wrapper for S2I](docs/wrappers/python.md) | [seldonio/seldon-core-s2i-python2](https://hub.docker.com/r/seldonio/seldon-core-s2i-python2/tags/) | 0.1 |
| [Seldon Core Python Wrapper](docs/wrappers/python-docker.md) | [seldonio/core-python-wrapper](https://hub.docker.com/r/seldonio/core-python-wrapper/tags/) | 0.7 |
| [Seldon Java Build Wrapper for S2I](docs/wrappers/java.md) | [seldonio/seldon-core-s2i-java-build](https://hub.docker.com/r/seldonio/seldon-core-s2i-java-build/tags/) | 0.1 |
| [Seldon Java Runtime Wrapper for S2I](docs/wrappers/java.md) | [seldonio/seldon-core-s2i-java-runtime](https://hub.docker.com/r/seldonio/seldon-core-s2i-java-runtime/tags/) | 0.1 |
| [Seldon R Wrapper for S2I](docs/wrappers/r.md) | [seldonio/seldon-core-s2i-r](https://hub.docker.com/r/seldonio/seldon-core-s2i-r) | 0.1 |
2 changes: 1 addition & 1 deletion util/api_tester/api-tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def generate_batch(contract,n):
batch = gen_continuous(range,shape)
batch = reconciliate_cont_type(batch,feature_def["dtype"])
elif feature_def["ftype"] == "categorical":
batch = gen_categorical(feature_def["values"],n)
batch = gen_categorical(feature_def["values"],[n,1])
feature_batches.append(batch)
return np.concatenate(feature_batches,axis=1)

Expand Down
8 changes: 4 additions & 4 deletions wrappers/python/seldon_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy==1.11.2
pandas==0.18.1
grpcio==1.1.3
Flask==0.11.1
numpy==1.14.5
pandas==0.23.4
grpcio==1.14.0
Flask==1.0.2
futures
redis==2.10.5
5 changes: 3 additions & 2 deletions wrappers/s2i/R/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
IMAGE_NAME = docker.io/seldonio/seldon-core-s2i-r
VERSION=0.1
IMAGE_NAME = docker.io/seldonio/seldon-core-s2i-r:${VERSION}

SELDON_CORE_DIR=../../..

Expand All @@ -8,7 +9,7 @@ build:
docker build -t $(IMAGE_NAME) .

push_to_dockerhub:
docker push $(IMAGE_NAME):latest
docker push $(IMAGE_NAME)


.PHONY: test
Expand Down
Loading

0 comments on commit dd0ff81

Please sign in to comment.