提交 1c90389e authored 作者: Pascal Lamblin's avatar 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
......@@ -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 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():
rval = [os.path.expanduser(s) for s in os.getenv('THEANORC', '~/.theanorc').split(':')]
rval.reverse()
print "THEANORC", rval
return rval
theano_cfg = ConfigParser.SafeConfigParser()
theano_cfg.read(config_files_from_theanorc())
......@@ -43,13 +44,14 @@ def fetch_val_for_key(key):
A successful search returs a string value.
An unsuccessful search raises a KeyError
The priority order is:
The (decreasing) priority order is:
- THEANO_FLAGS
- ~./theanorc
"""
# first try to find it in the FLAGS
rval = None
for name_val in THEANO_FLAGS.split(','):
if not name_val:
continue
......@@ -60,7 +62,12 @@ def fetch_val_for_key(key):
name, val = name_val_tuple
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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论