提交 b2585f61 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed bug when reading config options of the form obj.subobj (now using only…

Fixed bug when reading config options of the form obj.subobj (now using only full name instead of name)
上级 06ac1385
...@@ -108,7 +108,6 @@ def AddConfigVar(name, doc, thing, cls=TheanoConfigParser): ...@@ -108,7 +108,6 @@ def AddConfigVar(name, doc, thing, cls=TheanoConfigParser):
setattr(cls, parts[0], SubObj) setattr(cls, parts[0], SubObj)
AddConfigVar('.'.join(parts[1:]), doc, thing, cls=getattr(cls, parts[0])) AddConfigVar('.'.join(parts[1:]), doc, thing, cls=getattr(cls, parts[0]))
else: else:
thing.name = name
thing.doc = doc thing.doc = doc
thing.__get__() # trigger a read of the value thing.__get__() # trigger a read of the value
setattr(cls, parts[0], thing) setattr(cls, parts[0], thing)
...@@ -121,10 +120,10 @@ class ConfigParam(object): ...@@ -121,10 +120,10 @@ class ConfigParam(object):
# there is a name attribute too, but it is set by AddConfigVar # there is a name attribute too, but it is set by AddConfigVar
def __get__(self, *args): def __get__(self, *args):
#print "GETTING PARAM", self.name, self, args #print "GETTING PARAM", self.fullname, self, args
if not hasattr(self, 'val'): if not hasattr(self, 'val'):
try: try:
val_str = fetch_val_for_key(self.name) val_str = fetch_val_for_key(self.fullname)
except KeyError: except KeyError:
val_str = self.default val_str = self.default
self.__set__(None, val_str) self.__set__(None, val_str)
...@@ -132,7 +131,7 @@ class ConfigParam(object): ...@@ -132,7 +131,7 @@ class ConfigParam(object):
return self.val return self.val
def __set__(self, cls, val): def __set__(self, cls, val):
#print "SETTING PARAM", self.name,(cls), val #print "SETTING PARAM", self.fullname,(cls), val
if self.filter: if self.filter:
self.val = self.filter(val) self.val = self.filter(val)
else: else:
...@@ -149,7 +148,7 @@ class EnumStr(ConfigParam): ...@@ -149,7 +148,7 @@ class EnumStr(ConfigParam):
return val return val
else: else:
raise ValueError('Invalid value (%s) for configuration variable "%s". Legal options are %s' raise ValueError('Invalid value (%s) for configuration variable "%s". Legal options are %s'
% (val, self.name, self.all), val) % (val, self.fullname, self.all), val)
super(EnumStr, self).__init__(default, filter) super(EnumStr, self).__init__(default, filter)
def __str__(self): def __str__(self):
...@@ -165,7 +164,7 @@ class TypedParam(ConfigParam): ...@@ -165,7 +164,7 @@ class TypedParam(ConfigParam):
return casted_val return casted_val
else: else:
raise ValueError('Invalid value (%s) for configuration variable "%s".' raise ValueError('Invalid value (%s) for configuration variable "%s".'
% (val, self.name), val) % (val, self.fullname), val)
return casted_val return casted_val
super(TypedParam, self).__init__(default, filter) super(TypedParam, self).__init__(default, filter)
def __str__(self): def __str__(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论