Skip to main content

A thin and smart config provider for python apps

Reason this release was yanked:

don't use initial releases

Project description

QuickConfig


Description

QuickConfig is a super lightweight dynamic config provider for python applications. The config provider uses a runtime config that can be imported to any part of your application. The provider allows you to use runtime environment variables and configs anywhere in your application via a simple import.

Design

The quick config provider relies on a standard structure for an application's configurations. All configurations must be provided in a standard config directory. Configs in the config directory must follow the standard deployment configuration names like staging.py or test.py or production.py. Once the runtime environment is set via an environment variable environment, the config provider will read that and populate the configs available to the entire application as methods.

Usage

  1. Create an application like a Django/Flask Application which has runtime configs which may differ for each run time environment using the following nomenclature:
    • create a directory called config
    • create files in the directory with the following structure
    # config/base.py:
    import os
    
    ENV_VARS = {
        "some_api_key": os.environ.get('my_api_key'),
         "db_name": "my_default_db",
         "important_array": ['a', 'b', 'c', 'd']
    }
    
    # config/production.py:
    import os
    
    ENV_VARS = {
         "db_name": os.environ.get("production_db"),   # overwrites base.py
         "important_array": [1, 2, 3, 4]  # overwrites base.py
    }
    
    # config/development.py: 
    ENV_VARS = {
         "db_name": "my_dev_db",
    }
    
    • Note the use of ENV_VARS in each environment file. That is required
  2. Install the qc config pip install qc
  3. Use the environment vars in your application directly:
# in my_app/my_module/file.py
from quick_config import config

class MyModule:    
    def __init__(self):
        self.logger = config.get_logger()
        self.api_key = config.some_api_key()

        # depending on environment, this will change
        self.important_index_value = config.important_array(0)

global_db_name = config.db_name()

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

quick_config-0.2.1.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

quick_config-0.2.1-py3-none-any.whl (11.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page