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

!424 profiler: fixed 500 error when timeline summary file dose not exist

Merge pull request !424 from zhangyunshu/zys_timeline_fixed_filenotfounderror
...@@ -62,9 +62,7 @@ class TimelineAnalyser(BaseAnalyser): ...@@ -62,9 +62,7 @@ class TimelineAnalyser(BaseAnalyser):
Returns: Returns:
json, the content of timeline data. json, the content of timeline data.
""" """
# Search timeline json file under profiling dir.
display_filename = self._display_filename.format(self._device_id) display_filename = self._display_filename.format(self._device_id)
# Check if there is a timeline json file for display
file_path = os.path.join(self._profiling_dir, display_filename) file_path = os.path.join(self._profiling_dir, display_filename)
file_path = validate_and_normalize_path( file_path = validate_and_normalize_path(
file_path, raise_key='Invalid timeline json path.' file_path, raise_key='Invalid timeline json path.'
...@@ -90,11 +88,8 @@ class TimelineAnalyser(BaseAnalyser): ...@@ -90,11 +88,8 @@ class TimelineAnalyser(BaseAnalyser):
Returns: Returns:
json, the content of timeline summary information. json, the content of timeline summary information.
""" """
file_path = None summary_filename = self._timeline_summary_filename.format(self._device_id)
summary_file_name = 'timeline_summary_{}.json'.format(self._device_id) file_path = os.path.join(self._profiling_dir, summary_filename)
if summary_file_name in os.listdir(self._profiling_dir):
file_path = os.path.join(self._profiling_dir, summary_file_name)
file_path = validate_and_normalize_path( file_path = validate_and_normalize_path(
file_path, raise_key='Invalid timeline summary path.' file_path, raise_key='Invalid timeline summary path.'
) )
...@@ -107,6 +102,8 @@ class TimelineAnalyser(BaseAnalyser): ...@@ -107,6 +102,8 @@ class TimelineAnalyser(BaseAnalyser):
except (IOError, OSError, json.JSONDecodeError) as err: except (IOError, OSError, json.JSONDecodeError) as err:
logger.error('Error occurred when read timeline summary file: %s', err) logger.error('Error occurred when read timeline summary file: %s', err)
raise ProfilerIOException raise ProfilerIOException
else:
logger.info('No timeline summary file. Please check the output path.')
return timeline_summary return timeline_summary
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册