Easily configure Python apps via environment variables, YAML, and AWS SSM Param Store.
Project description
Flex Config
Configure your applications as easily as possible.
Main Features
Load config from wherever
- Comes with built in support for loading from dicts, environment variables, JSON/YAML/TOML files, and AWS SSM Parameter Store.
- Super easy to set up a custom source and load from anywhere.
Type conversion, validation, and hints via Pydantic
# "ConfigSchema" is pydantic's BaseModel renamed and re-exported for easier use
from flex_config import ConfigSchema, construct_config
class Config(ConfigSchema):
a_string: str
an_int: int
# Raises ValidationError
my_bad_config = construct_config(Config, {"a_string": ["not", "a", "string"], "an_int": "seven"})
my_good_config = construct_config(Config, {"a_string": "my_string", "an_int": "7"})
assert isinstance(my_good_config.an_int, int)
Dynamic loading of config values
from pathlib import Path
from typing import Dict, Any
# "ConfigSchema" is pydantic's BaseModel renamed and re-exported for easier use
from flex_config import ConfigSchema, construct_config, AWSSource, YAMLSource, EnvSource, ConfigSource
class Config(ConfigSchema):
env: str
my_thing: str
def get_ssm_params(config_so_far: Dict[str, Any]) -> ConfigSource:
# env is set to live or dev via environment variables in the deployment environment
env = config_so_far.get("env")
if env == "local": # Not a live deployment, my_thing is in a local yaml file
return {}
return AWSSource(f"my_app/{config_so_far['env']}")
my_config = construct_config(Config, [EnvSource("MY_APP_"), YAMLSource(Path("my_file.yaml")), get_ssm_params])
Installation
Basic install: poetry install flex_config
With all optional dependencies (support for AWS SSM, YAML, and TOML): poetry install flex_config -E all
For a full tutorial and API docs, check out the hosted documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flex_config-3.0.0.tar.gz.
File metadata
- Download URL: flex_config-3.0.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.10.13 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032a059b90f793a6647948fd58169ef3ccb012324ba5cef4ce457aa3dbf26849
|
|
| MD5 |
55a867cad2c492890907a1a3088970c2
|
|
| BLAKE2b-256 |
1d751d5c28ab66844e3274cb89f84e4b3890a6dc946ca1510a23e8bc9bbcdd65
|
File details
Details for the file flex_config-3.0.0-py3-none-any.whl.
File metadata
- Download URL: flex_config-3.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.10.13 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750920336e05c54b386098012c986b082fd3727fc9a3ef285de594125fb246cf
|
|
| MD5 |
5dc1f5f39a9c676b093034136b2ae87f
|
|
| BLAKE2b-256 |
e22d08b382d3859c85f42b72b5ce137ab19e2ac11e2d6efba8efa3c3e386dfd8
|