Configuration

Configuration#

This package provides a submodule config to help managing the parameters of a project that is:

  • strict: parameters are defined beforehand. Any unknown or invalid parameter will raise errors

  • structured: parameters can be organized in (nested) sections

  • documented: docstrings of parameters are re-used in configuration files, command line help, and static documentation via a plugin for Sphinx

The parameters values can be recovered from configuration files (TOML, YAML, Python files, or JSON), and from the command line as well.

It requires to specify the parameters in python code: their type, default value, help string, etc. It relies on the traitlets package to do this.

Note

The main difference with the “vanilla” traitlets package is that we allow nested configurations. We replace traitlets.config.Configurable by our subclass Section and use our own ApplicationBase class.

The help string of each trait is used to generate command line help, fully documented configuration files, and the autodoc_trait plugin integrates it in sphinx documentations.