12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- """
- @Authors: yangzihao(yangzihao@china-icv.cn)
- @Data: 2024/01/30
- @Last Modified: 2024/01/30
- @Summary: Evaluateion functions
- """
- import os
- import sys
- sys.path.append('../config')
- sys.path.append('../common')
- sys.path.append('../modules')
- sys.path.append('../results')
- import json
- import traceback
- import log
- from config_parser import ConfigParse
- from single_case_evaluate import single_case_evaluate
- from report_generate import report_generate
- def single_case_eval(configPath, dataPath, resultPath, trackPath, case_name):
- """
- :param configPath: 配置文件路径
- :param dataPath: 评价数据路径
- :param resultPath: 评价结果路径
- :param trackPath: 轨迹图片路径
- :param case_name: 用例名称
- :return: None
- """
- logger = log.get_logger()
-
- if len(os.listdir(dataPath)) == 0:
- print("No files in data_path!")
- logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: No files in data_path!")
- sys.exit(-1)
-
- try:
- config = ConfigParse(configPath)
- print("config is", config)
- except Exception as e:
- print('Config file parsing ERROR!', e)
- traceback.print_exc()
- logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Config file parsing ERROR: {repr(e)}!", exc_info=True)
- sys.exit(-1)
-
- try:
- reportDict = single_case_evaluate(config, dataPath, resultPath, case_name)
-
-
- with open(f'{resultPath}/report.json', 'w', encoding='utf-8') as f:
- f.write(json.dumps(reportDict, ensure_ascii=False))
-
- reportPdf = os.path.join(resultPath, 'report.pdf')
- report_generate(reportDict, reportPdf, trackPath)
- except Exception as e:
- traceback.print_exc()
- logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Evaluate single case ERROR: {repr(e)}!", exc_info=True)
- sys.exit(-1)
|