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

!205 fix bugs of multi-scalars comparision under concurrency [r0.3]

Merge pull request !205 from liangyongxiong/r0.3-fix-scalar-concurrency
......@@ -16,8 +16,10 @@
from urllib.parse import unquote
from mindinsight.utils.exceptions import ParamValueError, UrlDecodeError
from mindinsight.datavisual.common.log import logger
from mindinsight.datavisual.utils.tools import if_nan_inf_to_none
from mindinsight.datavisual.common.exceptions import ScalarNotExistError
from mindinsight.datavisual.common.exceptions import TrainJobNotExistError
from mindinsight.datavisual.common.validation import Validation
from mindinsight.datavisual.processors.base_processor import BaseProcessor
......@@ -71,25 +73,44 @@ class ScalarsProcessor(BaseProcessor):
scalars = []
for train_id in train_ids:
for tag in tags:
try:
tensors = self._data_manager.list_tensors(train_id, tag)
except ParamValueError:
continue
scalar = {
'train_id': train_id,
'tag': tag,
'values': [],
}
for tensor in tensors:
scalar['values'].append({
'wall_time': tensor.wall_time,
'step': tensor.step,
'value': if_nan_inf_to_none('scalar_value', tensor.value),
})
scalars.append(scalar)
scalars += self._get_train_scalars(train_id, tags)
return scalars
def _get_train_scalars(self, train_id, tags):
"""
Get scalar data for given train_id and tags.
Args:
train_id (str): Specify train job ID.
tags (list): Specify list of tags.
Returns:
list[dict], a list of dictionaries containing the `wall_time`, `step`, `value` for each scalar.
"""
scalars = []
for tag in tags:
try:
tensors = self._data_manager.list_tensors(train_id, tag)
except ParamValueError:
continue
except TrainJobNotExistError:
logger.warning('Can not find the given train job in cache.')
return []
scalar = {
'train_id': train_id,
'tag': tag,
'values': [],
}
for tensor in tensors:
scalar['values'].append({
'wall_time': tensor.wall_time,
'step': tensor.step,
'value': if_nan_inf_to_none('scalar_value', tensor.value),
})
scalars.append(scalar)
return scalars
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册