The following code sample shows how you can perform inference using Riva Python API gRPC bindings:
import grpc
import riva_api.riva_nlp_pb2 as rnlp
import riva_api.riva_nlp_pb2_grpc as rnlp_srv
grpc_server = “localhost:50051”
channel = grpc.insecure_channel(grpc_server)
riva_nlp = rnlp_srv.RivaLanguageUnderstandingStub(channel)
req = rnlp.NaturalQueryRequest()
req.query = “When did Beyonce start becoming popular?”
#req.context = test_context
resp = riva_nlp.NaturalQuery(req)
print(resp)
import grpc
import riva_api.riva_nlp_pb2 as rnlp
import riva_api.riva_nlp_pb2_grpc as rnlp_srv
grpc_server = “localhost:50051”
channel = grpc.insecure_channel(grpc_server)
riva_nlp = rnlp_srv.RivaLanguageUnderstandingStub(channel)
req = rnlp.NaturalQueryRequest()
req.query = “When did Beyonce start becoming popular?”
#req.context = test_context
resp = riva_nlp.NaturalQuery(req)
print(resp)
_InactiveRpcError Traceback (most recent call last)
in
14
15 #req.context = test_context
—> 16 resp = riva_nlp.NaturalQuery(req)
17 print(resp)
~/.local/lib/python3.6/site-packages/grpc/_channel.py in call(self, request, timeout, metadata, credentials, wait_for_ready, compression)
944 state, call, = self._blocking(request, timeout, metadata, credentials,
945 wait_for_ready, compression)
→ 946 return _end_unary_response_blocking(state, call, False, None)
947
948 def with_call(self,
~/.local/lib/python3.6/site-packages/grpc/_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
847 return state.response
848 else:
→ 849 raise _InactiveRpcError(state)
850
851
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = “Either the query or the context were empty.”
debug_error_string = “{“created”:”@1631009634.983369142",“description”:“Error received from peer ipv6:[::1]:50051”,“file”:“src/core/lib/surface/call.cc”,“file_line”:1066,“grpc_message”:“Either the query or the context were empty.”,“grpc_status”:3}