Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
32cea0e7
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看板
提交
32cea0e7
编写于
4月 28, 2020
作者:
L
luopengting
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add mixed type for customized
上级
72d3bb04
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
47 addition
and
18 deletion
+47
-18
mindinsight/lineagemgr/querier/querier.py
mindinsight/lineagemgr/querier/querier.py
+38
-15
tests/ut/lineagemgr/querier/event_data.py
tests/ut/lineagemgr/querier/event_data.py
+6
-0
tests/ut/lineagemgr/querier/test_querier.py
tests/ut/lineagemgr/querier/test_querier.py
+3
-3
未找到文件。
mindinsight/lineagemgr/querier/querier.py
浏览文件 @
32cea0e7
...
...
@@ -288,8 +288,8 @@ class Querier:
try
:
cmp_result
=
(
value1
>
value2
)
-
(
value1
<
value2
)
except
TypeError
:
type1
=
str
(
type
(
value1
))
type2
=
str
(
type
(
value2
))
type1
=
type
(
value1
).
__name__
type2
=
type
(
value2
).
__name__
cmp_result
=
(
type1
>
type2
)
-
(
type1
<
type2
)
return
cmp_result
...
...
@@ -314,19 +314,7 @@ class Querier:
offset_results
=
self
.
_handle_limit_and_offset
(
condition
,
results
)
customized
=
dict
()
for
offset_result
in
offset_results
:
for
obj_name
in
[
"metric"
,
"user_defined"
]:
obj
=
getattr
(
offset_result
,
obj_name
)
require
=
bool
(
obj_name
==
"metric"
)
if
obj
and
isinstance
(
obj
,
dict
):
for
key
,
value
in
obj
.
items
():
label
=
f
'
{
obj_name
}
/
{
key
}
'
customized
[
label
]
=
dict
()
customized
[
label
][
"label"
]
=
label
# user defined info is not displayed by default
customized
[
label
][
"required"
]
=
require
customized
[
label
][
"type"
]
=
type
(
value
).
__name__
customized
=
self
.
_organize_customized
(
offset_results
)
lineage_types
=
condition
.
get
(
ConditionParam
.
LINEAGE_TYPE
.
value
)
lineage_types
=
self
.
_get_lineage_types
(
lineage_types
)
...
...
@@ -348,6 +336,41 @@ class Querier:
return
lineage_info
def
_organize_customized
(
self
,
offset_results
):
"""Organize customized."""
customized
=
dict
()
for
offset_result
in
offset_results
:
for
obj_name
in
[
"metric"
,
"user_defined"
]:
self
.
_organize_customized_item
(
customized
,
offset_result
,
obj_name
)
# If types contain numbers and string, it will be "mixed".
# If types contain "int" and "float", it will be "float".
for
key
,
value
in
customized
.
items
():
types
=
value
[
"type"
]
if
len
(
types
)
==
1
:
customized
[
key
][
"type"
]
=
list
(
types
)[
0
]
elif
types
.
issubset
([
"int"
,
"float"
]):
customized
[
key
][
"type"
]
=
"float"
else
:
customized
[
key
][
"type"
]
=
"mixed"
return
customized
def
_organize_customized_item
(
self
,
customized
,
offset_result
,
obj_name
):
"""Organize customized item."""
obj
=
getattr
(
offset_result
,
obj_name
)
require
=
bool
(
obj_name
==
"metric"
)
if
obj
and
isinstance
(
obj
,
dict
):
for
key
,
value
in
obj
.
items
():
label
=
f
'
{
obj_name
}
/
{
key
}
'
current_type
=
type
(
value
).
__name__
if
customized
.
get
(
label
)
is
None
:
customized
[
label
]
=
dict
()
customized
[
label
][
"label"
]
=
label
# user defined info is not displayed by default
customized
[
label
][
"required"
]
=
require
customized
[
label
][
"type"
]
=
set
()
customized
[
label
][
"type"
].
add
(
current_type
)
def
_get_lineage_types
(
self
,
lineage_type_param
):
"""
Get lineage types.
...
...
tests/ut/lineagemgr/querier/event_data.py
浏览文件 @
32cea0e7
...
...
@@ -204,6 +204,12 @@ CUSTOMIZED_1 = {
'metric/mse'
:
{
'label'
:
'metric/mse'
,
'required'
:
True
,
'type'
:
'float'
}
}
CUSTOMIZED_2
=
{
'metric/accuracy'
:
{
'label'
:
'metric/accuracy'
,
'required'
:
True
,
'type'
:
'mixed'
},
'metric/mae'
:
{
'label'
:
'metric/mae'
,
'required'
:
True
,
'type'
:
'float'
},
'metric/mse'
:
{
'label'
:
'metric/mse'
,
'required'
:
True
,
'type'
:
'float'
}
}
METRIC_1
=
{
'accuracy'
:
1.0000002
,
'mae'
:
2.00000002
,
...
...
tests/ut/lineagemgr/querier/test_querier.py
浏览文件 @
32cea0e7
...
...
@@ -463,7 +463,7 @@ class TestQuerier(TestCase):
def
test_filter_summary_lineage_success_4
(
self
):
"""Test the success of filter_summary_lineage."""
expected_result
=
{
'customized'
:
event_data
.
CUSTOMIZED_
0
,
'customized'
:
event_data
.
CUSTOMIZED_
2
,
'object'
:
[
LINEAGE_FILTRATION_0
,
LINEAGE_FILTRATION_1
,
...
...
@@ -500,7 +500,7 @@ class TestQuerier(TestCase):
'sorted_type'
:
'ascending'
}
expected_result
=
{
'customized'
:
event_data
.
CUSTOMIZED_
0
,
'customized'
:
event_data
.
CUSTOMIZED_
2
,
'object'
:
[
LINEAGE_FILTRATION_0
,
LINEAGE_FILTRATION_5
,
...
...
@@ -522,7 +522,7 @@ class TestQuerier(TestCase):
'sorted_type'
:
'descending'
}
expected_result
=
{
'customized'
:
event_data
.
CUSTOMIZED_
1
,
'customized'
:
event_data
.
CUSTOMIZED_
2
,
'object'
:
[
LINEAGE_FILTRATION_6
,
LINEAGE_FILTRATION_4
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录