Search in sources :

Example 1 with Endpoint

use of io.seldon.protos.DeploymentProtos.Endpoint in project seldon-core by SeldonIO.

the class InternalPredictionService method aggregate.

public SeldonMessage aggregate(List<SeldonMessage> outputs, PredictiveUnitState state) throws InvalidProtocolBufferException {
    final Endpoint endpoint = state.endpoint;
    SeldonMessageList outputsList = SeldonMessageList.newBuilder().addAllSeldonMessages(outputs).build();
    switch(endpoint.getType()) {
        case REST:
            String dataString = ProtoBufUtils.toJson(outputsList);
            return queryREST("aggregate", dataString, state, endpoint, true);
        case GRPC:
            if (state.type == PredictiveUnitType.UNKNOWN_TYPE) {
                GenericBlockingStub stub = GenericGrpc.newBlockingStub(getChannel(endpoint)).withDeadlineAfter(TIMEOUT, TimeUnit.SECONDS);
                return stub.aggregate(outputsList);
            } else {
                CombinerBlockingStub stub = CombinerGrpc.newBlockingStub(getChannel(endpoint)).withDeadlineAfter(TIMEOUT, TimeUnit.SECONDS);
                return stub.aggregate(outputsList);
            }
    }
    throw new APIException(APIException.ApiExceptionType.ENGINE_MICROSERVICE_ERROR, "no service available");
}
Also used : APIException(io.seldon.engine.exception.APIException) Endpoint(io.seldon.protos.DeploymentProtos.Endpoint) GenericBlockingStub(io.seldon.protos.GenericGrpc.GenericBlockingStub) CombinerBlockingStub(io.seldon.protos.CombinerGrpc.CombinerBlockingStub) SeldonMessageList(io.seldon.protos.PredictionProtos.SeldonMessageList)

Aggregations

APIException (io.seldon.engine.exception.APIException)1 CombinerBlockingStub (io.seldon.protos.CombinerGrpc.CombinerBlockingStub)1 Endpoint (io.seldon.protos.DeploymentProtos.Endpoint)1 GenericBlockingStub (io.seldon.protos.GenericGrpc.GenericBlockingStub)1 SeldonMessageList (io.seldon.protos.PredictionProtos.SeldonMessageList)1