Skip to content

Commit fd5c9c2

Browse files
authored
Add more descriptive error messages (triton-inference-server#13)
1 parent 1b65f2c commit fd5c9c2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/resources/startup.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import signal
3535
import time
3636
import struct
37+
import traceback
3738

3839
from grpc_channelz.v1 import channelz
3940
from grpc_channelz.v1 import channelz_pb2
@@ -182,9 +183,10 @@ def Init(self, request, context):
182183
args = {x.key: x.value for x in request.args}
183184
try:
184185
self.backend.initialize(args)
185-
except tpb_utils.TritonModelException as e:
186+
except Exception as e:
186187
context.set_code(grpc.StatusCode.INTERNAL)
187-
context.set_details(e.message())
188+
tb = traceback.format_exc()
189+
context.set_details(tb)
188190

189191
return Empty()
190192

@@ -195,9 +197,10 @@ def Fini(self, request, context):
195197
if hasattr(self.backend, 'finalize'):
196198
try:
197199
self.backend.finalize()
198-
except tpb_utils.TritonModelException as e:
200+
except Exception as e:
199201
context.set_code(grpc.StatusCode.INTERNAL)
200-
context.set_details(e.message())
202+
tb = traceback.format_exc()
203+
context.set_details(tb)
201204

202205
return Empty()
203206

@@ -222,7 +225,7 @@ def Execute(self, request, context):
222225
numpy_type = tpb_utils.triton_to_numpy_type(x.dtype)
223226

224227
# We need to deserialize TYPE_STRING
225-
if numpy_type == np.object or numpy_type == np.bytes_:
228+
if numpy_type == np.object_ or numpy_type == np.bytes_:
226229
numpy_data = deserialize_bytes_tensor(x.raw_data)
227230
tensor = tpb_utils.Tensor(x.name,
228231
numpy_data.reshape(x.dims))
@@ -250,7 +253,12 @@ def Execute(self, request, context):
250253
context.set_details('Backend does not implement `execute` method')
251254
return ExecuteResponse()
252255

253-
responses = self.backend.execute(inference_requests)
256+
try:
257+
responses = self.backend.execute(inference_requests)
258+
except Exception as e:
259+
context.set_code(grpc.StatusCode.INTERNAL)
260+
tb = traceback.format_exc()
261+
context.set_details(tb)
254262

255263
# Make sure that number of InferenceResponse and InferenceRequest
256264
# objects match

0 commit comments

Comments
 (0)