jsonargparse icon indicating copy to clipboard operation
jsonargparse copied to clipboard

Support TOML configuration file format

Open haoxiangsnr opened this issue 2 years ago • 1 comments

🚀 Feature request

Hi, Thanks for this tool.

The Python language steering council has accepted PEP 680, which adds a TOML parser to the Python standard library. I was wondering if you want to add the support of the configuration file in TOML format.

Motivation

TOML (Tom's Obvious Minimal Language) is a configuration file format that is easy to read and write. I have used configuration files in TOML format in my deep learning projects for a long time. It looks like TOML has a stricter definition than YAML and is more flexible than JSON. I knew that some official projects of the Python community use configuration in TOML format, e.g., pyproject.toml in pip.

haoxiangsnr avatar Jan 05 '23 06:01 haoxiangsnr

Thank you for the interest. Since tomllib was added in python 3.11, lately I have though about adding the support for it in jsonargparse. Some comments:

  • Current versions of jsonargparse has custom-loaders, which means that TOML support can already be added by whoever wants it. This does no mean that it would be later added to jsonargparse for more convenience.
  • Even though tomllib is now in the standard library, it only supports parsing (load and loads). For TOML to make sense in jsonargparse, it would be necessary to output TOML (e.g. so that --print_config works). Therefore, TOML support requires adding dependencies, and would only be an optional feature.
  • If TOML support were to be added, would it be only for python >= 3.11 or for all python versions that jsonargparse supports?
  • I also work on machine learning which is why jsonargparse even though generic, it does have many features useful for it. However, for machine learning very commonly leads to several levels of nesting in YAML, e.g. LightningCLI. My impression has been that with such depth of nesting and use of lists, TOML is much less intuitive than YAML. I have though about TOML support but for simpler use cases.

mauvilsa avatar Jan 05 '23 09:01 mauvilsa