Closed idoby closed 2 years ago
The use case is somewhat esoteric, I admit, but this is a feature that is available in argparse (and therefore SP) add_argument, so now it can be used with add_arguments as well.
I'm combining configs from multiple sources, so I need to know exactly what was specified on the command line, since the command line is neither the top priority or lowest priority source I have. This way I can enable specifying each part of the dataclass from a different source and assemble the DC at the end of the entire process.
It sounds complicated but it makes keeping track of my ML experiments super easy.
(It also affects whether the config MUST be specified on the cmdline, help text etc)
I want to test it a little bit more with nested DCs before merging this
OK seems to work fine. @lebrice I wrote a small hack when dealing with the boolean test cases there, is there a better way to accomplish this?
@lebrice I'm pretty happy with this now, I'd appreciate your review.
add a suppressed dataclass using
add_arguments
, as well as another dataclass with a non-suppressed default usingadd_arguments
.a test for conflicts between two such argument groups (i.e. doing
parser.add_arguments(SomeClass, "foo", default=argparse.SUPPRESS)
, followed byparser.add_arguments(SomeClass, "bar")
.
Rebased onto master and added these tests. No bugs seem to have emerged this time.
We can have a zoom call and I'll show you :)
Interesting! Can you give me an example use-case for this? And how is this different than just parsing the class and then using
dataclasses.asdict
on the result?