ConfigMate
Practical and versatile configuration parsing in Python
ConfigMate streamlines heavyweight config parsing into a sleek, zero-boilerplate experience that lets you configure with confidence.
Key Features
- Extensible file format support: Automatic detection & parsing of all standard config file formats.
- Environment variable interpolation: Parse environment variables while keeping defaults in your configuration file.
- Override files: Segregate base configuration management such as DEV/STAG/PROD overrides in separate files.
- CLI support: Override configuration values with files or values directly from an automatically generated command line interface.
- Type validation: Custom validation support, and seamless extension for Pydantic's fantastic validation capabilities.
Get started with ConfigMate
ConfigMate simplifies your configuration management. Get started with these easy steps:
Installation
Install ConfigMate with all standard features:
pip install "configmate[standard]"
Alternatively, install with specific features (e.g., Pydantic):
pip install "configmate[pydantic]"
Set Up Configuration
- Create a Configuration File: In this example we will do YAML, but ConfigMate supports all standard config file formats(json, toml, ini - you name it):
# config.yaml
Database configuration:
host: localhost
port: ${DB_PORT:8000}
- Load your config in python: Use ConfigMate to load and validate configuration in your script:
# example.py
import configmate
import dataclasses
@dataclasses.dataclass
class DatabaseConfig:
host: str
port: int
config = configmate.get_config(
"config.yaml",
section='Database configuration',
validation=DatabaseConfig
)
print(config)
- Run Your Script with Different Configurations Execute your script, and override configurations using environment variables or command-line arguments:
# Default configuration
python example.py
>> DatabaseConfig(host='localhost', port=8000)
# Override port using an environment variable
DB_PORT=9000 python example.py
>> DatabaseConfig(host='localhost', port=9000)
# Override host using a command-line argument
python example.py ++host foreignhost
>> DatabaseConfig(host='foreignhost', port=8000)
Quick comparison with other config parsers
| Feature / Package | ConfigMate | ConfigParser | File Parsers (TOML/YAML/...) | ArgParse | Pallets/Click | Google/Fire | OmegaConf | Hydra |
|---------------------------------------|:----------:|:------------:|:---------------------------:|:--------:|:-------------:|:-----------:|:---------:|:-----:|
| No Boilerplate | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ |
| Support for Multiple File Formats | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Hierarchical Configuration | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Command-line Interface (CLI) Support | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ |
| Type Validation | ✅ | ❌ | Partial | ❌ | ✅ | ❌ | Partial | Partial|
| Environment Variable Interpolation | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
| Dependency Count | Low | Low | Low | Low | Low | Low | Low | Moderate |
Metadata
Release files for configmate 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| configmate-0.1.8.tar.gz | 19.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| configmate-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.0 kB
Release files / configmate-0.1.8.tar.gz
| Download URL | configmate-0.1.8.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
654de0fd78d2938e5546534a2ad90e62bcf5bca0524bc112f602a39d58a9304a
|
|
BLAKE2b-256 checksum How to use checksums |
1b87a21ecd73bab2a82abc48f913e70169a3cc564e6c2dd5323e433bd4c63f3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.0 Darwin/23.2.0
|
Release files / configmate-0.1.8-py3-none-any.whl
| Download URL | configmate-0.1.8-py3-none-any.whl |
|---|---|
| Size | 28.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28c454f01c55a57c379557df5a398775cd56baf8828c8ca77dc6a5e830e33972
|
|
BLAKE2b-256 checksum How to use checksums |
f77cc11447f679c1cfaedc4f7901fe19419491c48ff403743fca65572b052768
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.0 Darwin/23.2.0
|