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

!209 add parameter validation for train job caches api [r0.3]

Merge pull request !209 from liangyongxiong/r0.3-fix-param-validation
......@@ -14,6 +14,7 @@
# ============================================================================
"""Train task manager."""
from mindinsight.utils.exceptions import ParamTypeError
from mindinsight.datavisual.common.log import logger
from mindinsight.datavisual.common import exceptions
from mindinsight.datavisual.common.enums import PluginNameEnum
......@@ -141,9 +142,20 @@ class TrainTaskManager(BaseProcessor):
Returns:
dict, indicates train job ID and its current cache status.
Raises:
ParamTypeError, if the given train_ids parameter is not in valid type.
"""
if not isinstance(train_ids, list):
logger.error("train_ids must be list.")
raise ParamTypeError('train_ids', list)
cache_result = []
for train_id in train_ids:
if not isinstance(train_id, str):
logger.error("train_id must be str.")
raise ParamTypeError('train_id', str)
try:
train_job = self._data_manager.get_train_job(train_id)
except exceptions.TrainJobNotExistError:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册