Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bef80f32
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2321
Star
20933
Fork
5424
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
bef80f32
编写于
9月 01, 2022
作者:
R
Roc
提交者:
GitHub
9月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ut tool (#45605)
上级
934171ae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
17 deletion
+24
-17
tools/gen_ut_cmakelists.py
tools/gen_ut_cmakelists.py
+24
-17
未找到文件。
tools/gen_ut_cmakelists.py
浏览文件 @
bef80f32
...
...
@@ -168,6 +168,17 @@ def _process_name(name, curdir):
return
name
def
_norm_dirs
(
dirs
):
# reform all dirs' path as normal absolute path
# abspath() can automatically normalize the path format
norm_dirs
=
[]
for
d
in
dirs
:
d
=
os
.
path
.
abspath
(
d
)
if
d
not
in
norm_dirs
:
norm_dirs
.
append
(
d
)
return
norm_dirs
def
_process_run_type
(
run_type
):
rt
=
run_type
.
strip
()
# completely match one of the strings: 'NIGHTLY', 'EXCLUSIVE', 'CINN', 'DIST', 'GPUPS', 'INFER', 'EXCLUSIVE:NIGHTLY' and 'DIST:NIGHTLY'
...
...
@@ -179,13 +190,14 @@ def _process_run_type(run_type):
class
DistUTPortManager
():
def
__init__
(
self
):
def
__init__
(
self
,
ignore_dirs
=
[]
):
self
.
dist_ut_port
=
21200
self
.
assigned_ports
=
dict
()
self
.
last_test_name
=
""
self
.
last_test_cmake_file
=
""
self
.
no_cmake_dirs
=
[]
self
.
processed_dirs
=
set
()
self
.
ignore_dirs
=
_norm_dirs
(
ignore_dirs
)
def
reset_current_port
(
self
,
port
=
None
):
self
.
dist_ut_port
=
21200
if
port
is
None
else
port
...
...
@@ -251,7 +263,7 @@ class DistUTPortManager():
self
.
last_test_name
=
name
self
.
last_test_cmake_file
=
cmake_file_name
def
parse_assigned_dist_ut_ports
(
self
,
current_work_dir
,
ignores
,
depth
=
0
):
def
parse_assigned_dist_ut_ports
(
self
,
current_work_dir
,
depth
=
0
):
'''
Desc:
get all assigned dist ports to keep port of unmodified test fixed.
...
...
@@ -259,10 +271,9 @@ class DistUTPortManager():
if
current_work_dir
in
self
.
processed_dirs
:
return
# if root(depth==0)
, convert the ignores to abs paths
# if root(depth==0)
if
depth
==
0
:
self
.
processed_dirs
.
clear
()
ignores
=
[
os
.
path
.
abspath
(
i
)
for
i
in
ignores
]
self
.
processed_dirs
.
add
(
current_work_dir
)
contents
=
os
.
listdir
(
current_work_dir
)
...
...
@@ -270,7 +281,7 @@ class DistUTPortManager():
csv
=
cmake_file
.
replace
(
"CMakeLists.txt"
,
'testslist.csv'
)
if
os
.
path
.
isfile
(
csv
)
or
os
.
path
.
isfile
(
cmake_file
):
if
current_work_dir
not
in
ignore
s
:
if
current_work_dir
not
in
self
.
ignore_dir
s
:
if
os
.
path
.
isfile
(
cmake_file
)
and
os
.
path
.
isfile
(
csv
):
self
.
_init_dist_ut_ports_from_cmakefile
(
cmake_file
)
elif
not
os
.
path
.
isfile
(
cmake_file
):
...
...
@@ -281,8 +292,7 @@ class DistUTPortManager():
for
c
in
contents
:
c_path
=
os
.
path
.
join
(
current_work_dir
,
c
)
if
os
.
path
.
isdir
(
c_path
):
self
.
parse_assigned_dist_ut_ports
(
c_path
,
ignores
,
depth
+
1
)
self
.
parse_assigned_dist_ut_ports
(
c_path
,
depth
+
1
)
if
depth
==
0
:
# After all directories are scanned and processed
...
...
@@ -328,19 +338,17 @@ class DistUTPortManager():
class
CMakeGenerator
():
def
__init__
(
self
,
current_dirs
):
def
__init__
(
self
,
current_dirs
,
ignore_dirs
):
self
.
processed_dirs
=
set
()
self
.
port_manager
=
DistUTPortManager
()
self
.
current_dirs
=
current_dirs
self
.
port_manager
=
DistUTPortManager
(
ignore_dirs
)
self
.
current_dirs
=
_norm_dirs
(
current_dirs
)
def
prepare_dist_ut_port
(
self
):
for
c
in
self
.
_find_root_dirs
():
self
.
port_manager
.
parse_assigned_dist_ut_ports
(
c
,
ignores
=
args
.
ignore_cmake_dirs
,
depth
=
0
)
self
.
port_manager
.
parse_assigned_dist_ut_ports
(
c
,
depth
=
0
)
def
parse_csvs
(
self
):
for
c
in
self
.
current_dirs
:
c
=
os
.
path
.
abspath
(
c
)
self
.
_gen_cmakelists
(
c
)
def
_find_root_dirs
(
self
):
...
...
@@ -348,16 +356,15 @@ class CMakeGenerator():
# for each current directory, find its highest ancient directory (at least itself)
# which includes CMakeLists.txt or testslist.csv.txt in the filesys tree
for
c
in
self
.
current_dirs
:
c
=
os
.
path
.
abspath
(
c
)
while
True
:
ppath
=
os
.
path
.
dirname
(
c
)
if
os
.
path
.
abspath
(
ppath
)
==
os
.
path
.
abspath
(
c
)
:
if
ppath
==
c
:
break
cmake
=
os
.
path
.
join
(
ppath
,
"CMakeLists.txt"
)
csv
=
os
.
path
.
join
(
ppath
,
"testslist.csv.txt"
)
if
not
(
os
.
path
.
isfile
(
cmake
)
or
os
.
path
.
isfile
(
csv
)):
break
c
=
os
.
path
.
abspath
(
ppath
)
c
=
ppath
if
c
not
in
root_dirs
:
root_dirs
.
append
(
c
)
return
root_dirs
...
...
@@ -535,6 +542,6 @@ if __name__ == "__main__":
if
len
(
args
.
dirpaths
)
>=
1
:
current_work_dirs
=
current_work_dirs
+
[
d
for
d
in
args
.
dirpaths
]
cmake_generator
=
CMakeGenerator
(
current_work_dirs
)
cmake_generator
=
CMakeGenerator
(
current_work_dirs
,
args
.
ignore_cmake_dirs
)
cmake_generator
.
prepare_dist_ut_port
()
cmake_generator
.
parse_csvs
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录