Skip to content

Commit

Permalink
Escape some special characters for benchmark remark. (#1096)
Browse files Browse the repository at this point in the history
* Escape some special characters for benchmark remark.

* Do not show exception detail as there are some non ascii characters which html table does not support.
  • Loading branch information
zhangyang2057 authored Sep 21, 2023
1 parent 2fe80ac commit b0d4962
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import time
import subprocess
from update_trace_info import *
from html import escape


def data_shape_list_string(data):
Expand Down Expand Up @@ -273,7 +274,7 @@ def run_evb(self, target, kmodel, compile_opt, infer_dir):

if self.cfg['infer_report_opt']['enabled']:
self.infer_report_dict['result'] = 'Fail'
self.infer_report_dict['remark'] = detail.replace('\n', '<br/>')
self.infer_report_dict['remark'] = escape(detail)
prefix, suffix = os.path.splitext(self.infer_report_file)
json_file = f'{prefix}_{os.path.basename(self.case_dir)}{suffix}'
dump_dict_to_json(self.infer_report_dict, json_file)
Expand Down
2 changes: 1 addition & 1 deletion tests/nuc_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def infer_worker(target):
if ret.find('terminate') != -1 or ret.find('Exception') != -1:
err = 'infer exception'
target.logger.error(err)
msg = f'{err}: {ret}'.encode()
msg = f'{err}'.encode()
dict['type'] = 'exception'
dict['len'] = len(msg)
conn.sendall(json.dumps(dict).encode())
Expand Down
4 changes: 3 additions & 1 deletion tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from evaluator import *
from compare_util import *
from test_utils import *
from html import escape


class TestRunner(Evaluator, Inference, metaclass=ABCMeta):
Expand Down Expand Up @@ -271,7 +272,8 @@ def run(self, model_file: Union[List[str], str]):

if stage == 'infer' and self.cfg['infer_report_opt']['enabled']:
self.infer_report_dict['result'] = 'Pass' if judge else 'Fail'
self.infer_report_dict['remark'] = result.replace('\n', '<br/>')
self.infer_report_dict['remark'] = escape(
result).replace('\n', '<br/>')
prefix, suffix = os.path.splitext(self.infer_report_file)
json_file = f'{prefix}_{os.path.basename(self.case_dir)}{suffix}'
dump_dict_to_json(self.infer_report_dict, json_file)
Expand Down
5 changes: 0 additions & 5 deletions tests/update_trace_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,23 @@ def update_trace_info(infer_result: str, info_file: str):
line = buf.readline()
if not line:
break
print('line = {0}'.format(line))

if status == Status.find_titile:
title = find_titile(line)
print('title = {0}'.format(title))
if title:
status = Status.find_time
item_num = find_items(info_file)
print('item_num = {0}'.format(item_num))
if item_num == -1 or item_num == 0:
item_num = -1
status = Status.find_titile
continue

if status is Status.find_time:
time = find_time(line)
print('time = {0}'.format(time))
if time:
times.append(time)
if (len(times) == item_num):
update_items(info_file, times)
print('time updated!')
times.clear()
status = Status.find_titile
continue

0 comments on commit b0d4962

Please sign in to comment.