You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the new version 4.10.0, providing only init_args in a yaml config for a subclass is possible when class_path is set in some other config. Unfortunately, when I pass a model config using --model and then in a later config using --config additional init_args like so:
model:
init_args:
batch_size: 32
then this dictionary overwrites the existing, previously loaded model config completely. This means that there's not class_path entry anymore and the CLI crashes.
I tracked it down to the update function of class Namespace:
defupdate(self, value: Union['Namespace', Any], key: Optional[str] =None, only_unset: bool=False) ->'Namespace':
"""Sets or replaces all items from the given nested namespace. Args: value: A namespace to update multiple values or other type to set in a single key. key: Branch key where to set the value. Required if value is not namespace. only_unset: Whether to only set the value if not set in namespace. """ifnotisinstance(value, Namespace):
ifnotkey:
raiseKeyError('Key is required if value not a Namespace.')
ifnotonly_unsetorkeynotinself:
self[key] =valueelse:
prefix=key+'.'ifkeyelse''forkey, valinvalue.items():
ifnotonly_unsetorprefix+keynotinself:
self[prefix+key] =valreturnself
value is not a Namespace in case of the update dict coming from the second config which then goes into the first part of the if statment: if not isinstance(value, Namespace):. This is the part where it simply overwrites the existing and properly loaded namespace of the model.
Output: app: error: Configuration check failed :: Parser key "model": Type <class 'model.ModelBaseClass'> expects: a class path (str); or a dict with a class_path entry; or a dict with init_args (if class path given previously). Got "{'init_args': {'batch_size': 5}}".
The text was updated successfully, but these errors were encountered:
🐛 Bug report
With the new version 4.10.0, providing only
init_args
in a yaml config for a subclass is possible whenclass_path
is set in some other config. Unfortunately, when I pass a model config using--model
and then in a later config using--config
additionalinit_args
like so:then this dictionary overwrites the existing, previously loaded model config completely. This means that there's not
class_path
entry anymore and the CLI crashes.I tracked it down to the update function of class
Namespace
:value
is not aNamespace
in case of the update dict coming from the second config which then goes into the first part of theif
statment:if not isinstance(value, Namespace):
. This is the part where it simply overwrites the existing and properly loaded namespace of the model.To reproduce
Output:
app: error: Configuration check failed :: Parser key "model": Type <class 'model.ModelBaseClass'> expects: a class path (str); or a dict with a class_path entry; or a dict with init_args (if class path given previously). Got "{'init_args': {'batch_size': 5}}".
The text was updated successfully, but these errors were encountered: