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
I'm currently using hydra in combination with TensorDictModule and am running into TypeErrors when building modules because the underlying config uses container subclasses rather than the base class.
$ python app.py
ValueError: out_keys must be of type list, str or tuples of str.
Proposed solution
Replace all types in tensordict/nn/common.py with their collections.abc counterpart (which is the python recommendation). For example, change
# tensordict/nn/common.py#L928ifisinstance(in_keys, dict):
# write the kwargs and create a list instead_in_keys= []
self._kwargs= []
forkey, valueinin_keys.items():
self._kwargs.append(value)
_in_keys.append(key)
in_keys=_in_keyselse:
ifisinstance(in_keys, (str, tuple)):
in_keys= [in_keys]
elifnotisinstance(in_keys, list):
raiseValueError(self._IN_KEY_ERR)
self._kwargs=None
to
ifisinstance(in_keys, collections.abc.Mapping):
# write the kwargs and create a list instead_in_keys= []
self._kwargs= []
forkey, valueinin_keys.items():
self._kwargs.append(value)
_in_keys.append(key)
in_keys=_in_keyselse:
ifisinstance(in_keys, (str, tuple)):
in_keys= [in_keys]
elifnotisinstance(in_keys, collections.abc.MutableSequence): # possibly even the more general `Iterable`raiseValueError(self._IN_KEY_ERR)
self._kwargs=None
I don't think this is critical as it's not even a "bug" perse and is easy to get around, but it would be a nice QOL change. Thanks as always!
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm currently using
hydra
in combination withTensorDictModule
and am running intoTypeErrors
when building modules because the underlying config uses container subclasses rather than the base class.Example
My
hydra
config looks like this:which can be parsed in python like so:
but running this script gives a
ValueError
:$ python app.py ValueError: out_keys must be of type list, str or tuples of str.
Proposed solution
Replace all types in
tensordict/nn/common.py
with theircollections.abc
counterpart (which is the python recommendation). For example, changeto
I don't think this is critical as it's not even a "bug" perse and is easy to get around, but it would be a nice QOL change. Thanks as always!
The text was updated successfully, but these errors were encountered: