From 501e955b93cff9f7bc1734901b3e578de13168a0 Mon Sep 17 00:00:00 2001 From: Aaron Pham <29749331+aarnphm@users.noreply.github.com> Date: Mon, 25 Jul 2022 17:36:02 -0700 Subject: [PATCH] fix: repeated contents field Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> --- bentoml/_internal/io_descriptors/numpy.py | 12 ++- bentoml/grpc/v1/service.proto | 106 ++-------------------- 2 files changed, 15 insertions(+), 103 deletions(-) diff --git a/bentoml/_internal/io_descriptors/numpy.py b/bentoml/_internal/io_descriptors/numpy.py index dc011c3f9d..b2cbf7f92f 100644 --- a/bentoml/_internal/io_descriptors/numpy.py +++ b/bentoml/_internal/io_descriptors/numpy.py @@ -264,12 +264,14 @@ async def from_grpc_request( a `numpy.ndarray` object. This can then be used inside users defined logics. """ - from bentoml.grpc.v1 import struct_pb2 - from ..utils.grpc import proto_to_dict - logger.info([f for f in struct_pb2.ContentsProto.DESCRIPTOR.fields]) + # from bentoml.grpc.v1 import struct_pb2 + # logger.info([f for f in struct_pb2.ContentsProto.DESCRIPTOR.fields]) + print(request.contents) contents = proto_to_dict(request.contents) + print(contents) + raise RuntimeError return np.frombuffer(contents) async def to_grpc_response( @@ -285,7 +287,9 @@ async def to_grpc_response( `io_descriptor_pb2.Array`: Protobuf representation of given `np.ndarray` """ - pass + from bentoml.grpc.v1 import service_pb2 + + return service_pb2.InferenceResponse() def generate_protobuf(self): pass diff --git a/bentoml/grpc/v1/service.proto b/bentoml/grpc/v1/service.proto index 86ffaa6ba6..be1b044f21 100644 --- a/bentoml/grpc/v1/service.proto +++ b/bentoml/grpc/v1/service.proto @@ -48,56 +48,10 @@ message ServerReadyResponse { // Request for Inference. message InferenceRequest { // a given API route the rpc request is sent to. - string api_name = 14; - string api_version = 15; + string api_name = 1; + string api_version = 2; - // representation of the input value. - oneof contents { - // Serialized bytes contents. - bytes bytes_contents = 1; - - // DT_HALF, DT_BFLOAT16 - int32 half_contents = 10; - - // DT_FLOAT. - float float_contents = 2; - - // DT_DOUBLE. - double double_contents = 3; - - // DT_INT32, DT_INT16, DT_UINT16, DT_INT8, DT_UINT8. - int32 int_contents = 4; - - // DT_STRING - bytes string_contents = 5; - - // DT_COMPLEX64. - float scomplex_contents = 6; - - // DT_INT64 - int64 int64_contents = 7; - - // DT_BOOL - bool bool_contents = 8; - - // DT_COMPLEX128 - double dcomplex_contents = 9; - - // DT_UINT32 - uint32 uint32_contents = 11; - - // DT_UINT64 - uint64 uint64_contents = 12; - - // Represents arbitrary Python data structures. - NoneValue none_contents = 50; - ListValue list_contents = 51; - TupleValue tuple_contents = 52; - DictValue dict_contents = 53; - NamedTupleValue namedtuple_contents = 54; - - google.protobuf.Any any_contents = 55; - } + repeated bentoml.grpc.v1.ContentsProto contents = 3; // The data contained in an input can be represented in // "raw" bytes form or in the repeated type that matches the @@ -119,7 +73,7 @@ message InferenceRequest { // specific data type for a 16-bit float type. // // If this field is specified then contents must not be specified for any input tensor. - repeated bytes raw_bytes_contents = 13; + repeated bytes raw_bytes_contents = 4; // dataframes_columns and dataframe_indices are used // in conjunction with contents to represent a dataframe. @@ -132,53 +86,7 @@ message InferenceRequest { // Response from Inference. message InferenceResponse { // representation of the output value. - // representation of the input value. - oneof contents { - // Serialized bytes contents. - bytes bytes_contents = 1; - - // DT_HALF, DT_BFLOAT16 - int32 half_contents = 10; - - // DT_FLOAT. - float float_contents = 2; - - // DT_DOUBLE. - double double_contents = 3; - - // DT_INT32, DT_INT16, DT_UINT16, DT_INT8, DT_UINT8. - int32 int_contents = 4; - - // DT_STRING - bytes string_contents = 5; - - // DT_COMPLEX64. - float scomplex_contents = 6; - - // DT_INT64 - int64 int64_contents = 7; - - // DT_BOOL - bool bool_contents = 8; - - // DT_COMPLEX128 - double dcomplex_contents = 9; - - // DT_UINT32 - uint32 uint32_contents = 11; - - // DT_UINT64 - uint64 uint64_contents = 12; - - // Represents arbitrary Python data structures. - NoneValue none_contents = 50; - ListValue list_contents = 51; - TupleValue tuple_contents = 52; - DictValue dict_contents = 53; - NamedTupleValue namedtuple_contents = 54; - - google.protobuf.Any any_contents = 55; - } + repeated bentoml.grpc.v1.ContentsProto contents = 1; // The data contained in an output can be represented in // "raw" bytes form or in the repeated type that matches the @@ -200,10 +108,10 @@ message InferenceResponse { // specific data type for a 16-bit float type. // // If this field is specified then contents must not be specified for any input tensor. - repeated bytes raw_bytes_contents = 13; + repeated bytes raw_bytes_contents = 2; // Sends a rpc status back to the client. - google.rpc.Status status = 14; + google.rpc.Status status = 3; // the response should also include an error message type oneof errors {