Skip to main content

Practical and versatile configuration parsing in Python.

Project description

ConfigMate Logo

ConfigMate

Practical and versatile configuration parsing in Python

Pypi version Python versions Downloads Code quality License


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

  1. 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}
  1. 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)
  1. 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 |

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

configmate-0.1.8a0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

configmate-0.1.8a0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file configmate-0.1.8a0.tar.gz.

File metadata

  • Download URL: configmate-0.1.8a0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.2.0

File hashes

Hashes for configmate-0.1.8a0.tar.gz
Algorithm Hash digest
SHA256 2436443d6358fe506ea6e25ebbf5d66c14d0178bae948f58335884c1b8ea771b
MD5 ca77977f23979c732ba1d2d87ada107e
BLAKE2b-256 7c75805a4ce9cb0c6e01fecaec2a35a43f94737d04477a7783a4125133209ef5

See more details on using hashes here.

File details

Details for the file configmate-0.1.8a0-py3-none-any.whl.

File metadata

  • Download URL: configmate-0.1.8a0-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.2.0

File hashes

Hashes for configmate-0.1.8a0-py3-none-any.whl
Algorithm Hash digest
SHA256 526cd4531363d6a2b81aeb003f40164ba641a4af39c607b5d97dba8d8bcd479e
MD5 4a29ae0a1d7014b4aaaa26ebac48f527
BLAKE2b-256 a7f7bd45ee51f1be82fbf4015d5ba23f90680cd79b8492109bd1953351268b1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page