From WORKDIR /usr/local/lib/python3.6/site-packages/paddle_serving_server/env_check/simple_web_service,CMD ["python", "web_service.py"] in dockerfile, it is known that the loading of its main body is mainly paddle-serving-server
classRequestOp(Op): """ RequestOp is a special Op, for unpacking one request package. If the request needs one special unpackaging method, you need to inherit class RequestOp and rewrite function unpack_request_package.Notice!!! Class RequestOp does not run preprocess, process, postprocess. """
def__init__(self): """ Initialize the RequestOp """ # PipelineService.name = "@DAGExecutor" super(RequestOp, self).__init__(name="@DAGExecutor", input_ops=[]) # init op try: self.init_op() except Exception as e: _LOGGER.critical("Op(Request) Failed to init: {}".format(e)) os._exit(-1)
defproto_tensor_2_numpy(self, tensor): """ Convert proto tensor to numpy array, The supported types are as follows: INT64 FP32 INT32 FP64 INT16 FP16 BF16 UINT8 INT8 BOOL BYTES Unsupported type: STRING COMPLEX64 COMPLEX128 Args: tensor: one tensor in request.tensors. Returns: np_data: np.ndnumpy, the tensor data is converted to numpy. lod_info: np.ndnumpy, lod info of the tensor data, None default. """ if tensor isNoneor tensor.elem_type isNoneor tensor.name isNone: _LOGGER.error("input params of tensor is wrong. tensor: {}".format( tensor)) returnNone
# Set dim shape dims = [] if tensor.shape isNone: dims.append(1) else: for one_dim in tensor.shape: dims.append(one_dim)
# Set up 2-d lod tensor np_lod = None iflen(tensor.lod) > 0: np_lod = np.array(tensor.lod).astype(int32).reshape(2, -1)