# Perfect Config
Manage your configuations in a mechanism similar to `SQLAlchemy`.
## Usage
Install using `pip install perfectconfig`.
Define your configuration classes :
```python
from perfectconfig import GlobalConfig, ConfigProperty, config_store
class SampleServerConfiguration(GlobalConfig):
_name = "server_config"
port = ConfigProperty("port", default=8080)
host = ConfigProperty("host", default="localhost")
name = ConfigProperty("name", default="sample_server")
config_store.track() # Tracks the configuration defined in the file
```
Initialize your store(once initialized this is accessible everywhere):
```python
from perfectconfig import config_store
config_store.initialize("my-org", "my-product", format="yaml", single_file=False)
```
`format` can be `json` or `yaml`. Default is `json`.
`single_file` allows you to control, whether all individual configurations will be stored as separate files, or if they'd be maintained in the same file. In some cases format errors in the configuration file might impact the whole file, so you may want to separate it out. By default, it is set to `True`.
`config_store.initialize` can be called anywhere, but it is recommended to have it at the entrance point of the program.
Use anywhere:
```python
from perfectconfig import config_store
# Use it
server_config = config_store["server_config"]
print(server_config.port)
# Modify it
server_config.port = 9090
config_store.save(server_config)
```
What about deletions?
This library does not provide a mechanism to delete configurations, or rename them on specific environments. Kindly ensure that when deployed everything is as-intended.
What we do provide is a clean-up mechanism:
```python
from perfectconfig import config_store
config_store.initialize("my-org", "my-product", type="yaml")
config_store.purge()
```
This is expected to help you manage your configurations, but in a human readable way, so offers no encryption options, at the moment.
There are no in-built mutex, or resource locking implemented, this is to provide flexibility to the implementor.
## Active and Lazy loading
The program is prepared to perform active and lazy loading as required. The developer need not bother about it, and work on the main logic itself. Just by following the aforementioned steps, the configuration store will automatically manage the loading.
Active loading is when the property definitions and values are required at the start of the program. When the file containing the property definitions are imported, it automatically triggers the `track` function, to add load the definitions and then load the values using initialize.
Lazy loading is when the property definitions are loaded at a later time. This works by holding the values on a buffer, and assigning the values to the defintions, when they're required to be used.
Everything happens under the hood without the explicit intervention of the user.
## Under the hood
Uses the in-built `json` library, and `pyyaml` and `appdirs` to provide the functionality in a structured way.
This is inspired from the property loading mechanism in `Spring Boot`, with the mechanism used in `SQLAlchemy`.
## Warnings
If the configurations objects are changed(such as during development), the objects aren't automanaged yet. This will require a manual removal or updation of the configurations for them to operate as expected.
## Planned
```python
from perfectconfig import config_store
config_store.load(yourpackage.env_configs.prod)
config_store.load(yourpackage.env_configs.dev)
...
```
Raw data
{
"_id": null,
"home_page": null,
"name": "perfectconfig",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Supratik Chatterjee <supratikdevm96@gmail.com>",
"keywords": "config, configuration, management",
"author": null,
"author_email": "Supratik Chatterjee <supratikdevm96@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b6/69/6e5a79f9748bab1b4e20710ce5ce5ce08e8a6d210588cfe07a8bdbb40b7b/perfectconfig-1.1.3.tar.gz",
"platform": null,
"description": "# Perfect Config\n\nManage your configuations in a mechanism similar to `SQLAlchemy`.\n\n## Usage\n\nInstall using `pip install perfectconfig`.\n\nDefine your configuration classes :\n\n```python\nfrom perfectconfig import GlobalConfig, ConfigProperty, config_store\n\nclass SampleServerConfiguration(GlobalConfig):\n _name = \"server_config\"\n port = ConfigProperty(\"port\", default=8080)\n host = ConfigProperty(\"host\", default=\"localhost\")\n name = ConfigProperty(\"name\", default=\"sample_server\")\n\nconfig_store.track() # Tracks the configuration defined in the file\n```\n\nInitialize your store(once initialized this is accessible everywhere):\n\n```python\nfrom perfectconfig import config_store\nconfig_store.initialize(\"my-org\", \"my-product\", format=\"yaml\", single_file=False)\n```\n\n`format` can be `json` or `yaml`. Default is `json`.\n\n`single_file` allows you to control, whether all individual configurations will be stored as separate files, or if they'd be maintained in the same file. In some cases format errors in the configuration file might impact the whole file, so you may want to separate it out. By default, it is set to `True`.\n\n`config_store.initialize` can be called anywhere, but it is recommended to have it at the entrance point of the program.\n\nUse anywhere:\n\n```python\nfrom perfectconfig import config_store\n\n# Use it\nserver_config = config_store[\"server_config\"]\nprint(server_config.port)\n\n# Modify it\nserver_config.port = 9090\nconfig_store.save(server_config)\n```\n\nWhat about deletions?\n\nThis library does not provide a mechanism to delete configurations, or rename them on specific environments. Kindly ensure that when deployed everything is as-intended.\n\nWhat we do provide is a clean-up mechanism:\n\n```python\nfrom perfectconfig import config_store\nconfig_store.initialize(\"my-org\", \"my-product\", type=\"yaml\")\nconfig_store.purge()\n```\n\nThis is expected to help you manage your configurations, but in a human readable way, so offers no encryption options, at the moment.\n\nThere are no in-built mutex, or resource locking implemented, this is to provide flexibility to the implementor.\n\n## Active and Lazy loading\n\nThe program is prepared to perform active and lazy loading as required. The developer need not bother about it, and work on the main logic itself. Just by following the aforementioned steps, the configuration store will automatically manage the loading.\n\nActive loading is when the property definitions and values are required at the start of the program. When the file containing the property definitions are imported, it automatically triggers the `track` function, to add load the definitions and then load the values using initialize.\n\nLazy loading is when the property definitions are loaded at a later time. This works by holding the values on a buffer, and assigning the values to the defintions, when they're required to be used.\n\nEverything happens under the hood without the explicit intervention of the user.\n\n## Under the hood\n\nUses the in-built `json` library, and `pyyaml` and `appdirs` to provide the functionality in a structured way.\n\nThis is inspired from the property loading mechanism in `Spring Boot`, with the mechanism used in `SQLAlchemy`.\n\n## Warnings\n\nIf the configurations objects are changed(such as during development), the objects aren't automanaged yet. This will require a manual removal or updation of the configurations for them to operate as expected.\n\n## Planned\n\n```python\nfrom perfectconfig import config_store\nconfig_store.load(yourpackage.env_configs.prod)\nconfig_store.load(yourpackage.env_configs.dev)\n...\n```",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Configuration Managment library",
"version": "1.1.3",
"project_urls": {
"Bug Tracker": "https://github.com/supratikchatterjee16/perfectconfig/issues",
"Changelog": "https://github.com/supratikchatterjee16/iam/blob/master/CHANGELOG.md",
"Documentation": "https://readthedocs.org",
"Homepage": "https://conceivilize.com/products/perfectconfig",
"Repository": "https://github.com/supratikchatterjee16/perfectconfig.git"
},
"split_keywords": [
"config",
" configuration",
" management"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a36035fccf7ef338588ed126e229877e9efad17355eafef348003bf10edf6db7",
"md5": "e6937fdefb57b2a30cadb179cf59b73d",
"sha256": "9733d560a3276934bdb26c27ee233684e47eed41e1d5dd5cade60f204ee2edc6"
},
"downloads": -1,
"filename": "perfectconfig-1.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e6937fdefb57b2a30cadb179cf59b73d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 5624,
"upload_time": "2024-11-03T17:00:32",
"upload_time_iso_8601": "2024-11-03T17:00:32.433649Z",
"url": "https://files.pythonhosted.org/packages/a3/60/35fccf7ef338588ed126e229877e9efad17355eafef348003bf10edf6db7/perfectconfig-1.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b6696e5a79f9748bab1b4e20710ce5ce5ce08e8a6d210588cfe07a8bdbb40b7b",
"md5": "fc1e93e0bd22450d4307d5947626a2bf",
"sha256": "093971445bf31954f71217c6b5e9068fa2fcf8980f1b58e694af6a8876016d28"
},
"downloads": -1,
"filename": "perfectconfig-1.1.3.tar.gz",
"has_sig": false,
"md5_digest": "fc1e93e0bd22450d4307d5947626a2bf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 7267,
"upload_time": "2024-11-03T17:00:34",
"upload_time_iso_8601": "2024-11-03T17:00:34.172066Z",
"url": "https://files.pythonhosted.org/packages/b6/69/6e5a79f9748bab1b4e20710ce5ce5ce08e8a6d210588cfe07a8bdbb40b7b/perfectconfig-1.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-03 17:00:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "supratikchatterjee16",
"github_project": "perfectconfig",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "perfectconfig"
}