hb-config is utility for easy to configure your python project especially Deep Learning experiments.
- Do not use any boilerplate code
- Singleton Class (immediately use anywhere)
- Supports formats: .json and .yaml
- Access property using __getattr__ function
Config.TOKEN
- Edit property using __setattr__ function
Config.TOKEN = "{token}"
- every config data's type is dict
using pip
$ pip install hb-config
or clone repository
git clone https://github.com/hb-research/hb-config.git
python setup.py install
- base path : config/
- config3.yml example
project: hb-config
example: true
bot:
in_bot:
test: haha
simple: wow
- Using like dict
- only one difference : Config["project"] -> Config.project
- using get Config.get("project"), Config.get("project", {})
- using set Config.project = "set value"
- Add description with python annotation.
#
>>> from hbconfig import Config
>>> Config("config3")
>>> Config
Read config file name: config3.yml
{
"project": "hb-config",
"example": true,
"bot": {
"in_bot": {
"test": "haha",
"simple": "wow"
}
}
}
>>> Config.bot.in_bot
{
"test": "haha"
"simple": "wow"
}
>>> Config.project
'hb-config'
>>> Config.bot.in_bot.get("simple")
'wow'
>>> Config.bot.in_bot.get("not_exist_key", "default_value")
'default_value'
- The config file does not change.
>>> Config.bot.in_bot
{
"test": "haha"
"simple": "wow"
}
>>> Config.bot.in_bot = "hello"
>>> Config.bot.in_bot
'hello'
- example config
project: hb-config # project name
example: true # is it example?
bot:
in_bot:
test: haha
simple: wow
>>> Config
Read config file name: ./config/config
{
"project": "hb-config",
"example": true,
"bot": {
"in_bot": {
"test": "haha",
"simple": "wow"
}
}
}
>>> Config.description
{'example': 'is it example?', 'project': 'project name'}