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 31a207a3f80a9e1b090c8c78bb55c8d1c95392c9..ab83c3f3e560a3a036629368f7a9f9c2371000c7 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 aa69a4780c96d942853696d4a4cc63f2447d393f..0e3b7af888fa27fc684feb5f6ba96d496d111092 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):