mirror of
https://github.com/clearml/clearml-serving
synced 2025-06-26 18:16:00 +00:00
Fix gRPC errors print stack traces and full verbose details. Add support for controlling error printouts using CLEARML_SERVING_AIO_RPC_IGNORE_ERRORS and CLEARML_SERVING_AIO_RPC_VERBOSE_ERRORS (pass a whitespace-separated list of error codes or error names)
This commit is contained in:
17
clearml_serving/serving/utils.py
Normal file
17
clearml_serving/serving/utils.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import List, Set
|
||||
|
||||
import grpc
|
||||
|
||||
|
||||
def parse_grpc_errors(errors: List[str]) -> Set[grpc.StatusCode]:
|
||||
try:
|
||||
typed_errors = {
|
||||
int(e) if e.isdigit() else e.lower().replace("-", " ").replace("_", " ")
|
||||
for e in errors
|
||||
}
|
||||
if len(typed_errors) == 1 and next(iter(typed_errors)) in ("true", "false"):
|
||||
return set(grpc.StatusCode if next(iter(typed_errors)) == "true" else [])
|
||||
return {e for e in grpc.StatusCode if typed_errors.intersection(e.value)}
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
return set()
|
||||
Reference in New Issue
Block a user