def __init__(self): from server.config.config import load_config config = load_config() self.client = influxdb.InfluxDBClient(config.INFLUXDB_HOST, database=config.INFLUXDB_DB, use_udp=True, udp_port=config.INFLUXDB_PORT) self.measurement = '.'.join([config.GROUP_NAME, config.SERVER_NAME]) self.env = config.APP_MODE
def __init__(self): ''' 初始化函数 在这里做具体的模型加载或者处理程序加载 ''' config = load_config() self.engine = nCoVTestEngine(config)
import pytest import yaml from server.protobufs.gen.pb_python import nCoV_diagnosis_engine_pb2 from server.config.config import load_config from server.engine.nCoV_test_engine import nCoVTestEngine, check_advance_reason from server.utils.common_help import Session config = load_config() engine = nCoVTestEngine(config) from google.protobuf.json_format import ParseDict, MessageToDict temp_req = nCoV_diagnosis_engine_pb2.DPRequest() def _real_test(qs, answer_index): his = [] for q in qs: question = nCoV_diagnosis_engine_pb2.DetailedQuestions() ParseDict(q, question, ignore_unknown_fields=True) his.append(question) with Session(temp_req, None) as context: ret_code, _, result = engine.predict(context, his_questions=his, strategy='beijing') assert ret_code == 0 assert result['reply_type'] == nCoV_diagnosis_engine_pb2.NO_NEED assert result['answer_index'] == answer_index context.mark_succ('Quiz', 1 if ret_code == 0 else 0, ret_code)
def __init__(self): ''' load config and load model ''' config = load_config() self.engine = nCoVTestEngine(config)
#!/usr/bin/env python3 # coding: utf-8 import time import sys from collections import namedtuple from loguru import logger, _defaults as loguru_defaults from server.protobufs.gen.pb_python import common_pb2 from server.config.config import load_config from server.utils.latency_recoder import RemoteInfluxDB # Context = namedtuple('Context', # ['version','request_id','user_id','session_id','trace_id','logger']) cf = load_config() logger.remove() # log format # 处理请求中的log带上函数名、行号、服务名和请求id等 # 其他的log格式默认 # 通过'log_req'来判断 def log_format(record): if 'log_req' in record["extra"]: return """{time:YYYY-MM-DD HH:mm:ss.SSS}|{level: <8} |{name}:{function}:{line}|{extra[log_req]}|{extra[server_name]} |{extra[user_id]}|{extra[request_id]}|{extra[session_id]}|{extra[trace_id]} |{message}\n""" else: return loguru_defaults.LOGURU_FORMAT + '\n'