Skip to content

opendecree/decree-python

OpenDecree Python SDK

CI PyPI Python Downloads License Project Status: WIP

Python SDK for OpenDecree — schema-driven configuration management.

Alpha — This SDK is under active development. APIs and behavior may change without notice between versions.

Install

pip install opendecree

Quick Start

from opendecree import ConfigClient

with ConfigClient("localhost:9090", subject="myapp") as client:
    # Get config values (default: string)
    fee = client.get("tenant-id", "payments.fee")

    # Typed gets via overload
    retries = client.get("tenant-id", "payments.retries", int)
    enabled = client.get("tenant-id", "payments.enabled", bool)

    # Set values
    client.set("tenant-id", "payments.fee", "0.5%")

Watch for Changes

with ConfigClient("localhost:9090", subject="myapp") as client:
    with client.watch("tenant-id") as watcher:
        fee = watcher.field("payments.fee", float, default=0.01)
        enabled = watcher.field("payments.enabled", bool, default=False)

        if enabled:
            print(f"Current fee: {fee.value}")

        @fee.on_change
        def on_fee_change(old: float, new: float):
            print(f"Fee changed: {old} -> {new}")

Async

from opendecree import AsyncConfigClient

async with AsyncConfigClient("localhost:9090", subject="myapp") as client:
    val = await client.get("tenant-id", "payments.fee")
    retries = await client.get("tenant-id", "payments.retries", int)

Examples

Runnable examples in the examples/ directory:

Example What it shows
quickstart Context manager, typed get(), set()
async-client async with, await, asyncio.gather()
live-config ConfigWatcher, @on_change, changes()
fastapi-integration Async watcher as FastAPI lifespan dependency
error-handling RetryConfig, nullable=True, error hierarchy

Documentation

For detailed concepts (schemas, typed values, versioning, auth), see the main OpenDecree docs.

Requirements

  • Python 3.11+
  • A running OpenDecree server (v0.3.0+)

Questions?

Head to OpenDecree Discussions — our community hub covers all OpenDecree repos.

License

Apache License 2.0 — see LICENSE.

Packages

 
 
 

Contributors