Enable multiple arguments to config_path #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
For a project I'm working on currently it is helpful to separate the config into two different parts that can then be combined on the fly without creating a merged config.
E.g. having a few configs for the generative part of a gan and the discriminative part, and then being able to mix and match when starting a run without creating a shared config beforehand.
Changes
To allow this I have modified the
ArgumentParser
class. Theconfig_path
is now a list of configs to load instead of a single file. In the command line it can be called with--config_path path1 path2 ...
which is then appended to the previous configs given as a default for the parser. The priorities are then ordered left to right, the first config has the least priority and the last config has the most priority. E.g. put a general config with all keys as the first argument or pass it to the Parser and a specific config to overwrite some values at the end.As previous by default configs passed via the command line overwrite the configs passed as arguments inside the python code. I've also added the option to disable that behavior and extend the list instead.
All changes should be backwards compatible by default and all tests continue to pass.
I have also added some tests to check that multiple configs can be loaded and that the order is indeed as described.