pyrallis
pyrallis copied to clipboard
Enable multiple arguments to config_path
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. The config_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.