Skip to main content

Note: This package is in the dangerous land of 0.x.y versions and may be subject to breaking changes with minor version increments.

nr.config

The nr.config package helps with configuration file processing and dynamic reloading tasks. It can serve as a generic library or give you a fast and easy framework.

Quickstart

The nr.config.process_config() function is the main function for processing config data. It expects the data to process as well as a number of processor plugins that will run over config. A common pattern is to use a conf section to hydrate variables for the remainder of the configuration.

from nr.config import process_config
from nr.config.plugins import Vars
import yaml

with open('var/conf/runtime.yaml') as fp:
  data = yaml.safe_load(fp)

config = process_config(data['runtime'], Vars({'conf': data['conf']}))

This particular example allows the use of references in the runtime block.

conf:
  value: 42
runtime:
  answer: '{{conf.value}}'

Service applications may want to reload the configuration file whenever it changes. For this purpose the nr.config module provides the ConfigReloadTask that uses the watchdog module to observe file changes and reload the config when the file changes. Errors that occur during the reload are automatically logged and the last valid configuration will be returned.

from nr.config.reloader import ConfigReloadTask
from nr.proxy import Proxy

reload_task = ConfigReloadTask('var/conf/runtime.yaml', load_config_from_file)
reload_task.reload_callback(callback)
reload_task.start()
config = Proxy(reload_task.get)

Copyright © 2020 Niklas Rosenstein

Metadata

Release files for nr.config 0.2.0

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

Source distribution (sdist)

Source distribution for nr.config 0.2.0
File Size Uploaded Provenance Actions
nr.config-0.2.0.tar.gz 13.7 kB Without provenance Details for nr.config-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nr.config 0.2.0
File Interpreter ABI Platform Actions
nr.config-0.2.0-py3-none-any.whl Python 3 none any Details for nr.config-0.2.0-py3-none-any.whl

Total release size: 31.0 kB

Release files / nr.config-0.2.0.tar.gz

Download URL nr.config-0.2.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a74ba1a5e40b97e9dc41fc1b722d5fded6c30f6e672cb892e48ecb63415c2d2a
BLAKE2b-256 checksum
How to use checksums
850beca97846e54349cb7c2cddc8c3da4709c162a346a1e56739eda496726cdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

Release files / nr.config-0.2.0-py3-none-any.whl

Download URL nr.config-0.2.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2d8be4294953930321a960825de88c32f4b342782b067a26c992ce46bcdb8df
BLAKE2b-256 checksum
How to use checksums
5cce47bff78db79f5f1fcdf66c6cb7801ad39a0fe1fc112dee826f566fef377d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

Security for nr.config 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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