lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
399 stars 49 forks source link

Setting the attributes of a default config in subgroups #161

Closed saleml closed 1 year ago

saleml commented 2 years ago

Describe the bug Not sure whether it's a bug, or it's expected:

After specifying the default config in a subgroups, changing the inner attributes of the default configuration requires prior specification within the subgroups.

To Reproduce The same code in the example provided in subgroups.

$ python issue.py --model model_a --model.lr 1e-2
Config(model=ModelAConfig(lr=0.01, optimizer='Adam', betas=(0.9, 0.999)), dataset=Dataset2Config(data_dir='data/bar', bar=1.2))
$ python issue.py --model.lr 1e-2. % I was expecting this to work given that both model configs have `lr` attribute
Config(model=ModelAConfig(lr=0.0003, optimizer='Adam', betas=(0.9, 0.999)), dataset=Dataset2Config(data_dir='data/bar', bar=1.2))
$ python issue.py --model model_a --model.betas 0. 1.
Config(model=ModelAConfig(lr=0.0003, optimizer='Adam', betas=(0.0, 1.0)), dataset=Dataset2Config(data_dir='data/bar', bar=1.2))
$ python issue.py --model.betas 0. 1. % ModelA being the default, I was expecting this two work
Config(model=ModelAConfig(lr=0.0003, optimizer='Adam', betas=(0.9, 0.999)), dataset=Dataset2Config(data_dir='data/bar', bar=1.2))

Desktop (please complete the following information):

lebrice commented 2 years ago

Nice catch! This new subgroups feature needs a bit more testing. Thanks for pointing this out!