Commit 884e0815 by lichenggang

增加日志

parent d861280f
Showing with 15 additions and 6 deletions
......@@ -3,7 +3,7 @@ import time, json
import grpc
from protobuf import classify_pb2
from protobuf import classify_pb2_grpc
import traceback
from utils.config import model_config
from predic_fac import PredictorFac
from utils.log_manager import get_logger
......@@ -18,9 +18,17 @@ class Classify(classify_pb2_grpc.classifyServicer):
def Classify(self, request, context):
dic_data = json.loads(request.keyword)
print(dic_data)
res = self.predictorfac.predict(dic_data)
try:
dic_data = json.loads(request.keyword)
res = self.predictorfac.predict(dic_data)
res['status'] = 1
except:
res = {
'status': 0,
'err_msg': '未知'
}
log_server.error(traceback.format_exc())
return classify_pb2.ClassifyReply(message='result {msg}'.format(msg=res))
def fac_test_predic(self, data):
......
......@@ -138,13 +138,14 @@ class DicPredict(BasePredictor):
return model_id_res
def predict(self, dic_data, predict_type='all'):
self.info.info('预测类型为%s接收数据: ' % predict_type + str(dic_data))
dic_data = self.pre_deal(dic_data)
if predict_type == 'all':
head_id_res = self.head_predict(dic_data)
model_id_res = self.model_predict(dic_data)
print('表头预测结果', head_id_res)
print('模型预测结果', model_id_res)
self.info.info('表头预测结果: ' + str(head_id_res))
self.info.info('模型预测结果: ' + str(model_id_res))
# 表头预测和模型预测最后返回的数据进行综合处理
head_std_result = head_id_res.get('std_result')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment