From b1c8d4d75857d84b76df1710feb0ff0e3d4c51b0 Mon Sep 17 00:00:00 2001 From: Li Hongzhang Date: Mon, 14 Sep 2020 09:22:40 +0800 Subject: [PATCH] detect having summary or not --- .../datavisual/data_transform/data_manager.py | 59 +++++++++---------- .../data_transform/summary_watcher.py | 52 ++++++++-------- .../processors/train_task_manager.py | 3 + mindinsight/ui/src/locales/en-us.json | 2 + mindinsight/ui/src/locales/zh-cn.json | 2 + .../src/views/train-manage/summary-manage.vue | 17 +++++- 6 files changed, 80 insertions(+), 55 deletions(-) diff --git a/mindinsight/datavisual/data_transform/data_manager.py b/mindinsight/datavisual/data_transform/data_manager.py index 12baa323..c81ba8e1 100644 --- a/mindinsight/datavisual/data_transform/data_manager.py +++ b/mindinsight/datavisual/data_transform/data_manager.py @@ -50,29 +50,18 @@ class _BasicTrainJob: Basic info about train job. Args: - train_id (str): Id of the train job. abs_summary_base_dir (str): The canonical path of summary base directory. It should be the return value of realpath(). - abs_summary_dir (str): The canonical path of summary directory. It should be the return value of realpath(). - create_time (DateTime): The create time of summary directory. - update_time (DateTime): The latest modify time of summary files directly in the summary directory. - profiler_dir (str): The relative path of profiler directory. - profiler_type (str): The profiler device type. + entry (dict): The summary dir entry listed by SummaryWatcher. """ - def __init__(self, train_id, abs_summary_base_dir, abs_summary_dir, create_time, update_time, profiler_dir, - profiler_type=""): - self._train_id = train_id + def __init__(self, abs_summary_base_dir, entry): self._abs_summary_base_dir = abs_summary_base_dir - self._abs_summary_dir = abs_summary_dir - self._create_time = create_time - self._update_time = update_time - self._profiler_dir = profiler_dir - self._profiler_type = profiler_type + self._entry = entry @property def abs_summary_dir(self): """Get summary directory path.""" - return self._abs_summary_dir + return os.path.realpath(os.path.join(self._abs_summary_base_dir, self._entry['relative_path'])) @property def summary_base_dir(self): @@ -82,27 +71,46 @@ class _BasicTrainJob: @property def train_id(self): """Get train id.""" - return self._train_id + return self._entry['relative_path'] @property def profiler_dir(self): """Get profiler directory path.""" - return self._profiler_dir + if self._entry['profiler'] is not None: + return self._entry['profiler']['directory'] + return None @property def create_time(self): """Get create time.""" - return self._create_time + return self._entry['create_time'] @property def update_time(self): """Get update time.""" - return self._update_time + return self._entry['update_time'] @property def profiler_type(self): """Get profiler type""" - return self._profiler_type + if self._entry['profiler'] is not None: + return self._entry['profiler']['profiler_type'] + return '' + + @property + def summary_files(self): + """Get the summary files count in the summary dir.""" + return self._entry['summary_files'] + + @property + def graph_files(self): + """Get the graph pb files count in the summary dir.""" + return self._entry['graph_files'] + + @property + def lineage_files(self): + """Get the lineage files count in the summary dir.""" + return self._entry['lineage_files'] class CachedTrainJob: @@ -377,18 +385,9 @@ class _BriefCacheManager(_BaseCacheManager): basic_train_jobs = [] for info in summaries_info: - profiler = info['profiler'] basic_train_jobs.append(_BasicTrainJob( - train_id=info['relative_path'], abs_summary_base_dir=self._summary_base_dir, - abs_summary_dir=os.path.realpath(os.path.join( - self._summary_base_dir, - info['relative_path'] - )), - create_time=info['create_time'], - update_time=info['update_time'], - profiler_dir=None if profiler is None else profiler['directory'], - profiler_type="" if profiler is None else profiler['profiler_type'], + entry=info )) with self._lock: diff --git a/mindinsight/datavisual/data_transform/summary_watcher.py b/mindinsight/datavisual/data_transform/summary_watcher.py index cc040226..197a1130 100644 --- a/mindinsight/datavisual/data_transform/summary_watcher.py +++ b/mindinsight/datavisual/data_transform/summary_watcher.py @@ -26,6 +26,7 @@ from mindinsight.datavisual.utils.utils import contains_null_byte from mindinsight.datavisual.common.exceptions import MaxCountExceededError from mindinsight.utils.exceptions import FileSystemPermissionError +LINEAGE_SUMMARY_SUFFIX = '_lineage' class SummaryWatcher: """SummaryWatcher class.""" @@ -99,18 +100,8 @@ class SummaryWatcher: for key, value in summary_dict.items(): directory = { 'relative_path': key, - 'profiler': None, - 'create_time': value['ctime'], - 'update_time': value['mtime'], + **value } - profiler = value.get('profiler') - if profiler is not None: - directory['profiler'] = { - 'directory': profiler['directory'], - 'create_time': profiler['ctime'], - 'update_time': profiler['mtime'], - 'profiler_type': profiler['profiler_type'] - } directories.append(directory) # sort by update time in descending order and relative path in ascending order @@ -215,15 +206,24 @@ class SummaryWatcher: return if relative_path not in summary_dict: summary_dict[relative_path] = { - 'ctime': ctime, - 'mtime': mtime, + 'create_time': ctime, + 'update_time': mtime, + 'summary_files': 0, + 'lineage_files': 0, + 'graph_files': 0, 'profiler': None, } - elif summary_dict[relative_path]['ctime'] < ctime: + if summary_dict[relative_path]['create_time'] < ctime: summary_dict[relative_path].update({ - 'ctime': ctime, - 'mtime': mtime, + 'create_time': ctime, + 'update_time': mtime, }) + if not summary_pattern: + summary_dict[relative_path]['graph_files'] += 1 + elif entry.name.endswith(LINEAGE_SUMMARY_SUFFIX): + summary_dict[relative_path]['lineage_files'] += 1 + else: + summary_dict[relative_path]['summary_files'] += 1 elif entry.is_dir(): profiler_pattern = re.search(self.PROFILER_DIRECTORY_REGEX, entry.name) full_dir_path = os.path.join(summary_base_dir, relative_path, entry.name) @@ -233,16 +233,22 @@ class SummaryWatcher: profiler = { 'directory': os.path.join('.', entry.name), - 'ctime': ctime, - 'mtime': mtime, + 'create_time': ctime, + 'update_time': mtime, "profiler_type": profiler_type } - summary_dict[relative_path] = { - 'ctime': ctime, - 'mtime': mtime, - 'profiler': profiler, - } + if relative_path in summary_dict: + summary_dict[relative_path]['profiler'] = profiler + else: + summary_dict[relative_path] = { + 'create_time': ctime, + 'summary_files': 0, + 'lineage_files': 0, + 'graph_files': 0, + 'update_time': mtime, + 'profiler': profiler + } def is_summary_directory(self, summary_base_dir, relative_path): """ diff --git a/mindinsight/datavisual/processors/train_task_manager.py b/mindinsight/datavisual/processors/train_task_manager.py index 4aef0e0e..6e8c1dbd 100644 --- a/mindinsight/datavisual/processors/train_task_manager.py +++ b/mindinsight/datavisual/processors/train_task_manager.py @@ -145,6 +145,9 @@ class TrainTaskManager(BaseProcessor): profiler_dir=basic_info.profiler_dir, cache_status=train_job.cache_status.value, profiler_type=basic_info.profiler_type, + summary_files=basic_info.summary_files, + graph_files=basic_info.graph_files, + lineage_files=basic_info.lineage_files ) if train_job.cache_status == CacheStatus.CACHED: diff --git a/mindinsight/ui/src/locales/en-us.json b/mindinsight/ui/src/locales/en-us.json index 4fe4040f..b42160c9 100644 --- a/mindinsight/ui/src/locales/en-us.json +++ b/mindinsight/ui/src/locales/en-us.json @@ -51,6 +51,8 @@ "dataTraceback": "Dataset Lineage", "comparePlate": "Comparison Dashboard", "disableProfilerTip": "Failed to view profiling because no profiler log is available.", + "disableDashboardTip": "Failed to view training dashboard because no summary log or pb files are available.", + "disableParameterTip": "Failed to view parameter details because no lineage log is available.", "openNewTab": "Open Link in New Tab", "paramDetails": "Parameter Details", "trainingParamDetails": "Training Parameter Details", diff --git a/mindinsight/ui/src/locales/zh-cn.json b/mindinsight/ui/src/locales/zh-cn.json index cb3d94ba..4f58a1a2 100644 --- a/mindinsight/ui/src/locales/zh-cn.json +++ b/mindinsight/ui/src/locales/zh-cn.json @@ -51,6 +51,8 @@ "dataTraceback": "数据溯源", "comparePlate": "对比看板", "disableProfilerTip": "无profiler日志,无法查看性能分析", + "disableDashboardTip": "无summary日志或pb文件,无法查看训练看板", + "disableParameterTip": "无lineage日志,无法查看参数详情", "openNewTab": "打开新页签", "paramDetails": "参数详情", "trainingParamDetails": "训练参数详情", diff --git a/mindinsight/ui/src/views/train-manage/summary-manage.vue b/mindinsight/ui/src/views/train-manage/summary-manage.vue index 747edcdf..9beba31a 100644 --- a/mindinsight/ui/src/views/train-manage/summary-manage.vue +++ b/mindinsight/ui/src/views/train-manage/summary-manage.vue @@ -74,10 +74,16 @@ limitations under the License. class-name="operate-container" width="400"> @@ -267,6 +278,8 @@ export default { i.relative_path = i.relative_path ? i.relative_path : '--'; i.update_time = i.update_time ? i.update_time : '--'; i.viewProfiler = i.profiler_dir && i.profiler_dir.length; + i.viewDashboard = i.summary_files || i.graph_files || i.lineage_files; + i.paramDetails = i.lineage_files; }); this.currentFolder = res.data.name ? res.data.name : '--'; this.pagination.total = res.data.total;