easy-configer logo

About this project

🚧 TODO list :

  1. Release known issue area in v2.5.6 and hot-fix in v2.6.

  2. Tag v2.6 as stable version.

  3. Next version v3.0 is under development, stateless interface will be introduced as one of new features

  4. Nested argument intepolation may be one of features in v3.0

  5. You can preview the v3.0 prototype of codebase under ./dev folder

🐞 Known issues :

  1. allow_overwrite flag also allow you overwrite the entire section by a config value, most of case it should not a expected behavior (pitfall)

  2. Commendline argument CAN NOT update the arguments in sub_config (bug)


Preface βœ¨οƒ

easy_configer version : 2.5.6

Configeruating the program in an easy-way

I’m willing to provide a light-weight solution for configurating your python program. Hope this repository make every user control their large project with easier ~ ~

Introduction πŸ“οƒ

πŸ™‹β€β™‚οΈ Why choice easy_configer ?

With the python project go into large-scale, a lot of argument will be required to control the complex business logic, user may need a simple way to load configurations through a file eventually. Their exists various package cover part of function and offer some solution to tackle the mentioned problem.

Unfortunately, I can not find a solution for load & use the argument in simple manner at least. Instead, most of the config-tools seems only works for the specific goal, then cause the code more longer and hard to read.

For example :

## ConfigParser
import ConfigParser
Config = ConfigParser.ConfigParser()
Config.read("c:\\tomorrow.ini")
# get arg via method
Config.get(section, option)
# or get arg with converter
int(Config['lucky_num'])

## Argparse
import argparse
parse = argparse.ArgumentParser("description string")
parse.add_argument("--lucky_num", type=int)
...
args = parser.parse_args()
args.lucky_num

## Omegaconf
from omegaconf import OmegaConf
conf = OmegaConf.load('source/example.yaml')
conf.player.height

Except omegaconf, most of config tools have much redundant syntax to load and access config arguments. However, omegaconf also have several draw backs :

  1. Too much dependencies (version competible may become issue!)

  2. Dynamic config loading system is hard to trace (which config overwrite my default setup ?)

  3. Non-native container (it apply Mappable object, so need to apply to_container for further convertion)

That leverage me to package my solution for solving those issue. easy_configer have several advantages :

  1. Zero-dependency!! (except you want to convert easy_configer to other config tools instance)

  2. Flexible apply allow_overwrite=False, you can easily detect the overwritted arguments..

  3. Our container inherit pure python dict! Most of dict methods are also online ~

My solution also cover the following attributes :

  1. Hierachical section config (nested dict-like config)

  2. Accept multiple config file in dynamic loading manner (similar with omegaconf)

  3. Support customized class (initialized by list or keyword arguments)

  4. Commend-line add/update declared arguments/sections (even in hierachical section)

  5. Support the absl style FLAGS functionality (declare once, use anywhere)

And, of course the following attribute will also be supported :

  • dot-access of any arguments (even in nested dictionary)

  • inline comment β€˜#’, now you can write comment in everyline ~

  • support config argument interpolation (even in nested dictionary)!

  • support config conversion, feel free to use easy_config or the other config tools (omegaconf, argparse, …, etc.)

  • support omegaconf-like dynamic config loading system ~