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
so creating an ArgumentParser with default arguments inside parsing (as happens with add_config_path_arg=True) overwrites any custom settings of these.
To Reproduce
Create the program reproduce.py:
importsimple_parsingfromdataclassesimportdataclass@dataclassclassBaz:
arg: int=2@dataclassclassFoo:
baz: Baz=Baz()
if__name__=="__main__":
parser=simple_parsing.ArgumentParser(
add_config_path_arg=True, # setting to False works fineargument_generation_mode=simple_parsing.ArgumentGenerationMode.NESTED,
)
parser.add_arguments(Foo, "foo")
args=parser.parse_args()
and run python reproduce.py --help
Expected behavior
At the very bottom, the argument arg should be accessible via --foo.baz.arg. It should print this:
usage: reproduce.py [-h] [--foo.baz.arg int]options: -h, --help show this help message and exitFoo ['foo']: Foo(baz: __main__.Baz = Baz(arg=2))Baz ['foo.baz']: Baz(arg: int = 2) --foo.baz.arg int (default: 2)
Actual behavior
Prints
usage: reproduce.py [-h] [--config_path Path] [--arg int]options: -h, --help show this help message and exit --config_path Path Path to a config file containing default values to use. (default: None)Foo ['foo']: Foo(baz: __main__.Baz = Baz(arg=2))Baz ['foo.baz']: Baz(arg: int = 2) --arg int (default: 2)
The text was updated successfully, but these errors were encountered:
rhaps0dy
added a commit
to AlignmentResearch/SimpleParsing
that referenced
this issue
Apr 19, 2023
Describe the bug
Creating an
ArgumentParser
sets the values ofso creating an
ArgumentParser
with default arguments inside parsing (as happens withadd_config_path_arg=True
) overwrites any custom settings of these.To Reproduce
Create the program
reproduce.py
:and run
python reproduce.py --help
Expected behavior
At the very bottom, the argument
arg
should be accessible via--foo.baz.arg
. It should print this:Actual behavior
Prints
The text was updated successfully, but these errors were encountered: