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

S2i examples #118

Merged
merged 8 commits into from
Mar 16, 2018
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
79 changes: 75 additions & 4 deletions examples/models/deep_mnist/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,79 @@
# Deep MNIST
A TensorFlow model for MNIST classification.

A simple tensorflow model for MNIST classification.
## Train locally

You must train the model before wrapping it as it uses a local model parameter file.
```bash
make train
```

## Wrap using [s2i](https://github.com/openshift/source-to-image#installation).

```bash
s2i build . seldonio/seldon-core-s2i-python2 deep-mnist
```
make train
```

## Local Docker Smoke Test

Run under docker.

```bash
docker run --rm -p 5000:5000 deep-mnist
```

Ensure test grpc modules compiled.

```bash
pushd ../../../wrappers/testing ; make build_protos ; popd
```

Send a data request using the wrapper tester.

```bash
python ../../../wrappers/testing/tester.py contract.json 0.0.0.0 5000 -p
```

## Minikube test

```bash
minikube start --memory 4096
```

[Install seldon core](/readme.md#install)

Connect to Minikube Docker daemon

```bash
eval $(minikube docker-env)
```

Build image using minikube docker daemon.

```bash
s2i build . seldonio/seldon-core-s2i-python2 deep-mnist
```

Launch deployment

```bash
kubectl create -f deep_mnist.json
```

Port forward API server

```bash
kubectl port-forward $(kubectl get pods -n seldon -l app=seldon-apiserver-container-app -o jsonpath='{.items[0].metadata.name}') -n seldon 8080:8080
```

Ensure tester gRPC modules compiled. You will need to install grpc-tools module.

```bash
pushd ../../../util/api_tester ; make build_protos ; popd
```

Send test request
```bash
python ../../../util/api_tester/api-tester.py contract.json 0.0.0.0 8080 --oauth-key oauth-key --oauth-secret oauth-secret -p
```


53 changes: 53 additions & 0 deletions examples/models/deep_mnist/deep_mnist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"apiVersion": "machinelearning.seldon.io/v1alpha1",
"kind": "SeldonDeployment",
"metadata": {
"labels": {
"app": "seldon"
},
"name": "deep-mnist"
},
"spec": {
"annotations": {
"project_name": "Tensorflow MNIST",
"deployment_version": "v1"
},
"name": "deep-mnist",
"oauth_key": "oauth-key",
"oauth_secret": "oauth-secret",
"predictors": [
{
"componentSpec": {
"spec": {
"containers": [
{
"image": "deep-mnist:latest",
"imagePullPolicy": "IfNotPresent",
"name": "classifier",
"resources": {
"requests": {
"memory": "1Mi"
}
}
}
],
"terminationGracePeriodSeconds": 20
}
},
"graph": {
"children": [],
"name": "classifier",
"endpoint": {
"type" : "REST"
},
"type": "MODEL"
},
"name": "single-model",
"replicas": 1,
"annotations": {
"predictor_version" : "v1"
}
}
]
}
}
86 changes: 86 additions & 0 deletions examples/models/keras_mnist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Deep MNIST
A Keras model for MNIST classification.

## Depenencies

```bash
pip install keras
pip install grpcio-tools
```

## Train locally

```bash
python train_mnist.py
```

## Wrap using [s2i](https://github.com/openshift/source-to-image#installation).

```bash
s2i build . seldonio/seldon-core-s2i-python3 keras-mnist:0.1
```

## Local Docker Smoke Test

Run under docker.

```bash
docker run --rm -p 5000:5000 keras-mnist:0.1
```

Ensure test grpc modules compiled.

```bash
pushd ../../../wrappers/testing ; make build_protos ; popd
```

Send a data request using the wrapper tester.

```bash
python ../../../wrappers/testing/tester.py contract.json 0.0.0.0 5000 -p
```

## Minikube test

```bash
minikube start --memory 4096
```

[Install seldon core](/readme.md#install)

Connect to Minikube Docker daemon

```bash
eval $(minikube docker-env)
```

Build image using minikube docker daemon.

```bash
s2i build . seldonio/seldon-core-s2i-python3 keras-mnist:0.1
```

Launch deployment

```bash
kubectl create -f keras_mnist_deployment.json
```

Port forward API server

```bash
kubectl port-forward $(kubectl get pods -n seldon -l app=seldon-apiserver-container-app -o jsonpath='{.items[0].metadata.name}') -n seldon 8080:8080
```

Ensure tester gRPC modules compiled.

```bash
pushd ../../../util/api_tester ; make build_protos ; popd
```

Send test request
```bash
python ../../../util/api_tester/api-tester.py contract.json 0.0.0.0 8080 --oauth-key oauth-key --oauth-secret oauth-secret -p
```


2 changes: 1 addition & 1 deletion examples/models/keras_mnist/keras_mnist_deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"spec": {
"containers": [
{
"image": "seldonio/mnistclassifier:0.0",
"image": "keras-mnist:0.1",
"imagePullPolicy": "IfNotPresent",
"name": "keras-mnist-classifier",
"resources": {
Expand Down
4 changes: 2 additions & 2 deletions examples/models/keras_mnist/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scikit-learn==0.17.1
scipy==0.18.1
numpy>=1.8.2
scipy>=0.13.3
keras==2.1.3
tensorflow==1.0.1
h5py
4 changes: 2 additions & 2 deletions examples/models/keras_mnist/train_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def build_graph(self):
optimizer='Adam',
metrics=['accuracy'])

print 'graph builded'
print('graph builded')

def fit(self,X,y=None,
X_test=None,y_test=None,
Expand Down Expand Up @@ -150,7 +150,7 @@ def build_graph(self):
optimizer='Adam',
metrics=['accuracy'])

print 'graph builded'
print('graph builded')

def fit(self,X,y=None,
X_test=None,y_test=None,
Expand Down
4 changes: 4 additions & 0 deletions examples/models/mean_classifier/.s2i/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODEL_NAME=MeanClassifier
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
4 changes: 4 additions & 0 deletions examples/models/sigmoid_predictor/.s2i/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODEL_NAME=SigmoidPredictor
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
4 changes: 2 additions & 2 deletions examples/models/sigmoid_predictor/contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"ftype":"continuous",
"range":[-1,1],
"repeat":10
},
}
],
"targets":[
{
"name":"proba",
"dtype":"FLOAT",
"ftype":"continuous",
"range":[0,1]
"values":[0,1]
}
]
}
86 changes: 86 additions & 0 deletions examples/models/sklearn_iris/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Deep MNIST
A scikit-learn Iris model.

## Depenencies

```bash
pip install sklearn
pip install grpcio-tools
```

## Train locally

```bash
python train_iris.py
```

## Wrap using [s2i](https://github.com/openshift/source-to-image#installation).

```bash
s2i build . seldonio/seldon-core-s2i-python3 sklearn-iris:0.1
```

## Local Docker Smoke Test

Run under docker.

```bash
docker run --rm -p 5000:5000 sklearn-iris:0.1
```

Ensure test grpc modules compiled.

```bash
pushd ../../../wrappers/testing ; make build_protos ; popd
```

Send a data request using the wrapper tester.

```bash
python ../../../wrappers/testing/tester.py contract.json 0.0.0.0 5000 -p
```

## Minikube test

```bash
minikube start --memory 4096
```

[Install seldon core](/readme.md#install)

Connect to Minikube Docker daemon

```bash
eval $(minikube docker-env)
```

Build image using minikube docker daemon.

```bash
s2i build . seldonio/seldon-core-s2i-python3 sklearn-iris:0.1
```

Launch deployment

```bash
kubectl create -f sklearn_iris_deployment.json
```

Port forward API server

```bash
kubectl port-forward $(kubectl get pods -n seldon -l app=seldon-apiserver-container-app -o jsonpath='{.items[0].metadata.name}') -n seldon 8080:8080
```

Ensure tester gRPC modules compiled.

```bash
pushd ../../../util/api_tester ; make build_protos ; popd
```

Send test request
```bash
python ../../../util/api_tester/api-tester.py contract.json 0.0.0.0 8080 --oauth-key oauth-key --oauth-secret oauth-secret -p
```


2 changes: 1 addition & 1 deletion examples/models/sklearn_iris/sklearn_iris_deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"spec": {
"containers": [
{
"image": "seldonio/irisclassifier:0.1",
"image": "sklearn-iris:0.1",
"imagePullPolicy": "IfNotPresent",
"name": "sklearn-iris-classifier",
"resources": {
Expand Down
Loading