Flexigurator
Flexigurator is a collection of useful tools when working with configuration. Flexigurator builds on top of ConfZ and Pydantic while adding some extra functionality to make your life easier when testing and deploying.
Examples
config_patch
When using ConfZ to define a configuration singleton using a .yaml file,
# config.yaml
some_string: default
some_int: 42
from confz import ConfZ, ConfZFileSource
class Config(ConfZ):
some_string: str
some_int: int
CONFIG_SOURCES = ConfZFileSource("config.yaml")
configuration variables can be easily hotswapped using patch_config:
from flexigurator import patch_config
data = dict(some_int=9001)
with patch_config(Config, data):
Config().some_int # 9001
Config().some_int # 42
Importantly, the new data does not need to be complete.
ConfigVersions
Allows for easy storing and on-demand loading of configuration versions.
from pathlib import Path
from confz import ConfZFileSource
from flexigurator import ConfigVersions, DirectorySource
class Config(ConfZ): # type: ignore
a: int
b: int
class Configs(ConfigVersions):
CONFIG_CLASS = Config
BASE = dict(a=1, b=2) # Optional base version which is loaded before other versions
test = ConfZFileSource("configs/test.yaml")
folder = DirectorySource(Path("configs/versions"))
with Configs().version("test"):
print(Config()) # Configuration from the ConfZFileSource is now loaded
with Configs().version("folder.version_1"):
print(Config()) # Configuration from "configs/versions/version_1.yaml" is loaded
placeholder
When having nested, optional BaseModels in your Config,
class Config(ConfZ):
ui: UIConfig | None
server: ServerConfig | None
it would be nice if trying to load configuration automatically throws an exception if it is not configured.
The placeholder method provides such functionality, and it can be used as follows:
from flexigurator import placeholder, patch_config
class Config(ConfZ):
ui: UIConfig = placeholder(UIConfig)
server: ServerConfig = placeholder(UIConfig)
Config().server.ip_address # NotConfiguredException!
This removes the need for None-checking as exception handling is done behind the scenes.
ConfigForm
ConfigForm allows for the easy creation of forms for ConfZ or BaseModel classes.
Forms are generated using Json Editor and are served using FastAPI.
Having instantiated ConfigForm,
# form.py
from flexigurator import ConfigForm
app = ConfigForm(Config, "save/path", "templates/path")
The server can be started using (for instance) Uvicorn:
uvicorn form:app
Installation
Flexigurator is available on PyPi and can be installed using pip:
pip install flexigurator
Metadata
Release files for flexigurator 0.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flexigurator-0.5.3.tar.gz | 10.5 kB | Without provenance | Details for flexigurator-0.5.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flexigurator-0.5.3-py3-none-any.whl | Python 3 | none | any | Details for flexigurator-0.5.3-py3-none-any.whl |
Total release size: 22.3 kB
Release files / flexigurator-0.5.3.tar.gz
| Download URL | flexigurator-0.5.3.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a77237441bbe31a7e90561010f65c317d660413ccb4354fbbdcc48344f1abcf6
|
|
BLAKE2b-256 checksum How to use checksums |
f513aa961420650ea40fc74de25a8cd79bcc5c9d4a764531b68669e909c1cb02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure
|
Release files / flexigurator-0.5.3-py3-none-any.whl
| Download URL | flexigurator-0.5.3-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9fc739d99e85fddd94dfe3c549ad0c20ba56c3cdfede20665356357076817e1
|
|
BLAKE2b-256 checksum How to use checksums |
a7e9fff5456f0c2b9794257b64fb3254160973cb3c808ed7cf325ee933ffc0df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure
|
Security for flexigurator 0.5.3
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.