Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
PaddleRec
提交
a12fe9da
P
PaddleRec
项目概览
BaiXuePrincess
/
PaddleRec
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleRec
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a12fe9da
编写于
6月 10, 2020
作者:
T
tangwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix windows adapter
上级
cc3d47cf
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
20 addition
and
32 deletion
+20
-32
core/factory.py
core/factory.py
+1
-2
core/reader.py
core/reader.py
+2
-4
core/utils/envs.py
core/utils/envs.py
+16
-10
doc/design.md
doc/design.md
+1
-2
run.py
run.py
+0
-14
未找到文件。
core/factory.py
浏览文件 @
a12fe9da
...
...
@@ -59,8 +59,7 @@ class TrainerFactory(object):
@
staticmethod
def
create
(
config
):
_config
=
envs
.
load_yaml
(
config
)
envs
.
set_global_envs
(
_config
)
envs
.
update_workspace
()
envs
.
set_global_envs
(
_config
,
True
)
trainer
=
TrainerFactory
.
_build_trainer
(
config
)
return
trainer
...
...
core/reader.py
浏览文件 @
a12fe9da
...
...
@@ -27,8 +27,7 @@ class ReaderBase(dg.MultiSlotDataGenerator):
def
__init__
(
self
,
config
):
dg
.
MultiSlotDataGenerator
.
__init__
(
self
)
_config
=
envs
.
load_yaml
(
config
)
envs
.
set_global_envs
(
_config
)
envs
.
update_workspace
()
envs
.
set_global_envs
(
_config
,
True
)
@
abc
.
abstractmethod
def
init
(
self
):
...
...
@@ -46,8 +45,7 @@ class SlotReader(dg.MultiSlotDataGenerator):
def
__init__
(
self
,
config
):
dg
.
MultiSlotDataGenerator
.
__init__
(
self
)
_config
=
envs
.
load_yaml
(
config
)
envs
.
set_global_envs
(
_config
)
envs
.
update_workspace
()
envs
.
set_global_envs
(
_config
,
True
)
def
init
(
self
,
sparse_slots
,
dense_slots
,
padding
=
0
):
from
operator
import
mul
...
...
core/utils/envs.py
浏览文件 @
a12fe9da
...
...
@@ -68,7 +68,7 @@ def get_fleet_mode():
return
fleet_mode
def
set_global_envs
(
envs
):
def
set_global_envs
(
envs
,
adapter
):
assert
isinstance
(
envs
,
dict
)
def
fatten_env_namespace
(
namespace_nests
,
local_envs
):
...
...
@@ -92,6 +92,10 @@ def set_global_envs(envs):
fatten_env_namespace
([],
envs
)
if
adapter
:
workspace_adapter
()
os_path_adapter
()
def
get_global_env
(
env_name
,
default_value
=
None
,
namespace
=
None
):
"""
...
...
@@ -106,7 +110,7 @@ def get_global_envs():
return
global_envs
def
pa
th
_adapter
(
path
):
def
pa
ddlerec
_adapter
(
path
):
if
path
.
startswith
(
"paddlerec."
):
package
=
get_runtime_environ
(
"PACKAGE_BASE"
)
l_p
=
path
.
split
(
"paddlerec."
)[
1
].
replace
(
"."
,
"/"
)
...
...
@@ -115,23 +119,25 @@ def path_adapter(path):
return
path
def
windows_path_converter
(
path
):
def
os_path_adapter
():
for
name
,
value
in
global_envs
.
items
():
if
isinstance
(
value
,
str
):
if
get_platform
()
==
"WINDOWS"
:
return
path
.
replace
(
"/"
,
"
\\
"
)
value
=
value
.
replace
(
"/"
,
"
\\
"
)
else
:
return
path
.
replace
(
"
\\
"
,
"/"
)
value
=
value
.
replace
(
"
\\
"
,
"/"
)
global_envs
[
name
]
=
value
def
update_workspace
():
def
workspace_adapter
():
workspace
=
global_envs
.
get
(
"workspace"
)
if
not
workspace
:
return
workspace
=
pa
th
_adapter
(
workspace
)
workspace
=
pa
ddlerec
_adapter
(
workspace
)
for
name
,
value
in
global_envs
.
items
():
if
isinstance
(
value
,
str
):
value
=
value
.
replace
(
"{workspace}"
,
workspace
)
value
=
windows_path_converter
(
value
)
global_envs
[
name
]
=
value
...
...
doc/design.md
浏览文件 @
a12fe9da
...
...
@@ -197,8 +197,7 @@ class Reader(dg.MultiSlotDataGenerator):
def
__init__
(
self
,
config
):
dg
.
MultiSlotDataGenerator
.
__init__
(
self
)
_config
=
envs
.
load_yaml
(
config
)
envs
.
set_global_envs
(
_config
)
envs
.
update_workspace
()
envs
.
set_global_envs
(
_config
,
True
)
@
abc
.
abstractmethod
def
init
(
self
):
...
...
run.py
浏览文件 @
a12fe9da
...
...
@@ -260,18 +260,6 @@ def single_infer_engine(args):
def
cluster_engine
(
args
):
def
update_workspace
(
cluster_envs
):
workspace
=
cluster_envs
.
get
(
"engine_workspace"
,
None
)
if
not
workspace
:
return
path
=
envs
.
path_adapter
(
workspace
)
for
name
,
value
in
cluster_envs
.
items
():
if
isinstance
(
value
,
str
):
value
=
value
.
replace
(
"{workspace}"
,
path
)
value
=
envs
.
windows_path_converter
(
value
)
cluster_envs
[
name
]
=
value
def
master
():
role
=
"MASTER"
from
paddlerec.core.engine.cluster.cluster
import
ClusterEngine
...
...
@@ -280,8 +268,6 @@ def cluster_engine(args):
flattens
[
"engine_role"
]
=
role
flattens
[
"engine_run_config"
]
=
args
.
model
flattens
[
"engine_temp_path"
]
=
tempfile
.
mkdtemp
()
update_workspace
(
flattens
)
envs
.
set_runtime_environs
(
flattens
)
print
(
envs
.
pretty_print_envs
(
flattens
,
(
"Submit Envs"
,
"Value"
)))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录