Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1c90389e
提交
1c90389e
authored
1月 28, 2010
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
THEANO_FLAGS and THEANORC environment variables are now right-dominant…
THEANO_FLAGS and THEANORC environment variables are now right-dominant (right-most definitions have precedence over the ones on their left)
上级
5fba2f7c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
9 行删除
+16
-9
configparser.py
theano/configparser.py
+16
-9
没有找到文件。
theano/configparser.py
浏览文件 @
1c90389e
...
@@ -14,11 +14,12 @@ THEANO_FLAGS=os.getenv("THEANO_FLAGS","")
...
@@ -14,11 +14,12 @@ THEANO_FLAGS=os.getenv("THEANO_FLAGS","")
# [section.]option[=value] entries. If the section part is omited, their should be only one
# [section.]option[=value] entries. If the section part is omited, their should be only one
# section with that contain the gived option.
# section with that contain the gived option.
# THEANORC=~/.theanorc:~lisa/.theanorc
# THEANORC can contain a colon-delimited list of config files, like
# THEANORC=~lisa/.theanorc:~/.theanorc
# In that case, definitions in files on the right (here, ~/.theanorc) have
# precedence over those in files on the left.
def
config_files_from_theanorc
():
def
config_files_from_theanorc
():
rval
=
[
os
.
path
.
expanduser
(
s
)
for
s
in
os
.
getenv
(
'THEANORC'
,
'~/.theanorc'
)
.
split
(
':'
)]
rval
=
[
os
.
path
.
expanduser
(
s
)
for
s
in
os
.
getenv
(
'THEANORC'
,
'~/.theanorc'
)
.
split
(
':'
)]
rval
.
reverse
()
print
"THEANORC"
,
rval
return
rval
return
rval
theano_cfg
=
ConfigParser
.
SafeConfigParser
()
theano_cfg
=
ConfigParser
.
SafeConfigParser
()
theano_cfg
.
read
(
config_files_from_theanorc
())
theano_cfg
.
read
(
config_files_from_theanorc
())
...
@@ -42,14 +43,15 @@ def fetch_val_for_key(key):
...
@@ -42,14 +43,15 @@ def fetch_val_for_key(key):
"""Return the overriding config value for a key.
"""Return the overriding config value for a key.
A successful search returs a string value.
A successful search returs a string value.
An unsuccessful search raises a KeyError
An unsuccessful search raises a KeyError
The priority order is:
The
(decreasing)
priority order is:
- THEANO_FLAGS
- THEANO_FLAGS
- ~./theanorc
- ~./theanorc
"""
"""
# first try to find it in the FLAGS
# first try to find it in the FLAGS
rval
=
None
for
name_val
in
THEANO_FLAGS
.
split
(
','
):
for
name_val
in
THEANO_FLAGS
.
split
(
','
):
if
not
name_val
:
if
not
name_val
:
continue
continue
...
@@ -60,7 +62,12 @@ def fetch_val_for_key(key):
...
@@ -60,7 +62,12 @@ def fetch_val_for_key(key):
name
,
val
=
name_val_tuple
name
,
val
=
name_val_tuple
if
name
==
key
:
if
name
==
key
:
return
val
# rval might be overriden by a later definition in THEANO_FLAGS
rval
=
val
# If an rval is found, it should be a string
if
rval
is
not
None
:
return
rval
# next try to find it in the config file
# next try to find it in the config file
...
@@ -77,7 +84,7 @@ def fetch_val_for_key(key):
...
@@ -77,7 +84,7 @@ def fetch_val_for_key(key):
return
theano_cfg
.
get
(
section
,
option
)
return
theano_cfg
.
get
(
section
,
option
)
except
(
ConfigParser
.
NoOptionError
,
ConfigParser
.
NoSectionError
):
except
(
ConfigParser
.
NoOptionError
,
ConfigParser
.
NoSectionError
):
raise
KeyError
(
key
)
raise
KeyError
(
key
)
class
TheanoConfigParser
(
object
):
class
TheanoConfigParser
(
object
):
#properties are installed by AddConfigVar
#properties are installed by AddConfigVar
...
@@ -143,7 +150,7 @@ class ConfigParam(object):
...
@@ -143,7 +150,7 @@ class ConfigParam(object):
self
.
val
=
val
self
.
val
=
val
deleter
=
None
deleter
=
None
class
EnumStr
(
ConfigParam
):
class
EnumStr
(
ConfigParam
):
def
__init__
(
self
,
default
,
*
options
):
def
__init__
(
self
,
default
,
*
options
):
self
.
default
=
default
self
.
default
=
default
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论