Skip to main content

codecov Build Version Python versions License

Description

konfetti is a Python configuration management system with an intuitive API, lazy evaluation and (a)sync Vault support.

The interface design and features are heavily inspired by decouple, Django, envparse and dynaconf.

Key features:

  • Lazy evaluation;

  • Built-in environment variables support;

  • Built-in async Vault access support;

  • Helpers for tests;

  • Django & Flask integration.

Benefits of lazy evaluation:

  • Faster & simpler test runs; No need for evaluation the the whole project config if it is not used

  • Avoid network calls during imports until necessary;

Quickstart

To use konfetti you need to define:

  • configuration variables in a module or a class;

  • an access point;

Settings module

# app_name/settings/production.py
from konfetti import env, vault

VAULT_ADDR = env("VAULT_ADDR")
VAULT_TOKEN = env("VAULT_TOKEN")

DEBUG = env("DEBUG", default=False)
DATABASE_URI = vault("path/to/db")

The naming convention for variables names is upper case, other variables will be ignored. To work with Vault it is required to specify VAULT_ADDR and VAULT_TOKEN in the settings module.

Access point

# app_name/settings/__init__.py
from konfetti import Konfig, AsyncVaultBackend

config = Konfig(vault_backend=AsyncVaultBackend("/secret/team"))

konfetti relies on KONFETTI_SETTINGS environment variable to discover your settings module, in the case above:

export KONFETTI_SETTINGS=app_name.settings.production

Alternatively the access point could be initiated from an object, importable string, mapping or a JSON file.

class TestSettings:
    VALUE = "secret"
config = Konfig.from_object(TestSettings, ...)
config = Konfig.from_object("path.to.settings", ...)

# If the config is in the same module
SECRET = vault("/path/to")["secret"]
config = Konfig.from_object(__name__, ...)
config = Konfig.from_mapping({"SECRET": 42}, ...)
config = Konfig.from_json("/path/to.json")

Usage

The settings module/class with configuration options shouldn’t be accessed directly, because the aforementioned features are implemented in the access point level.

from app_name.settings import config

async def something():
    await config.DATABASE_URI  # asynchronously taken from Vault
    debug = config.DEBUG  # Usual sync access

Documentation

For full documentation, please see https://konfetti.readthedocs.io/en/latest/

Or you can look at the docs/ directory in the repository.

Python support

Konfetti supports Python 2.7, 3.5, 3.6, 3.7 and 3.8

License

The code in this project is licensed under MIT license. By contributing to konfetti, you agree that your contributions will be licensed under its MIT license.

Metadata

Release files for konfetti 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for konfetti 0.7.0
File Interpreter ABI Platform
konfetti-0.7.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / konfetti-0.7.0-py2.py3-none-any.whl

Download URL konfetti-0.7.0-py2.py3-none-any.whl
Size 24.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
48202f2b0e6363810487b6146f82ff1f95c4ec23d54f45d94d79a0d85aecfc08
BLAKE2b-256 checksum
How to use checksums
09c0c9c35b00f8198ef05acb76325d8c1793a0bb5ea95b9c12f3d095b248853b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

0.8.0

1 release file

0.7.2

1 release file

0.7.1

1 release file

This release

0.7.0 This release

1 release file

0.6.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page