Skip to main content

chumicro-config

Runtime config from one shared dotted-key shape (wifi.ssid, mqtt.broker.host).

Each library exposes a <Name>Config.from_config() factory that reads its own dotted-prefix section from a shared dict (wifi.*, mqtt.broker.*, etc.) and returns typed configuration. Apps load one runtime_config.msgpack at boot; libraries pull their slice out. No global registry, no hand-written if "key" in config: walls.


Part of the ChuMicro family: small, focused Python libraries for microcontrollers and laptops. Browse all libraries.

Install

# CircuitPython (after `circup bundle-add ChuMicro/ChuMicro-Bundle`)
circup install chumicro_config

# MicroPython
mpremote mip install github:ChuMicro/ChuMicro-Bundle/chumicro_config

# CPython
pip install chumicro-config

For bundle setup, pre-compiled .mpy bundles, the experimental channel, and details on PyPI naming, see the chumicro INSTALL guide.

Quick example

User-app pattern (the 2-line bring-up):

from chumicro_config import load_runtime_config
from chumicro_wifi import WifiConfig, WifiService

config = load_runtime_config()                          # reads /runtime_config.msgpack
wifi = WifiService(WifiConfig.from_config(config))      # reads + types the wifi.* keys

Library-side pattern (load_section builds a typed config from the flat-key payload, used today by chumicro-wifi):

from chumicro_config import load_section

class WifiConfig:
    def __init__(self, ssid, password, hostname=None, connect_timeout_ms=15_000): ...

    @classmethod
    def from_config(cls, config):
        return load_section(
            cls, config,
            prefix="wifi",
            required=("ssid", "password"),
            optional={"hostname": None, "connect_timeout_ms": 15_000},
        )

What's included

Symbol What it does
load_runtime_config(path=…) Read + decode /runtime_config.msgpack into a flat-key RuntimeConfig (dict-shaped)
config Lazily-loaded module attribute: the deployed RuntimeConfig, or None when the file is absent. First attribute access reads the file once and caches the result
RuntimeConfig Lookup wrapper over the flat-key payload: get(key[, default]), [key] / require(key), in check
load_section(cls, config, *, prefix, required=…, optional=…) Build cls(**kwargs) by reading flat-prefix keys. Used today by chumicro-wifi's WifiConfig.from_config; available to any library whose constructor signature maps 1:1 to its config subkeys
try_load_section(...) Soft variant: returns None instead of raising when config is None, the wrong type, or missing a required key
MissingConfigKey / InvalidConfigType / ConfigError Targeted exceptions: single-inheritance from ConfigError (MicroPython forbids multi-parent layouts)

Where this fits

Depends on chumicro-msgpack for decode. Most ChuMicro libraries with a <Name>Config.from_config() factory read their slice off the shared RuntimeConfig via config.get(...); chumicro-wifi additionally uses the load_section helper here. Other consumers: chumicro-mqtt, chumicro-ntp, chumicro-requests, chumicro-websockets, chumicro-http_server.

Platform support

Works on CPython, MicroPython, and CircuitPython.

Examples

examples/end_to_end.py shows the full read → load_section → typed-config flow on CPython; see any consumer library (starting with chumicro-wifi) for the integrated usage shape.

Contributing

Issues, bug reports, and pull requests are welcome, and so is "I ran it on this board and here's what happened", some of the most useful feedback a hardware project can get. Development happens in the ChuMicro repository, whose contributing guide covers setup and the test workflow.

Docs

📖 Stable docs · Experimental docs

Find this library

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chumicro_config-0.7.5.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chumicro_config-0.7.5-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file chumicro_config-0.7.5.tar.gz.

File metadata

  • Download URL: chumicro_config-0.7.5.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chumicro_config-0.7.5.tar.gz
Algorithm Hash digest
SHA256 8db74fb0b50174b2a9c65f09832cc0b56aca677cdb31a877546630d1609c0dba
MD5 cc1b9870af170b9c609a508318d8bf43
BLAKE2b-256 f9201cdb222233f1e2ec92b0be5e642edbcafe90dd8aa8e88d40b4f8d155f0a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_config-0.7.5.tar.gz:

Publisher: promote.yml on ChuMicro/ChuMicro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chumicro_config-0.7.5-py3-none-any.whl.

File metadata

File hashes

Hashes for chumicro_config-0.7.5-py3-none-any.whl
Algorithm Hash digest
SHA256 178cbaa0459ee6dae5080a150441ce65a5b3a46f726977e2d857fdae7d21f74e
MD5 ff7df09244cd0831f12785358f764c84
BLAKE2b-256 36df25d45d13849df5f391a782f5c185e743f8355bb5ac288ac6c23101bfb6ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_config-0.7.5-py3-none-any.whl:

Publisher: promote.yml on ChuMicro/ChuMicro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.7.7

2 files

0.7.6

2 files

This release

0.7.5 This release

2 files

0.7.4

2 files

0.7.3

2 files

Supported by

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