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 started using the (very cool) feature of linking an argument to a list of subclass objects, as shown in the documentation.
It seems that when the target argument is a list of ParentClass defined as a class property, I cannot set it simply as List[ParentClass]. If I do so, I get an exception. In order for the link to work as expected, I must define the argument as a union of both ParentClass and a list of ParentClass: Union[ParentClass, List[ParentClass]]
In my use case, a single object rather than a list doesn't make sense for the relevant class property, so I would prefer to only allow for the property to be a list.
Interestingly, this problem doesn't happen if I define the argument directly using parser.add_argument, I only get it when I use parser.add_class_arugments.
I started using the (very cool) feature of linking an argument to a list of subclass objects, as shown in the documentation.
It seems that when the target argument is a list of ParentClass defined as a class property, I cannot set it simply as
List[ParentClass]
. If I do so, I get an exception. In order for the link to work as expected, I must define the argument as a union of both ParentClass and a list of ParentClass:Union[ParentClass, List[ParentClass]]
In my use case, a single object rather than a list doesn't make sense for the relevant class property, so I would prefer to only allow for the property to be a list.
Interestingly, this problem doesn't happen if I define the argument directly using parser.add_argument, I only get it when I use parser.add_class_arugments.
Expected behavior
The argument linking should work when List[ParentClass] is defined as a property of a class.
Environment
pip install jsonargparse[all]
): as part of pytorch lightningThe text was updated successfully, but these errors were encountered: