From 9076c4a14c75cf8ad26a4396c623a7be60e1f156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=93=E6=B3=A2?= Date: Mon, 4 Mar 2024 11:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90bugfix=E3=80=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=88=B0=E5=AF=B9=E5=BA=94=E5=B1=9E=E7=BB=84=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/python/ptdbg_ascend/overflow_check/info_dump.py | 3 ++- .../src/python/ptdbg_ascend/parse_tool/lib/utils.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/overflow_check/info_dump.py b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/overflow_check/info_dump.py index 31a207a3f8..ab83c3f3e5 100644 --- a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/overflow_check/info_dump.py +++ b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/overflow_check/info_dump.py @@ -8,7 +8,7 @@ import numpy as np import torch from ..common.utils import print_error_log, get_time -from ..common.file_check_util import FileOpen +from ..common.file_check_util import FileOpen, FileCheckConst, change_mode special_torch_object = ["memory_format"] @@ -210,6 +210,7 @@ def write_json(file_path, data, indent=None): if not os.path.exists(file_path): with FileOpen(file_path, 'w') as f: f.write("{\n}") + change_mode(file_path, FileCheckConst.DATA_FILE_AUTHORITY) lock.acquire() with FileOpen(file_path, 'a+') as f: fcntl.flock(f, fcntl.LOCK_EX) diff --git a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/parse_tool/lib/utils.py b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/parse_tool/lib/utils.py index aa69a4780c..0e3b7af888 100644 --- a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/parse_tool/lib/utils.py +++ b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/parse_tool/lib/utils.py @@ -310,9 +310,14 @@ class Util: return md5_hash.hexdigest() def write_csv(self, data, filepath): + need_change_mode = False + if not os.path.exists(filepath): + need_change_mode = True with FileOpen(filepath, 'a') as f: writer = csv.writer(f) writer.writerows(data) + if need_change_mode: + change_mode(filepath, FileCheckConst.DATA_FILE_AUTHORITY) def deal_with_dir_or_file_inconsistency(self, output_path): if os.path.exists(output_path): -- Gitee