I want to use gRPC calls when our model is deployed in seldon. Following is the code I got for python gRPC from seldon example.
def get_token():
payload = {'grant_type': 'client_credentials'}
"http://{}:8080/oauth/token".format(SELDON_API_IP),
auth=HTTPBasicAuth('oauth-key', 'oauth-secret'),
data=payload)
token = response.json()["access_token"]
return token
def grpc_request():
token = get_token()
datadef = prediction_pb2.DefaultData(
names = ["a","b"],
tensor = prediction_pb2.Tensor(
shape = [3,2],
values = [1.0,1.0,2.0,3.0,4.0,5.0]
)
)
request = prediction_pb2.SeldonMessage(data = datadef)
channel = grpc.insecure_channel("{}:5000".format(SELDON_API_IP))
stub = prediction_pb2_grpc.SeldonStub(channel)
metadata = [('oauth_token', token)]
response = stub.Predict(request=request,metadata=metadata)
print(response)
I want to convert same in Java for gRPC request. What will be equivalent code in Java and required dependencies for gRPC?