Browse Source

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

Merge pull request !424 from zhangyunshu/zys_timeline_fixed_filenotfounderror
tags/v0.6.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
1ef2205514
1 changed files with 4 additions and 7 deletions
  1. +4
    -7
      mindinsight/profiler/analyser/timeline_analyser.py

+ 4
- 7
mindinsight/profiler/analyser/timeline_analyser.py View File

@@ -62,9 +62,7 @@ class TimelineAnalyser(BaseAnalyser):
Returns:
json, the content of timeline data.
"""
# Search timeline json file under profiling dir.
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 = validate_and_normalize_path(
file_path, raise_key='Invalid timeline json path.'
@@ -90,11 +88,8 @@ class TimelineAnalyser(BaseAnalyser):
Returns:
json, the content of timeline summary information.
"""
file_path = None
summary_file_name = 'timeline_summary_{}.json'.format(self._device_id)
if summary_file_name in os.listdir(self._profiling_dir):
file_path = os.path.join(self._profiling_dir, summary_file_name)

summary_filename = self._timeline_summary_filename.format(self._device_id)
file_path = os.path.join(self._profiling_dir, summary_filename)
file_path = validate_and_normalize_path(
file_path, raise_key='Invalid timeline summary path.'
)
@@ -107,6 +102,8 @@ class TimelineAnalyser(BaseAnalyser):
except (IOError, OSError, json.JSONDecodeError) as err:
logger.error('Error occurred when read timeline summary file: %s', err)
raise ProfilerIOException
else:
logger.info('No timeline summary file. Please check the output path.')

return timeline_summary



Loading…
Cancel
Save