Helper package for using AWS App Config with Pydantic
Project description
Ever wanted to use AWS AppConfig for your Python app, but can’t bear configs without pydantic?
Well, your days of using evil .env or .ini files, ENVIRONMENT variables or even custom providers is over!
With just a simple
pip install pydantic-appconfig
With a lot of inspiration from this AWS sample.
Introducing pydantic_appconfig.
Set yourself up with your favourite pydantic.BaseModel:
class MyAppConfig(pydantic.BaseModel): """My app config.""" test_field_string: str test_field_int: int class Config: """The pydantic config, including title for the JSON schema.""" title = "MyAppConfig"
Set up the config helper using your shiny config class:
from pydantic_appconfig import AppConfigHelper my_config: AppConfigHelper[MyAppConfig] = AppConfigHelper( appconfig_application="AppConfig-App", appconfig_environment="AppConfig-Env", appconfig_profile="AppConfig-Profile", max_config_age=15, fetch_on_init=True, config_schema_model=MyAppConfig, )
Use it:
my_val = my_config.config.test_field_string
AWS AppConfig also has support for validators.
Pydantic is able to generate a JSON schema for you to upload:
print(MyAppConfig.schema_json(indent=2))
{ "title": "MyAppConfig", "description": "My app config.", "type": "object", "properties": { "test_field_string": { "title": "Test Field String", "type": "string" }, "test_field_int": { "title": "Test Field Int", "type": "integer" } }, "required": [ "test_field_string", "test_field_int" ] }
Project details
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
File details
Details for the file pydantic_appconfig-2.0.0.tar.gz
.
File metadata
- Download URL: pydantic_appconfig-2.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.2 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2df25431698f27672529f49c2bfd40b1ad73cc7022dc2280525b749dd2029ce |
|
MD5 | f6855fa1a6ff3eca067275dbc9df6cf0 |
|
BLAKE2b-256 | d682fcfc83f3703a1947fb478957ca1bd480d2ac0656e0e2a39c3cc7ba5ed589 |
File details
Details for the file pydantic_appconfig-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: pydantic_appconfig-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.2 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccfadece32d0ed5f20665b900c52b4ae23633047d758054d9788db0422af3bed |
|
MD5 | 7e2bd7d9eb8a8f770a3c16de496fbb50 |
|
BLAKE2b-256 | 323929504e852062de70fdd11dbc54fdde89ff67260faf03fc0421e44841f377 |