From 6e885d668b69b39e54166f905110b7b3e260fca9 Mon Sep 17 00:00:00 2001 From: Haodong Duan Date: Tue, 25 Jul 2023 10:06:01 +0800 Subject: [PATCH] force utf-8 encoding for all non-dataset fileios (#97) --- opencompass/openicl/icl_retriever/icl_votek_retriever.py | 2 +- opencompass/utils/summarizer.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opencompass/openicl/icl_retriever/icl_votek_retriever.py b/opencompass/openicl/icl_retriever/icl_votek_retriever.py index ab81ad0e..ceddfb9d 100644 --- a/opencompass/openicl/icl_retriever/icl_votek_retriever.py +++ b/opencompass/openicl/icl_retriever/icl_votek_retriever.py @@ -42,7 +42,7 @@ class VotekRetriever(TopkRetriever): vote_file=None): n = len(embeddings) if vote_file is not None and os.path.isfile(vote_file): - with open(vote_file) as f: + with open(vote_file, encoding='utf-8') as f: vote_stat = json.load(f) else: vote_stat = defaultdict(list) diff --git a/opencompass/utils/summarizer.py b/opencompass/utils/summarizer.py index a6704b68..aefa8c94 100644 --- a/opencompass/utils/summarizer.py +++ b/opencompass/utils/summarizer.py @@ -205,7 +205,7 @@ class Summarizer: output_dir = osp.split(output_path)[0] mmengine.mkdir_or_exist(output_dir) - with open(output_path, 'w') as f: + with open(output_path, 'w', encoding='utf-8') as f: f.write(time_str + '\n') f.write('tabulate format\n') f.write('^' * 128 + '\n') @@ -228,6 +228,6 @@ class Summarizer: content += f'详细评测汇总已输出至 {osp.abspath(output_path)}' self.lark_reporter.post(content) - with open(output_csv_path, 'w') as f: + with open(output_csv_path, 'w', encoding='utf-8') as f: f.write('\n'.join([','.join(row) for row in table]) + '\n') self.logger.info(f'write csv to {osp.abspath(output_csv_path)}')