!18580 Optimize error msg when pyfunc return None

Merge pull request !18580 from xiefangqi/md_fix_python_err_msg
This commit is contained in:
i-robot 2021-06-21 17:45:22 +08:00 committed by Gitee
commit fe4e01a96e
1 changed files with 5 additions and 2 deletions

View File

@ -61,7 +61,8 @@ Status PyFuncOp::Compute(const TensorRow &input, TensorRow *output) {
py::object ret_py_ele = ret_py_tuple[i];
// Object is none if pyfunc timeout
if (ret_py_ele.is_none()) {
MS_LOG(INFO) << "PyFunc execute time out";
MS_LOG(INFO) << "Expected that PyFunc should return numpy array, got None. If python_multiprocessing is "
"True, PyFunc may execute time out.";
goto TimeoutError;
}
if (!py::isinstance<py::array>(ret_py_ele)) {
@ -94,7 +95,9 @@ ShapeMisMatch:
goto ComputeReturn;
TimeoutError:
ret = Status(StatusCode::kMDTimeOut, __LINE__, __FILE__, "PyFunc execute time out");
ret = Status(StatusCode::kMDTimeOut, __LINE__, __FILE__,
"Expected that PyFunc should return numpy array, got None. If python_multiprocessing is True, "
"PyFunc may execute time out.");
goto ComputeReturn;
}