提交 c363a866 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!404 Change the summary watcher for not calling analyse in user scripts.

Merge pull request !404 from yuximiao/master
...@@ -226,7 +226,7 @@ class SummaryWatcher: ...@@ -226,7 +226,7 @@ class SummaryWatcher:
elif entry.is_dir(): elif entry.is_dir():
profiler_pattern = re.search(self.PROFILER_DIRECTORY_REGEX, entry.name) profiler_pattern = re.search(self.PROFILER_DIRECTORY_REGEX, entry.name)
full_dir_path = os.path.join(summary_base_dir, relative_path, entry.name) full_dir_path = os.path.join(summary_base_dir, relative_path, entry.name)
if profiler_pattern is None or self._is_empty_directory(full_dir_path): if profiler_pattern is None or not self._is_valid_profiler_directory(full_dir_path):
return return
profiler = { profiler = {
...@@ -286,19 +286,19 @@ class SummaryWatcher: ...@@ -286,19 +286,19 @@ class SummaryWatcher:
profiler_pattern = re.search(self.PROFILER_DIRECTORY_REGEX, entry.name) profiler_pattern = re.search(self.PROFILER_DIRECTORY_REGEX, entry.name)
if profiler_pattern is not None and entry.is_dir(): if profiler_pattern is not None and entry.is_dir():
full_path = os.path.realpath(os.path.join(summary_directory, entry.name)) full_path = os.path.realpath(os.path.join(summary_directory, entry.name))
if not self._is_empty_directory(full_path): if self._is_valid_profiler_directory(full_path):
return True return True
return False return False
def _is_empty_directory(self, directory): def _is_valid_profiler_directory(self, directory):
try: try:
count = len(os.listdir(directory)) from mindinsight.profiler.common.util import analyse_device_list_from_profiler_dir
except FileNotFoundError: device_list = analyse_device_list_from_profiler_dir(directory)
logger.warning('Directory %s not found.', directory) except ImportError:
count = 0 device_list = []
return not bool(count) return bool(device_list)
def list_summary_directories_by_pagination(self, summary_base_dir, offset=0, limit=10): def list_summary_directories_by_pagination(self, summary_base_dir, offset=0, limit=10):
""" """
......
...@@ -35,16 +35,24 @@ def analyse_device_list_from_profiler_dir(profiler_dir): ...@@ -35,16 +35,24 @@ def analyse_device_list_from_profiler_dir(profiler_dir):
Returns: Returns:
list, the device_id list. list, the device_id list.
""" """
profiler_file_prefix = ["timeline_display", "output_op_compute_time"]
device_id_list = set() device_id_list = set()
for _, _, filenames in os.walk(profiler_dir): for _, _, filenames in os.walk(profiler_dir):
for filename in filenames: for filename in filenames:
profiler_file_prefix = ["output_op_compute_time", "output_data_preprocess_aicpu"] if filename.startswith("step_trace_raw"):
items = filename.split("_") items = filename.split("_")
device_num = items[-1].split(".")[0] if items[-1].split(".") else "" device_num = ""
if len(items) > 3:
device_num = items[3]
else:
items = filename.split("_")
device_num = items[-1].split(".")[0] if items[-1].split(".") else ""
if device_num.isdigit() and '_'.join(items[:-1]) in profiler_file_prefix: if device_num.isdigit() and '_'.join(items[:-1]) in profiler_file_prefix:
device_id_list.add(device_num) device_id_list.add(device_num)
return list(device_id_list) return sorted(list(device_id_list))
def query_latest_trace_time_file(profiler_dir, device_id=0): def query_latest_trace_time_file(profiler_dir, device_id=0):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册