Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
c60e9624
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
7
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c60e9624
编写于
4月 20, 2020
作者:
O
ougongchang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixing can not find node exception
fix ut for changes
上级
ecab5e89
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
13 deletion
+15
-13
mindinsight/datavisual/common/exceptions.py
mindinsight/datavisual/common/exceptions.py
+5
-2
mindinsight/datavisual/data_transform/graph/graph.py
mindinsight/datavisual/data_transform/graph/graph.py
+2
-2
mindinsight/datavisual/data_transform/graph/msgraph.py
mindinsight/datavisual/data_transform/graph/msgraph.py
+1
-1
mindinsight/datavisual/processors/graph_processor.py
mindinsight/datavisual/processors/graph_processor.py
+4
-3
tests/ut/datavisual/processors/test_graph_processor.py
tests/ut/datavisual/processors/test_graph_processor.py
+3
-5
未找到文件。
mindinsight/datavisual/common/exceptions.py
浏览文件 @
c60e9624
...
...
@@ -76,8 +76,11 @@ class SummaryLogIsLoading(MindInsightException):
class
NodeNotInGraphError
(
MindInsightException
):
"""Can not find node in graph error."""
def
__init__
(
self
):
error_msg
=
"Can not find node in graph by given node name."
def
__init__
(
self
,
node_name
,
node_type
=
None
):
if
node_type
is
not
None
:
error_msg
=
f
"Can not find node in graph by the given node name. node name:
{
node_name
}
, type:
{
node_type
}
."
else
:
error_msg
=
f
"Can not find node in graph by the given node name. node name:
{
node_name
}
."
super
(
NodeNotInGraphError
,
self
).
__init__
(
DataVisualErrors
.
NODE_NOT_IN_GRAPH_ERROR
,
error_msg
,
http_code
=
400
)
...
...
mindinsight/datavisual/data_transform/graph/graph.py
浏览文件 @
c60e9624
...
...
@@ -21,7 +21,7 @@ import time
from
enum
import
Enum
from
mindinsight.datavisual.common.log
import
logger
from
mindinsight.datavisual.common
import
exceptions
from
mindinsight.datavisual.common
.exceptions
import
NodeNotInGraphError
from
.node
import
NodeTypeEnum
from
.node
import
Node
...
...
@@ -151,7 +151,7 @@ class Graph:
"""
if
node_name
and
self
.
_polymeric_nodes
.
get
(
node_name
)
is
None
\
and
self
.
_normal_nodes
.
get
(
node_name
)
is
None
:
raise
exceptions
.
NodeNotInGraphError
(
)
raise
NodeNotInGraphError
(
node_name
=
node_name
)
response
=
{}
nodes
=
self
.
get_normal_nodes
()
...
...
mindinsight/datavisual/data_transform/graph/msgraph.py
浏览文件 @
c60e9624
...
...
@@ -82,7 +82,7 @@ class MSGraph(Graph):
self
.
_calc_output
()
logger
.
info
(
"Build leaf nodes end, normal nodes count: %s, group count: %s, "
"le
ft node
count: %s."
,
len
(
self
.
_normal_nodes
),
len
(
self
.
_node_groups
),
"le
af nodes
count: %s."
,
len
(
self
.
_normal_nodes
),
len
(
self
.
_node_groups
),
len
(
self
.
_leaf_nodes
))
def
_calc_input
(
self
,
leaf_node_id_map_name
,
graph_proto
,
const_nodes_map
):
...
...
mindinsight/datavisual/processors/graph_processor.py
浏览文件 @
c60e9624
...
...
@@ -23,6 +23,7 @@ from mindinsight.datavisual.common.validation import Validation
from
mindinsight.datavisual.data_transform.graph
import
NodeTypeEnum
from
mindinsight.datavisual.processors.base_processor
import
BaseProcessor
from
mindinsight.utils.exceptions
import
ParamValueError
from
mindinsight.datavisual.common.exceptions
import
NodeNotInGraphError
class
GraphProcessor
(
BaseProcessor
):
...
...
@@ -95,15 +96,15 @@ class GraphProcessor(BaseProcessor):
''
%
(
NodeTypeEnum
.
NAME_SCOPE
.
value
,
NodeTypeEnum
.
POLYMERIC_SCOPE
.
value
))
if
name
and
not
self
.
_graph
.
exist_node
(
name
):
raise
ParamValueError
(
"The node name is not in graph."
)
raise
NodeNotInGraphError
(
node_name
=
name
,
node_type
=
node_type
)
nodes
=
[]
if
node_type
==
NodeTypeEnum
.
NAME_SCOPE
.
value
:
nodes
=
self
.
_graph
.
get_normal_nodes
(
name
)
if
node_type
==
NodeTypeEnum
.
POLYMERIC_SCOPE
.
value
:
if
not
name
:
raise
ParamValueError
(
'The node name "%s" not in graph, node type is %s.'
%
(
name
,
node_type
))
raise
NodeNotInGraphError
(
node_name
=
name
,
node_type
=
node_type
)
polymeric_scope_name
=
name
nodes
=
self
.
_graph
.
get_polymeric_nodes
(
polymeric_scope_name
)
...
...
tests/ut/datavisual/processors/test_graph_processor.py
浏览文件 @
c60e9624
...
...
@@ -27,6 +27,7 @@ import pytest
from
mindinsight.datavisual.common
import
exceptions
from
mindinsight.datavisual.common.enums
import
PluginNameEnum
from
mindinsight.datavisual.common.exceptions
import
GraphNotExistError
from
mindinsight.datavisual.common.exceptions
import
NodeNotInGraphError
from
mindinsight.datavisual.data_transform
import
data_manager
from
mindinsight.datavisual.data_transform.data_manager
import
DataManager
from
mindinsight.datavisual.data_transform.loader_generators.data_loader_generator
import
DataLoaderGenerator
...
...
@@ -120,14 +121,11 @@ class TestGraphProcessor:
@
pytest
.
mark
.
parametrize
(
"name, node_type"
,
[(
"not_exist_name"
,
"name_scope"
),
(
""
,
"polymeric_scope"
)])
def
test_get_nodes_with_not_exist_name
(
self
,
name
,
node_type
):
"""Test getting nodes with not exist name."""
with
pytest
.
raises
(
ParamValue
Error
)
as
exc_info
:
with
pytest
.
raises
(
NodeNotInGraph
Error
)
as
exc_info
:
graph_processor
=
GraphProcessor
(
self
.
_train_id
,
self
.
_mock_data_manager
)
graph_processor
.
get_nodes
(
name
,
node_type
)
if
name
:
assert
"The node name is not in graph."
in
exc_info
.
value
.
message
else
:
assert
f
'The node name "
{
name
}
" not in graph, node type is
{
node_type
}
.'
in
exc_info
.
value
.
message
assert
'Can not find node in graph by the given node name'
in
exc_info
.
value
.
message
@
pytest
.
mark
.
usefixtures
(
'load_graph_record'
)
@
pytest
.
mark
.
parametrize
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录