Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Flex Config

codecov Code style: black Generic badge MIT license

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

Release files for flex-config 3.0.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 flex-config 3.0.0
File Size Uploaded
flex_config-3.0.0.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flex-config 3.0.0
File Interpreter ABI Platform
flex_config-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size:19.2 kB

Release files / flex_config-3.0.0.tar.gz

Download URL flex_config-3.0.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
032a059b90f793a6647948fd58169ef3ccb012324ba5cef4ce457aa3dbf26849
BLAKE2b-256 checksum
How to use checksums
1d751d5c28ab66844e3274cb89f84e4b3890a6dc946ca1510a23e8bc9bbcdd65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.10.13 Linux/6.2.0-1018-azure

Release files / flex_config-3.0.0-py3-none-any.whl

Download URL flex_config-3.0.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
750920336e05c54b386098012c986b082fd3727fc9a3ef285de594125fb246cf
BLAKE2b-256 checksum
How to use checksums
e22d08b382d3859c85f42b72b5ce137ab19e2ac11e2d6efba8efa3c3e386dfd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.10.13 Linux/6.2.0-1018-azure
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