Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dongjunlee/hb-config
hb-config: easy to configure your python project especially Deep Learning experiments
https://github.com/dongjunlee/hb-config
config configuration experiment python singleton
Last synced: 6 days ago
JSON representation
hb-config: easy to configure your python project especially Deep Learning experiments
- Host: GitHub
- URL: https://github.com/dongjunlee/hb-config
- Owner: DongjunLee
- License: mit
- Created: 2017-08-26T06:29:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-20T16:39:23.000Z (over 6 years ago)
- Last Synced: 2025-01-20T21:54:25.103Z (10 days ago)
- Topics: config, configuration, experiment, python, singleton
- Language: Python
- Homepage:
- Size: 35.2 KB
- Stars: 21
- Watchers: 2
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# hb-config: easy to configure your python packge
hb-config is utility for easy to configure your python project especially **Deep Learning experiments**.
## Feature
- 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**## Install
using pip
```
$ pip install hb-config
```or clone repository
```
git clone https://github.com/hb-research/hb-config.git
python setup.py install
```## Usage
- base path : config/
- config3.yml example```yml
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. `#`### Load config
```python
>>> 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"
}
}
}
```### Get
```
>>> 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'
```### Set
- The config file does not change.
```
>>> Config.bot.in_bot
{
"test": "haha"
"simple": "wow"
}>>> Config.bot.in_bot = "hello"
>>> Config.bot.in_bot
'hello'```
### Description
- example config
```yml
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'}
```