Skip to content

Commit

Permalink
run lint reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
nadinet committed Mar 26, 2021
1 parent bc6e10c commit 405c3ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/seldon_core/seldon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ def grpc_predict_seldon(
grpc_max_receive_message_length: int = 4 * 1024 * 1024,
names: Iterable[str] = None,
client_return_type: str = "proto",
raw_data: Dict = None,
raw_data: Dict = None,
**kwargs,
) -> SeldonClientPrediction:
"""
Expand Down
8 changes: 7 additions & 1 deletion python/tests/test_seldon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)

JSON_TEST_DATA = {"test": [0.0, 1.0]}
RAW_DATA_TEST = {"data":{"ndarray":[[0.0,1.0,2.0]]}}
RAW_DATA_TEST = {"data": {"ndarray": [[0.0, 1.0, 2.0]]}}
CUSTOM_TEST_DATA = any_pb2.Any(value=b"test")


Expand Down Expand Up @@ -50,11 +50,13 @@ def mocked_requests_post_success_json_data(url, *args, **kwargs):
json = seldon_message_to_json(request)
return MockResponse(json, 200, text="{}")


def mocked_requests_post_success_raw_data(url, *args, **kwargs):
request = json_to_seldon_message(RAW_DATA_TEST)
json = seldon_message_to_json(request)
return MockResponse(json, 200, text="{}")


@mock.patch("requests.post", side_effect=mocked_requests_post_404)
def test_predict_rest_404(mock_post):
sc = SeldonClient(deployment_name="404")
Expand Down Expand Up @@ -135,6 +137,7 @@ def test_predict_rest_raw_data_seldon_proto(mock_post):
assert json_response == RAW_DATA_TEST
assert mock_post.call_count == 1


@mock.patch("requests.post", side_effect=mocked_requests_post_success_raw_data)
def test_predict_rest_raw_data_gateway_dict(mock_post):
sc = SeldonClient(
Expand Down Expand Up @@ -323,6 +326,7 @@ def test_predict_grpc_seldon():
response = sc.predict(client_return_type="proto")
assert response.response.strData == "predict"


@mock.patch("seldon_core.seldon_client.prediction_pb2_grpc.SeldonStub", new=MyStub)
def test_predict_grpc_proto_raw_data_seldon():
sc = SeldonClient(deployment_name="mymodel", transport="grpc", gateway="seldon")
Expand All @@ -332,6 +336,7 @@ def test_predict_grpc_proto_raw_data_seldon():
assert request == RAW_DATA_TEST
assert response.response.strData == "predict"


@mock.patch("seldon_core.seldon_client.prediction_pb2_grpc.SeldonStub", new=MyStub)
def test_predict_grpc_raw_data_gateway():
sc = SeldonClient(deployment_name="mymodel", transport="grpc", gateway="istio")
Expand All @@ -340,6 +345,7 @@ def test_predict_grpc_raw_data_gateway():
assert request == RAW_DATA_TEST
assert response.response.strData == "predict"


@mock.patch("seldon_core.seldon_client.prediction_pb2_grpc.SeldonStub", new=MyStub)
def test_grpc_predict_json_data_seldon():
sc = SeldonClient(
Expand Down

0 comments on commit 405c3ba

Please sign in to comment.