From 6bd0c51eb013dca012b832cc70d7cd394ec417ed Mon Sep 17 00:00:00 2001 From: felixhjh <852142024@qq.com> Date: Wed, 24 Nov 2021 16:25:20 +0000 Subject: [PATCH] modify init and error msg, import problem --- python/pipeline/dag.py | 5 +++-- python/pipeline/error_catch.py | 11 ++++++----- python/pipeline/operator.py | 7 ++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/python/pipeline/dag.py b/python/pipeline/dag.py index 138a2bac..1275bc70 100644 --- a/python/pipeline/dag.py +++ b/python/pipeline/dag.py @@ -29,8 +29,9 @@ import json from .error_catch import ErrorCatch, CustomException, CustomExceptionCode, ParamChecker, ParamVerify from .operator import Op, RequestOp, ResponseOp, VirtualOp from .channel import (ThreadChannel, ProcessChannel, ChannelData, - ChannelDataErrcode, ChannelDataType, ChannelStopError, - ProductErrCode) + ChannelDataType, ChannelStopError) +from .error_catch import ProductErrCode +from .error_catch import CustomExceptionCode as ChannelDataErrcode from .profiler import TimeProfiler, PerformanceTracer from .util import NameGenerator, ThreadIdGenerator, PipelineProcSyncManager from .proto import pipeline_service_pb2 diff --git a/python/pipeline/error_catch.py b/python/pipeline/error_catch.py index 0749134e..d56db57b 100644 --- a/python/pipeline/error_catch.py +++ b/python/pipeline/error_catch.py @@ -48,8 +48,9 @@ class CustomExceptionCode(enum.Enum): class ProductErrCode(enum.Enum): """ - ProductErrCode is a base class for recording business error code. - product developers overwrites this class and extend more error codes. + ProductErrCode is to record business error codes. + the ProductErrCode number ranges from 51 to 99 + product developers can directly add error code into this class. """ pass @@ -105,13 +106,13 @@ class ErrorCatch(): _LOGGER.error("\nLog_id: {}\n{}Classname: {}\nFunctionName: {}\nArgs: {}".format(log_id, traceback.format_exc(), func.__qualname__, func.__name__, args)) split_list = re.split("\n|\t|:", str(e)) resp.err_no = int(split_list[3]) - resp.err_msg = "Log_id: {} ErrNo: {} Error_msg: {} ClassName: {} FunctionName: {}".format(log_id, resp.err_no, split_list[9], func.__qualname__ ,func.__name__ ) + resp.err_msg = "Log_id: {} Raise_msg: {} ClassName: {} FunctionName: {}".format(log_id, split_list[9], func.__qualname__ ,func.__name__ ) is_send_to_user = split_list[-1].replace(" ", "") if is_send_to_user == "True": return (None, resp) else: print("Erro_Num: {} {}".format(resp.err_no, resp.err_msg)) - print("Init error occurs. For detailed information, Please look up log by log_id.") + print("Init error occurs. For detailed information. Please look up pipeline.log.wf in PipelineServingLogs by log_id.") kill_stop_process_by_pid("kill", os.getpgid(os.getpid())) except Exception as e: if "log_id" in kw.keys(): @@ -123,7 +124,7 @@ class ErrorCatch(): resp = pipeline_service_pb2.Response() _LOGGER.error("\nLog_id: {}\n{}Classname: {}\nFunctionName: {}\nArgs: {}".format(log_id, traceback.format_exc(), func.__qualname__, func.__name__, args)) resp.err_no = CustomExceptionCode.UNKNOW.value - resp.err_msg = "Log_id: {} ErrNo: {} Error_msg: {} ClassName: {} FunctionName: {}".format(log_id, resp.err_no, str(e).replace("\'", ""), func.__qualname__ ,func.__name__ ) + resp.err_msg = "Log_id: {} Raise_msg: {} ClassName: {} FunctionName: {}".format(log_id, str(e).replace("\'", ""), func.__qualname__ ,func.__name__ ) return (None, resp) else: resp = pipeline_service_pb2.Response() diff --git a/python/pipeline/operator.py b/python/pipeline/operator.py index 1950d4c9..4121e290 100644 --- a/python/pipeline/operator.py +++ b/python/pipeline/operator.py @@ -36,9 +36,10 @@ else: from .error_catch import ErrorCatch, CustomException, CustomExceptionCode from .proto import pipeline_service_pb2 -from .channel import (ThreadChannel, ProcessChannel, ChannelDataErrcode, - ChannelData, ChannelDataType, ChannelStopError, - ChannelTimeoutError, ProductErrCode) +from .channel import (ThreadChannel, ProcessChannel,ChannelData, + ChannelDataType, ChannelStopError, ChannelTimeoutError) +from .error_catch import ProductErrCode +from .error_catch import CustomExceptionCode as ChannelDataErrcode from .util import NameGenerator from .profiler import UnsafeTimeProfiler as TimeProfiler from . import local_service_handler -- GitLab