diff --git a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py index 44f8dbdfb499c374c86bf5a92572502b7703be63..22a7e4ecdb6aeb4b31cc1f76d85e2f81fa89414e 100644 --- a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py +++ b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py @@ -801,8 +801,14 @@ def create_kbyk_json(dump_path, summary_mode, step): } create_directory(dump_path) + tmp_json_path = os.path.join(dump_path, "tmp.json") config_json_path = os.path.join(dump_path, "kernel_kbyk_dump.json") - save_json(config_json_path, config_json, indent=4) + save_json(tmp_json_path, config_json, indent=4) + while not os.path.exists(tmp_json_path): + logger.info(f"Waiting for {tmp_json_path} to be created...") + time.sleep(1) + if os.path.exists(tmp_json_path): + move_file(tmp_json_path, config_json_path) logger.info(config_json_path + " has been created.") return config_json_path diff --git a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py index 6b8b734450008d4945c29d14a239da6fc09a86c2..363503f9e07322add38fcc9e08a6bbc65ce72c04 100644 --- a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py +++ b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py @@ -778,8 +778,14 @@ def create_kbyk_json(dump_path, summary_mode, step): } create_directory(dump_path) + tmp_json_path = os.path.join(dump_path, "tmp.json") config_json_path = os.path.join(dump_path, "kernel_kbyk_dump.json") - save_json(config_json_path, config_json, indent=4) + save_json(tmp_json_path, config_json, indent=4) + while not os.path.exists(tmp_json_path): + logger.info(f"Waiting for {tmp_json_path} to be created...") + time.sleep(1) + if os.path.exists(tmp_json_path): + move_file(tmp_json_path, config_json_path) logger.info(config_json_path + " has been created.") return config_json_path