Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
24b18875
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看板
提交
24b18875
编写于
9月 08, 2020
作者:
S
shenghong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add the function of get_lineage_table
上级
61185d99
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
1 deletion
+49
-1
mindinsight/lineagemgr/model.py
mindinsight/lineagemgr/model.py
+47
-0
requirements.txt
requirements.txt
+2
-1
未找到文件。
mindinsight/lineagemgr/model.py
浏览文件 @
24b18875
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# ============================================================================
# ============================================================================
"""This file is used to define the model lineage python api."""
"""This file is used to define the model lineage python api."""
import
os
import
os
import
pandas
as
pd
from
mindinsight.lineagemgr.common.exceptions.exceptions
import
LineageParamValueError
,
\
from
mindinsight.lineagemgr.common.exceptions.exceptions
import
LineageParamValueError
,
\
LineageQuerySummaryDataError
,
LineageParamSummaryPathError
,
\
LineageQuerySummaryDataError
,
LineageParamSummaryPathError
,
\
...
@@ -28,6 +29,9 @@ from mindinsight.lineagemgr.lineage_parser import LineageParser, LineageOrganize
...
@@ -28,6 +29,9 @@ from mindinsight.lineagemgr.lineage_parser import LineageParser, LineageOrganize
from
mindinsight.lineagemgr.querier.querier
import
Querier
from
mindinsight.lineagemgr.querier.querier
import
Querier
from
mindinsight.utils.exceptions
import
MindInsightException
from
mindinsight.utils.exceptions
import
MindInsightException
_METRIC_PREFIX
=
"[M]"
_USER_DEFINED_PREFIX
=
"[U]"
def
get_summary_lineage
(
data_manager
=
None
,
summary_dir
=
None
,
keys
=
None
):
def
get_summary_lineage
(
data_manager
=
None
,
summary_dir
=
None
,
keys
=
None
):
"""
"""
...
@@ -183,3 +187,46 @@ def _convert_relative_path_to_abspath(summary_base_dir, search_condition):
...
@@ -183,3 +187,46 @@ def _convert_relative_path_to_abspath(summary_base_dir, search_condition):
search_condition
.
get
(
'summary_dir'
)[
'eq'
]
=
abs_dir
search_condition
.
get
(
'summary_dir'
)[
'eq'
]
=
abs_dir
return
search_condition
return
search_condition
def
get_lineage_table
(
data_manager
):
"""Get lineage data in a table from data manager."""
lineages
=
filter_summary_lineage
(
data_manager
=
data_manager
)
lineage_objects
=
lineages
.
get
(
"object"
,
[])
cnt_lineages
=
len
(
lineage_objects
)
metric_prefix
=
_METRIC_PREFIX
user_defined_prefix
=
_USER_DEFINED_PREFIX
# Step 1, get column names
column_names
=
set
()
for
lineage
in
lineage_objects
:
model_lineage
=
lineage
.
get
(
"model_lineage"
,
{})
metric
=
model_lineage
.
get
(
"metric"
,
{})
metric_names
=
tuple
(
'{}{}'
.
format
(
metric_prefix
,
key
)
for
key
in
metric
.
keys
())
user_defined
=
model_lineage
.
get
(
"user_defined"
,
{})
user_defined_names
=
tuple
(
'{}{}'
.
format
(
metric_prefix
,
key
)
for
key
in
user_defined
.
keys
())
model_lineage_temp
=
list
(
model_lineage
.
keys
())
for
key
in
model_lineage_temp
:
if
key
in
[
"metric"
,
"user_defined"
]:
model_lineage_temp
.
remove
(
key
)
column_names
.
update
(
model_lineage_temp
)
column_names
.
update
(
metric_names
)
column_names
.
update
(
user_defined_names
)
# Step 2, collect data
column_data
=
{
key
:
[
None
]
*
cnt_lineages
for
key
in
column_names
}
for
ind
,
lineage
in
enumerate
(
lineage_objects
):
model_lineage
=
lineage
.
get
(
"model_lineage"
,
{})
metric
=
model_lineage
.
pop
(
"metric"
,
{})
metric_content
=
{
'{}{}'
.
format
(
metric_prefix
,
key
):
val
for
key
,
val
in
metric
.
items
()
}
user_defined
=
model_lineage
.
pop
(
"user_defined"
,
{})
user_defined_content
=
{
'{}{}'
.
format
(
user_defined_prefix
,
key
):
val
for
key
,
val
in
user_defined
.
items
()
}
final_content
=
{}
final_content
.
update
(
model_lineage
)
final_content
.
update
(
metric_content
)
final_content
.
update
(
user_defined_content
)
for
key
,
val
in
final_content
.
items
():
column_data
[
key
][
ind
]
=
val
return
pd
.
DataFrame
(
column_data
)
requirements.txt
浏览文件 @
24b18875
...
@@ -13,4 +13,5 @@ protobuf>=3.8.0
...
@@ -13,4 +13,5 @@ protobuf>=3.8.0
psutil
>=5.6.1
psutil
>=5.6.1
six
>=1.12.0
six
>=1.12.0
Werkzeug
>=1.0.0
Werkzeug
>=1.0.0
tabulate
>=0.8.6
tabulate
>=0.8.6
\ No newline at end of file
pandas
>=1.0.4
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录