Library to inject configurations
Project description
Concoction
Concoction is a simple configuration injection library that allows you to easily inject configuration values into your
Python applications. It supports both pydantic
and dataclasses
for defining configuration models. Unlike traditional
configuration management tools, Concoction does not parse or layer configurations; it only works with a dictionary
object as an input.
Inspiration
Concoction is inspired by the @ConfigurationProperties
and @Value
annotations from Spring Boot. These annotations
allow for easy injection of configuration properties into Java applications, and Concoction aims to provide a similar
experience for Python developers.
Key Features
- Flexibility with Plain Dictionaries: Simple and flexible configuration management using plain dictionaries.
- Injecting Whole Configuration Blocks: Inject entire configuration blocks for modular and decoupled settings.
- Injecting Individual Fields: Granular control with the ability to inject specific configuration fields.
Installation
To install Concoction, run the following command:
pip install concoction
Usage
Here is an example of config.yaml
file:
app:
service:
host: 0.0.0.0
port: 8000
and injecting service
section into our config
import yaml # pip install pyyaml
from pydantic import BaseModel
from concoction import Configuration, set_global_config
# define config with injection
@Configuration("app.service")
class ServiceConfig(BaseModel):
host: str
port: int
# Load configuration from a YAML file
with open("config.yaml") as f:
config = yaml.safe_load(f)
set_global_config(config)
# Create an instance of the configuration model
app_config = ServiceConfig()
or field-wise
from concoction.values.pydantic import Value
class ServiceConfig(BaseModel):
host: str = Value("app.service.host")
port: int = Value("app.service.port")
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file concoction-0.1.3.tar.gz
.
File metadata
- Download URL: concoction-0.1.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a8ef81e14859749c192d1daec94b967cc6cc325c5177b886cf4c70c4bf430d |
|
MD5 | 0c8c6f1e5d5c268e2686064009556530 |
|
BLAKE2b-256 | 6c847956c0651274b660f75957c60b07e4befed239713b6056245c4f1e5738fe |
File details
Details for the file concoction-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: concoction-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6121b32ad812b5f039d44f82371edd36169d854c6ad36a7bc8db8a025f014a13 |
|
MD5 | 946c8a14774c4a125a5e27727001e44e |
|
BLAKE2b-256 | 3f2c8ac7385b6551d453bd2016704c3e99826b91f3da8220bdb91e900a1d0f45 |