Skip to content

Commit

Permalink
Merge branch 'master' into release-0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gsunner committed Jun 27, 2018
2 parents ec3ce7e + 957fcda commit cf0cb67
Show file tree
Hide file tree
Showing 70 changed files with 396 additions and 12,237 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Change Log

## [v0.1.7](https://github.com/SeldonIO/seldon-core/tree/v0.1.7) (2018-06-04)
[Full Changelog](https://github.com/SeldonIO/seldon-core/compare/v0.1.6...v0.1.7)

**Closed issues:**

- Quickstart problem [\#153](https://github.com/SeldonIO/seldon-core/issues/153)
- NameError: global name 'ListValue' is not defined [\#148](https://github.com/SeldonIO/seldon-core/issues/148)
- bad credentials error with get\_token function [\#144](https://github.com/SeldonIO/seldon-core/issues/144)
- Make CRD Namespaced scoped [\#141](https://github.com/SeldonIO/seldon-core/issues/141)
- Create wrappers for Java based models [\#137](https://github.com/SeldonIO/seldon-core/issues/137)
- Update ksonnet prototypes for latest image version [\#130](https://github.com/SeldonIO/seldon-core/issues/130)
- Create demo notebook for Azure [\#129](https://github.com/SeldonIO/seldon-core/issues/129)
- Grafana Dashboard [\#109](https://github.com/SeldonIO/seldon-core/issues/109)
- Multiple helm seldon-core installs on separate namespaces fails [\#106](https://github.com/SeldonIO/seldon-core/issues/106)

**Merged pull requests:**

- Add install guide [\#156](https://github.com/SeldonIO/seldon-core/pull/156) ([cliveseldon](https://github.com/cliveseldon))
- WIP : PySpark and PMML example [\#155](https://github.com/SeldonIO/seldon-core/pull/155) ([cliveseldon](https://github.com/cliveseldon))
- Fix gRPC tests for wrappers and update sklearn iris example to show use [\#150](https://github.com/SeldonIO/seldon-core/pull/150) ([cliveseldon](https://github.com/cliveseldon))
- Minikube RBAC updates and Notebooks for Model examples [\#147](https://github.com/SeldonIO/seldon-core/pull/147) ([cliveseldon](https://github.com/cliveseldon))
- change ClusterRoleBinding to RoleBinding [\#146](https://github.com/SeldonIO/seldon-core/pull/146) ([gsunner](https://github.com/gsunner))
- MNIST loadtest [\#143](https://github.com/SeldonIO/seldon-core/pull/143) ([cliveseldon](https://github.com/cliveseldon))
- Openshift article on using s2i in seldon-core [\#140](https://github.com/SeldonIO/seldon-core/pull/140) ([cliveseldon](https://github.com/cliveseldon))
- Java wrappers [\#138](https://github.com/SeldonIO/seldon-core/pull/138) ([cliveseldon](https://github.com/cliveseldon))
- add notebook for azure demo [\#135](https://github.com/SeldonIO/seldon-core/pull/135) ([gsunner](https://github.com/gsunner))
- update ksonnet defaults to 0.1.6 [\#131](https://github.com/SeldonIO/seldon-core/pull/131) ([cliveseldon](https://github.com/cliveseldon))
- Typos fix [\#128](https://github.com/SeldonIO/seldon-core/pull/128) ([LevineHuang](https://github.com/LevineHuang))

## [v0.1.6](https://github.com/SeldonIO/seldon-core/tree/v0.1.6) (2018-03-29)
[Full Changelog](https://github.com/SeldonIO/seldon-core/compare/v0.1.5...v0.1.6)

Expand Down
2 changes: 1 addition & 1 deletion api-frontend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>io.seldon.apife</groupId>
<artifactId>seldon-apife</artifactId>
<version>0.1.7</version>
<version>0.1.8</version>
<packaging>jar</packaging>

<name>api-frontend</name>
Expand Down
2 changes: 1 addition & 1 deletion cluster-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.seldon.clustermanager</groupId>
<artifactId>seldon-cluster-manager</artifactId>
<packaging>jar</packaging>
<version>0.1.7</version>
<version>0.1.8</version>
<name>seldon-cluster-manager</name>
<url>http://maven.apache.org</url>

Expand Down
5 changes: 3 additions & 2 deletions core-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ RUN \

# dependencies for release script
RUN \
# install env for python3
apt-get update -y && \
apt-get install -y python-pip && \
pip install pyyaml && \
apt-get install -y python3-pip && \
pip3 install pyyaml && \
apt-get remove -y --auto-remove && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /work
Expand Down
2 changes: 1 addition & 1 deletion core-builder/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DOCKER_IMAGE_NAME=seldonio/core-builder
DOCKER_IMAGE_VERSION=0.2
DOCKER_IMAGE_VERSION=0.3

build_docker_image:
docker build --force-rm=true -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) .
Expand Down
8 changes: 0 additions & 8 deletions docs/getting_started/minikube.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,4 @@ The response contains:
* "names": The names of your classes.
* "ndarray": The predicted probabilities for each class.
## Next Steps
* You can run several notebooks that show various examples on minikube and Google cloud platform
* [Jupyter Notebook showing deployment of prebuilt model using Minikube](https://github.com/SeldonIO/seldon-core/blob/master/notebooks/kubectl_demo_minikube.ipynb)
* [Jupyter Notebook showing deployment of prebuilt model using GCP cluster](https://github.com/SeldonIO/seldon-core/blob/master/notebooks/kubectl_demo_gcp.ipynb)
* [Epsilon-greedy multi-armed bandits for real time optimization of models](https://github.com/SeldonIO/seldon-core/blob/master/notebooks/epsilon_greedy_gcp.ipynb)
* [Advanced graphs showing the various types of runtime prediction graphs that can be built](https://github.com/cliveseldon/seldon-core/blob/master/notebooks/advanced_graphs.ipynb)
* [Jupyter notebook to create seldon-core with ksonnet and expose APIs using Ambassador.](https://github.com/SeldonIO/seldon-core/blob/master/notebooks/ksonnet_ambassador_minikube.ipynb)
5 changes: 0 additions & 5 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Seldon Documentation

## Quick Start

- [Quick Start using Minikube](./getting_started/minikube.md)
- [Jupyter Notebook showing deployment of prebuilt model](https://github.com/SeldonIO/seldon-core/blob/master/notebooks/kubectl_demo_minikube.ipynb)

## Deployment Guide

![API](./deploy.png)
Expand Down
2 changes: 1 addition & 1 deletion docs/wrappers/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Create a Spring Boot Maven project and include the dependency:
<dependency>
<groupId>io.seldon.wrapper</groupId>
<artifactId>seldon-core-wrapper</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
</dependency>
```

Expand Down
8 changes: 4 additions & 4 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>io.seldon.engine</groupId>
<artifactId>seldon-engine</artifactId>
<version>0.1.7</version>
<version>0.1.8</version>
<packaging>jar</packaging>

<name>engine</name>
Expand Down Expand Up @@ -76,9 +76,9 @@
<dependencies>
<!-- https://mvnrepository.com/artifact/org.nd4j/nd4j-native -->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>0.9.1</version>
<groupId>org.ojalgo</groupId>
<artifactId>ojalgo</artifactId>
<version>45.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
import java.util.Iterator;
import java.util.List;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
import org.ojalgo.matrix.BasicMatrix;
import org.ojalgo.matrix.PrimitiveMatrix;
import org.springframework.stereotype.Component;

import io.seldon.engine.exception.APIException;
import io.seldon.protos.PredictionProtos.DefaultData;
import io.seldon.protos.PredictionProtos.SeldonMessage;

import io.seldon.engine.predictors.PredictorUtils;

@Component
public class AverageCombinerUnit extends PredictiveUnitImpl {

Expand All @@ -49,8 +47,8 @@ public SeldonMessage aggregate(List<SeldonMessage> outputs, PredictiveUnitState
if (shape.length!=2){
throw new APIException(APIException.ApiExceptionType.ENGINE_INVALID_COMBINER_RESPONSE, String.format("Combiner received data that is not 2 dimensional"));
}

INDArray currentSum = Nd4j.zeros(shape[0],shape[1]);
BasicMatrix.Factory<PrimitiveMatrix> matrixFactory = PrimitiveMatrix.FACTORY;
PrimitiveMatrix currentSum = matrixFactory.makeZero(shape[0], shape[1]);
SeldonMessage.Builder respBuilder = SeldonMessage.newBuilder();

for (Iterator<SeldonMessage> i = outputs.iterator(); i.hasNext();)
Expand All @@ -69,10 +67,10 @@ public SeldonMessage aggregate(List<SeldonMessage> outputs, PredictiveUnitState
if (inputShape[1] != shape[1]){
throw new APIException(APIException.ApiExceptionType.ENGINE_INVALID_COMBINER_RESPONSE, String.format("Expected batch length %d but found %d",shape[1],inputShape[1]));
}
INDArray inputArr = PredictorUtils.getINDArray(inputData);
PrimitiveMatrix inputArr = PredictorUtils.getOJMatrix(inputData);
currentSum = currentSum.add(inputArr);
}
currentSum = currentSum.div((float)outputs.size());
currentSum = currentSum.divide((float)outputs.size());

DefaultData newData = PredictorUtils.updateData(outputs.get(0).getData(), currentSum);
respBuilder.setData(newData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.ojalgo.matrix.PrimitiveMatrix;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
Expand All @@ -37,8 +37,8 @@
import io.seldon.engine.service.InternalPredictionService;
import io.seldon.protos.DeploymentProtos.PredictiveUnit.PredictiveUnitMethod;
import io.seldon.protos.PredictionProtos.Feedback;
import io.seldon.protos.PredictionProtos.SeldonMessage;
import io.seldon.protos.PredictionProtos.Meta;
import io.seldon.protos.PredictionProtos.SeldonMessage;

@Component
public class PredictiveUnitBean extends PredictiveUnitImpl {
Expand Down Expand Up @@ -227,8 +227,8 @@ public void doSendFeedback(Feedback feedback, PredictiveUnitState state) throws
private int getBranchIndex(SeldonMessage routerReturn, PredictiveUnitState state){
int branchIndex = 0;
try {
INDArray dataArray = PredictorUtils.getINDArray(routerReturn.getData());
branchIndex = (int) dataArray.getInt(0);
PrimitiveMatrix dataArray = PredictorUtils.getOJMatrix(routerReturn.getData());
branchIndex = dataArray.get(0).intValue();
}
catch (IndexOutOfBoundsException e) {
throw new APIException(APIException.ApiExceptionType.ENGINE_INVALID_ROUTING,"Router that caused the exception: id="+state.name+" name="+state.name);
Expand Down
112 changes: 38 additions & 74 deletions engine/src/main/java/io/seldon/engine/predictors/PredictorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,22 @@
*******************************************************************************/
package io.seldon.engine.predictors;

import io.seldon.protos.PredictionProtos.Tensor;
import io.seldon.protos.PredictionProtos.DefaultData.DataOneofCase;
import io.seldon.protos.PredictionProtos.DefaultData;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
import org.ojalgo.matrix.BasicMatrix;
import org.ojalgo.matrix.PrimitiveMatrix;

import com.google.protobuf.ListValue;
import com.google.protobuf.Value;

import io.seldon.protos.PredictionProtos.DefaultData;
import io.seldon.protos.PredictionProtos.DefaultData.DataOneofCase;
import io.seldon.protos.PredictionProtos.Tensor;

public class PredictorUtils {

public static DefaultData tensorToNDArray(DefaultData data){
if (data.getDataOneofCase() == DataOneofCase.TENSOR)
{
List<Double> valuesList = data.getTensor().getValuesList();
List<Integer> shapeList = data.getTensor().getShapeList();

DefaultData.Builder dataBuilder = DefaultData.newBuilder();

int index=0;
for (Iterator<String> i = data.getNamesList().iterator(); i.hasNext();){
dataBuilder.setNames(index, i.next());
index++;
}

ListValue.Builder b1 = ListValue.newBuilder();
for (int i = 0; i < shapeList.get(0); ++i) {
ListValue.Builder b2 = ListValue.newBuilder();
for (int j = 0; j < shapeList.get(1); j++){
b2.addValues(Value.newBuilder().setNumberValue(valuesList.get(i*shapeList.get(1))+j));
}
b1.addValues(Value.newBuilder().setListValue(b2.build()));
}
dataBuilder.setNdarray(b1.build());

return dataBuilder.build();

}
else if (data.getDataOneofCase() == DataOneofCase.NDARRAY)
{
return data;
}
return null;
}


public static DefaultData nDArrayToTensor(DefaultData data){
if (data.getDataOneofCase() == DataOneofCase.TENSOR)
Expand Down Expand Up @@ -98,49 +64,45 @@ else if (data.getDataOneofCase() == DataOneofCase.NDARRAY)
}
return null;
}
public static INDArray getINDArray(DefaultData data){


public static PrimitiveMatrix getOJMatrix(DefaultData data){
BasicMatrix.Factory<PrimitiveMatrix> matrixFactory = PrimitiveMatrix.FACTORY;
if (data.getDataOneofCase() == DataOneofCase.TENSOR)
{

List<Double> valuesList = data.getTensor().getValuesList();
List<Integer> shapeList = data.getTensor().getShapeList();

double[] values = new double[valuesList.size()];
int[] shape = new int[shapeList.size()];
for (int i = 0; i < values.length; i++) {
values[i] = valuesList.get(i);
}
for (int i = 0; i < shape.length; i++) {
shape[i] = shapeList.get(i);
int rows = shapeList.get(0);
int columns = shapeList.get(1);

double[][] values = new double[rows][columns];
for (int i = 0; i < rows*columns; i++) {
values[i/columns][i%columns] = valuesList.get(i);
}

INDArray newArr = Nd4j.create(values,shape,'c');

return newArr;
return matrixFactory.rows(values);
}
else if (data.getDataOneofCase() == DataOneofCase.NDARRAY)
{
ListValue list = data.getNdarray();
int bLength = list.getValuesCount();
int vLength = list.getValues(0).getListValue().getValuesCount();

double[] values = new double[bLength*vLength];
int[] shape = {bLength,vLength};
int rows = list.getValuesCount();
int cols = list.getValues(0).getListValue().getValuesCount();

for (int i = 0; i < bLength; ++i) {
for (int j = 0; j < vLength; j++){
values[i*bLength+j] = list.getValues(i).getListValue().getValues(j).getNumberValue();
double[][] values = new double[rows][cols];
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; j++){
values[i][j] = list.getValues(i).getListValue().getValues(j).getNumberValue();
}
}

INDArray newArr = Nd4j.create(values,shape,'c');

return newArr;
return matrixFactory.rows(values);
}
return null;
}




public static int[] getShape(DefaultData data){
if (data.getDataOneofCase() == DataOneofCase.TENSOR){
Expand All @@ -162,7 +124,7 @@ else if(data.getDataOneofCase() == DataOneofCase.NDARRAY){
return null;
}

public static DefaultData updateData(DefaultData oldData, INDArray newData){
public static DefaultData updateData(DefaultData oldData, PrimitiveMatrix newData){
DefaultData.Builder dataBuilder = DefaultData.newBuilder();

dataBuilder.addAllNames(oldData.getNamesList());
Expand All @@ -175,23 +137,24 @@ public static DefaultData updateData(DefaultData oldData, INDArray newData){

if (oldData.getDataOneofCase() == DataOneofCase.TENSOR){
Tensor.Builder tBuilder = Tensor.newBuilder();
List<Integer> shapeList = Arrays.stream(newData.shape()).boxed().collect(Collectors.toList());
tBuilder.addAllShape(shapeList);

tBuilder.addShape((int)newData.countRows());
tBuilder.addShape((int)newData.countColumns());

for (int i=0; i<shapeList.get(0); ++i){
for (int j=0; j<shapeList.get(1); ++j){
tBuilder.addValues(newData.getDouble(i,j));
for (int i=0; i<newData.countRows(); ++i){
for (int j=0; j<newData.countColumns(); ++j){
tBuilder.addValues(newData.get(i,j));
}
}
dataBuilder.setTensor(tBuilder);
return dataBuilder.build();
}
else if (oldData.getDataOneofCase() == DataOneofCase.NDARRAY){
ListValue.Builder b1 = ListValue.newBuilder();
for (int i = 0; i < newData.shape()[0]; ++i) {
for (int i = 0; i < newData.countRows(); ++i) {
ListValue.Builder b2 = ListValue.newBuilder();
for (int j = 0; j < newData.shape()[1]; j++){
b2.addValues(Value.newBuilder().setNumberValue(newData.getDouble(i,j)));
for (int j = 0; j < newData.countColumns(); j++){
b2.addValues(Value.newBuilder().setNumberValue(newData.get(i,j)));
}
b1.addValues(Value.newBuilder().setListValue(b2.build()));
}
Expand All @@ -202,5 +165,6 @@ else if (oldData.getDataOneofCase() == DataOneofCase.NDARRAY){

}


}

Loading

0 comments on commit cf0cb67

Please sign in to comment.