Closed bayerj closed 2 years ago
Hi Justin,
That's a great question! The yaml
integration is localized to the following parts of pyrallis
pyrallis.dump
function (which uses the general pyrallis.encode
)pyrallis.load
function (which uses the general pyrallis.decode
)config_path
and parse all cmd strings (to ensure a uniform parsing syntax as explained here)I've been thinking about what would be a good way to support other formats as well, but decided to first release the package as it is, and maybe add support in the future.
The thing is that for 1-2 I can always just add additional functions or arguments, the confusing part is the loading mechanism. Say someone wants to pass the following value to pyrallis {1: 2}
, right now pyrallis uses only yaml for parsing strings so
python train.py --int_dict="{1: 2}"
and
int_dict: {1: 2}
would function the same way and would be parsed correctly.
Now, for jsons int keys in dictionaries are not allowed, that would mean that the console mode
python train.py --int_dict="{1: 2}"
should also fail when using jsons (otherwise we are in a confusing situation where it can be loaded from cmd but not from file). So what happens here that the functionally of pyrallis changes when a different format is used, and I want to make sure that there's a way to allow that without confusing users.
I would give it some more thought and would be happy to hear if you have any specific ideas on that matter.
Added an option in MR #7 to globally change the configuration format
pyrallis.set_config_type('json')
# or
pyrallis.set_config_type(pyrallis.ConfigType.JSON)
Still need to review and update docs.
Hello,
Is there a chance to support different configuration formats, e.g. TOML or JSON? I wonder how deeply yaml is integrated.
Best, -Justin
PS: Nice project. :)