Skip to main content

The official tool to allow for creating and app-merging configuration options for pop projects.

Project description

Made with pop, a Python implementation of Plugin Oriented Programming Documentation is published with Sphinx on GitLab Pages via vmware.gitlab.io Made with Python

About

Pop-config is the official tool to allow for creating and app-merging configuration options for pop projects. Plugin Oriented Programming presents a means to merge multiple applications together dynamically. This capabilities requires that the startup of these applications needs to be managed from within the programming paradigm. Since this is the case pop-config becomes a critical and hard requirement of pop.

Pop-config is not just about being able to work with pop projects to facilitate app-merging, it has also been designed to make the startup of an application much simpler, and to make the expensive boiler plate of startup and configuration as transparent as possible. When making pop projects the idea is that projects are developed in very small chunks and are then dynamically merged together. So the creation of these mergeable apps needs to be quick and easy!

Pop-config also solves a problem with configuration of applications, when making a new application, if you want robust configuration loading, you need to be able to take options from the command line, environment variables, and configuration files. Pop-config does all of this for you, and loads them in the correct order, all behind the scenes, making your life easier.

Installation

For a basic installation run

$ pip install pop-config

To enable async logging install with the async extras

$ pip install pop-config[async]

Understanding the conf.py

Pop relies on a configuration file to manage how to merge apps, and also how to manage and merge configuration data. The data in this file is presented in 4 Python dictionaries and defines every aspect of configuration loading.

The 4 dictionaries are called CONFIG, CLI_CONFIG, SUBCOMMANDS and DYNE. Each dictionary serves a specific purpose. Between them you can define how the cli arguments are presented, all configuration defaults, documentation, etc.

This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.

For more information:

The CONFIG Dictionary

The bulk of the configuration will be present in the CONFIG dictionary. all of your configuration options are defined here. Most entries in the CONFIG dictionary will be very simple and just expose the most basic values:

CONFIG = {
    "name": {
        "default": "frank",
        "help": "Enter the name to use",
    },
}

This simple example presents the documentation for the configuration value and what the default value should be.

Vertically app-merged projects can add config items to their parent dynes like so:

CONFIG = {
    "new_item": {
        "type": int,
        "default": 1,
        "dyne": "idem",
    },
}

Many more options can be used, but they will be covered in the reference document.

The CLI_CONFIG Dictionary

Adding a configuration value does not make it appear on the command line. Each application can be extended to include command line options. Lets extend our earlier example to expose the “name” option as a command line argument:

CLI_CONFIG = {
    "name": {},
}
CONFIG = {
    "name": {
        "default": "frank",
        "help": "Enter the name to use",
    },
}

That’s it! The “name” option is now available on the command line and can be used as --name bob.

But what if we want it to be a positional argument? Simple! Just add the positional option to the CLI_CONFIG:

CLI_CONFIG = {
    "name": {
        "positional": True,
    },
}
CONFIG = {
    "name": {
        "default": "frank",
        "help": "Enter the name to use",
    },
}

You can inherit cli args from another project. Say, for example that you want to implement the --output flag exactly the same way rend does, you can source it like this:

CLI_CONFIG = {
    "output": {
        "source": "rend",
    },
}

Many more options exist that allow you to control every aspect of the user’s command line experience.

The SUBCOMMANDS Dictionary

Sometimes it is desirable to have subcommands. Subcommands allow your CLI to work in a way similar to the git cli, where you have multiple routines that all can be called from a single command.

Lets add a few more things to our example so that we can have subcommands.

CLI_CONFIG = {
    "name": {
        "subcommands": ["test", "apply"],
    },
    "weight": {},
    "power": {
        "subcommands": ["apply"],
    },
}
CONFIG = {
    "name": {
        "default": "frank",
        "help": "Enter the name to use",
    },
    "weight": {
        "default": "150",
        "help": "Enter how heavy it should be",
    },
    "power": {
        "default": "100",
        "help": "Enter how powerful it should be",
    },
}

SUBCOMMANDS = {
    "test": {
        "help": "Used to test",
        "desc": "When running in test mode, things will be tested",
    },
    "apply": {
        "help": "Used to apply",
        "desc": "When running in apply mode, things will be applied",
    },
}

In this example we see that the option name will be available under the subcommands test and apply. The option power will be available only under the subcommand apply and the option weight is globally available.

The DYNE Dictionary

The DYNE dictionary allows you to control what dynamic names your app is presenting to other pop projects. This name gets used not only inside of pop-config but also inside of pop to determine what plugin subsystems this application merges with. The DYNE system allows for your cli to be extended by third party code, enabling configuration options to be made available to your application via external code.

The DYNE system is very powerful. But since it is not critical to getting started with pop-config it will be covered in more depth in another document.

Log Module

Within the log module of pop-config there are several config options.

If “log_plugin” is set to “rotating”, the “log_handler_options” config item can be set to something other than the defaults.

The two options are:

  1. maxBytes default: 1024*1024*100 This option specifies the maximum size of each back up log file. Once a log file approaches this value the “rotating” module will save the file and create a new log file.

  2. backupCount default: 5 This option tells the rotating module how many backup log files are allowed. As that number increases the oldest files are deleted.

Acknowledgements

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

pop-config-12.0.1.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

pop_config-12.0.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file pop-config-12.0.1.tar.gz.

File metadata

  • Download URL: pop-config-12.0.1.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.16

File hashes

Hashes for pop-config-12.0.1.tar.gz
Algorithm Hash digest
SHA256 d96e2d93de70b69cfc3f3382d402df285a92f30cfc56a99a5ea384d22dd0ce6b
MD5 fb4b93c3719d6d4d1005b71338fae9f0
BLAKE2b-256 5c82a24d2a86c77384b949f8269a6bb082e6a0499251dbbe537a8624196e726d

See more details on using hashes here.

File details

Details for the file pop_config-12.0.1-py3-none-any.whl.

File metadata

  • Download URL: pop_config-12.0.1-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.16

File hashes

Hashes for pop_config-12.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8340a5e8ae4b848762f6245db32580abad95e05f438540b87985b9773de0989
MD5 f9e892fb29c7bf6e8c66332f3844c975
BLAKE2b-256 1bd0acf2b061c137f609f8bda95abbed5aa53d1c6db6967b5e6308a58ae61718

See more details on using hashes here.

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