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

Decode binData before sending it to Predict function #993

Merged
merged 5 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions python/seldon_core/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ANNOTATION_GRPC_MAX_MSG_SIZE,
)
from seldon_core.proto import prediction_pb2_grpc
import base64
import os

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -113,6 +114,10 @@ def __init__(self, user_model):
self.user_model = user_model

def Predict(self, request_grpc, context):
data_type = request_grpc.WhichOneof("data_oneof")
lennon310 marked this conversation as resolved.
Show resolved Hide resolved
if data_type == "binData":
binData = request_grpc.binData
request_grpc.binData = base64.b64decode(binData)
return seldon_core.seldon_methods.predict(self.user_model, request_grpc)

def SendFeedback(self, feedback_grpc, context):
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_model_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def test_proto_bin_data():
bdata_base64 = base64.b64encode(bdata)
request = prediction_pb2.SeldonMessage(binData=bdata_base64)
resp = app.Predict(request, None)
assert resp.binData == bdata_base64
assert resp.binData == bdata


def test_proto_bin_data_nparray():
Expand Down