Skip to content

Commit

Permalink
Merge pull request #3141 from juliusvonkohout/patch-1
Browse files Browse the repository at this point in the history
Support disabling of ssl/tls in seldon_client
  • Loading branch information
ukclivecox committed May 17, 2021
2 parents cde296c + 1749fde commit aad5615
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions python/seldon_core/seldon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def __init__(
call_credentials: SeldonCallCredentials = None,
debug: bool = False,
client_return_type: str = "dict",
ssl: bool = None,
):
"""
Expand Down Expand Up @@ -283,6 +284,7 @@ def predict(
meta: Dict = None,
client_return_type: str = None,
raw_data: Dict = None,
ssl: bool = None,
) -> SeldonClientPrediction:
"""
Expand Down Expand Up @@ -357,6 +359,7 @@ def predict(
meta=meta,
client_return_type=client_return_type,
raw_data=raw_data,
ssl=ssl,
)
self._validate_args(**k)
if k["gateway"] == "ambassador" or k["gateway"] == "istio":
Expand Down Expand Up @@ -394,6 +397,7 @@ def feedback(
gateway_prefix: str = None,
client_return_type: str = None,
raw_request: dict = None,
ssl: bool = None,
) -> SeldonClientFeedback:
"""
Expand Down Expand Up @@ -447,6 +451,7 @@ def feedback(
gateway_prefix=gateway_prefix,
client_return_type=client_return_type,
raw_request=raw_request,
ssl=ssl,
)
self._validate_args(**k)
if k["gateway"] == "ambassador" or k["gateway"] == "istio":
Expand Down Expand Up @@ -509,6 +514,7 @@ def explain(
http_path: str = None,
client_return_type: str = None,
predictor: str = None,
ssl: bool = None,
) -> Dict:
"""
Expand Down Expand Up @@ -575,6 +581,7 @@ def explain(
http_path=http_path,
client_return_type=client_return_type,
predictor=predictor,
ssl=ssl,
)
self._validate_args(**k)
if k["gateway"] == "ambassador" or k["gateway"] == "istio":
Expand Down Expand Up @@ -1395,6 +1402,7 @@ def rest_predict_gateway(
meta: Dict = {},
client_return_type: str = "proto",
raw_data: Dict = None,
ssl: bool = None,
**kwargs,
) -> SeldonClientPrediction:
"""
Expand Down Expand Up @@ -1469,13 +1477,13 @@ def rest_predict_gateway(
req_headers = headers.copy()
else:
req_headers = {}
if call_credentials is None:
if call_credentials is None or ssl is False:
scheme = "http"
else:
scheme = "https"
if not call_credentials is None:
if not call_credentials.token is None:
req_headers["X-Auth-Token"] = call_credentials.token
if not call_credentials is None:
if not call_credentials.token is None:
req_headers["X-Auth-Token"] = call_credentials.token
if http_path is not None:
url = url = (
scheme
Expand Down Expand Up @@ -1578,6 +1586,7 @@ def explain_predict_gateway(
http_path: str = None,
client_return_type: str = "dict",
predictor: str = None,
ssl: bool = None,
**kwargs,
) -> SeldonClientPrediction:
"""
Expand Down Expand Up @@ -1647,13 +1656,13 @@ def explain_predict_gateway(
req_headers = headers.copy()
else:
req_headers = {}
if channel_credentials is None:
if channel_credentials is None or ssl is False:
scheme = "http"
else:
scheme = "https"
if not call_credentials is None:
if not call_credentials.token is None:
req_headers["X-Auth-Token"] = call_credentials.token
if not call_credentials is None:
if not call_credentials.token is None:
req_headers["X-Auth-Token"] = call_credentials.token
if http_path is not None:
url = (
scheme
Expand Down Expand Up @@ -1759,6 +1768,7 @@ def grpc_predict_gateway(
meta: Dict = {},
client_return_type: str = "proto",
raw_data: Dict = None,
ssl: bool = None,
**kwargs,
) -> SeldonClientPrediction:
"""
Expand Down Expand Up @@ -1866,7 +1876,10 @@ def grpc_predict_gateway(
)
# This piece also allows for blank SSL Channel credentials in case this is required
else:
grpc_channel_credentials = grpc.ssl_channel_credentials()
if ssl is False:
grpc_channel_credentials = grpc.local_channel_credentials()
else:
grpc_channel_credentials = grpc.ssl_channel_credentials()
if channel_credentials.verify == False:
# If Verify is set to false then we add the SSL Target Name Override option
options += [
Expand Down

0 comments on commit aad5615

Please sign in to comment.