|
44 | 44 | import numpy as np |
45 | 45 |
|
46 | 46 | from python_host_pb2 import * |
47 | | -from python_host_pb2_grpc import PythonInterpreterServicer, add_PythonInterpreterServicer_to_server |
| 47 | +from python_host_pb2_grpc import \ |
| 48 | + PythonInterpreterServicer, add_PythonInterpreterServicer_to_server |
48 | 49 | import grpc |
49 | 50 |
|
50 | 51 | MAX_GRPC_MESSAGE_SIZE = 2147483647 |
@@ -72,9 +73,9 @@ def serialize_byte_tensor(input_tensor): |
72 | 73 | if input_tensor.size == 0: |
73 | 74 | return np.empty([0]) |
74 | 75 |
|
75 | | - # If the input is a tensor of string/bytes objects, then must flatten those into |
76 | | - # a 1-dimensional array containing the 4-byte byte size followed by the |
77 | | - # actual element bytes. All elements are concatenated together in "C" |
| 76 | + # If the input is a tensor of string/bytes objects, then must flatten those |
| 77 | + # into a 1-dimensional array containing the 4-byte byte size followed by |
| 78 | + # the actual element bytes. All elements are concatenated together in "C" |
78 | 79 | # order. |
79 | 80 | if (input_tensor.dtype == np.object) or (input_tensor.dtype.type |
80 | 81 | == np.bytes_): |
@@ -153,7 +154,9 @@ def __init__(self, module_path, *args, **kwargs): |
153 | 154 | super(PythonInterpreterServicer, self).__init__(*args, **kwargs) |
154 | 155 |
|
155 | 156 | module_path = Path(module_path).resolve() |
156 | | - # Add model parent directories so that relative and absolute import work |
| 157 | + |
| 158 | + # Add model parent directories so that relative and absolute imports |
| 159 | + # work. |
157 | 160 | sys.path.append(str(module_path.parent)) |
158 | 161 | sys.path.append(str(module_path.parent.parent)) |
159 | 162 |
|
@@ -190,7 +193,7 @@ def Init(self, request, context): |
190 | 193 | args = {x.key: x.value for x in request.args} |
191 | 194 | try: |
192 | 195 | self.model_instance.initialize(args) |
193 | | - except Exception as e: |
| 196 | + except Exception: |
194 | 197 | context.set_code(grpc.StatusCode.INTERNAL) |
195 | 198 | tb = traceback.format_exc() |
196 | 199 | context.set_details(tb) |
|
0 commit comments