lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
410 stars 51 forks source link

Parsing Multiple Instances with List Attribute Throws Error #1

Closed lebrice closed 4 years ago

lebrice commented 4 years ago

Describe the bug When parsing multiple instances, each of them having a List attribute with a default value, there shouldn't be an error message, each instance should instead get the default list.

To Reproduce Steps to reproduce the behavior:

$ python examples/list_example.py 
Traceback (most recent call last):
  File "examples/list_example.py", line 22, in <module>
    cnn_stack = CNNStack.from_args_multiple(args, 2)
  File "/home/fabrice/Source/SimpleParsing/simple_parsing/parsing.py", line 207, in from_args_multiple
    f"The field '{field_name}' contains {len(field_values)} values, but either 1 or {num_instances_to_parse} values were expected.")
simple_parsing.parsing.InconsistentArgumentError: The field 'kernel_sizes' contains 3 values, but either 1 or 2 values were expected.

Expected behavior

[
CNNStack(name='stack', num_layers=3, kernel_sizes=[7,5,5], num_filters=[32, 64, 64]), CNNStack(name='stack', num_layers=3, kernel_sizes=[7,5,5], num_filters=[32, 64, 64])
]