Skip to main content

Flexible Python configurations.

Project description

Pycnfg logo

Flexible Python configurations.

Build Status PyPi version PyPI Status Docs Telegram

Pycnfg is a tool to execute Python-based configuration.

  • Pure Python.
  • Flexible.

It offers unified patten to create arbitrary Python objects pipeline-wise. That naturally allows to control all parameters via single file.

Logic

For details, please refer to Concepts.

Installation

PyPi PyPi version PyPI Status

pip install pycnfg
Development installation (tests and docs)

pip install pycnfg[dev]

Docker Docker Pulls

docker run -it nizaevka/pycnfg

Pycnfg is tested on: Python 3.6+.

Docs

Docs

Getting started

"""Configuration example to produce object."""

import pycnfg


class CustomProducer(pycnfg.Producer):
    """Specify custom methods to produce object."""
    def __init__(self, objects, oid):
        # Mandatory.
        super().__init__(objects, oid)

    def set(self, obj, key, val=42):
        obj[key] = val
        return obj

    def print(self, obj, key='a'):
        print(obj[key])
        return obj

    def method_id(self, obj, *args, **kwargs):
        # Some logic..
        return obj


# Configuration.
#   Set `init` object state {'a': 7}.
#   Set `producer` class CustomProducer.
#   Set `steps` to execute.
CNFG = {
    'section_1': {
        'conf_1': {
            'init': {'a': 7},
            'producer': CustomProducer,
            'steps': [
                ('set', {'key': 'b', 'val': 42}),
                ('print', {}),
                ('print', {'key': 'b'}),
                ('method_id', {}),
            ],
        },
        # 'conf_2': {...}
    }
    # 'section_2': {...}
}

if __name__ == '__main__':
    # Execute configuration(s) in priority.
    objects = pycnfg.run(CNFG)
    # => 7
    # => 42

    # Storage for produced object(s).
    print(objects['section_1__conf_1'])
    # => {'a': 7, 'b': 42}

see docs for details ;)

Examples

Check examples folder.

Check also mlshell - a ML framework based on Pycnfg.

Contribution guide

License

Apache License, Version 2.0 LICENSE. License

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

pycnfg-0.0.2.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycnfg-0.0.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file pycnfg-0.0.2.tar.gz.

File metadata

  • Download URL: pycnfg-0.0.2.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.1

File hashes

Hashes for pycnfg-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b8a6a1549212d397068acc8e2598144b67e9d92a2bf76a172cd3b614bb3787dd
MD5 d578ef416eaa97669113c77184ca60bc
BLAKE2b-256 0b7cc828c10077ca5fe76dfa0dac5d4850ecdc1ed91a7ca731f73b7ca8c04b7a

See more details on using hashes here.

File details

Details for the file pycnfg-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pycnfg-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.1

File hashes

Hashes for pycnfg-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fbf6324e03011e14ff4f4484121d1b021d9c63ee071e7a6e280100347dce70a9
MD5 6905986afa476de8bc9356caf31f4e93
BLAKE2b-256 128a492504f760707e70222c9a8c2b5a52eef1b280c5eb747731786d7df741b8

See more details on using hashes here.

Supported by

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