Skip to main content

Hierarchical configuration framework

Project description

Build Status Documentation Status

confugue is a hierarchical configuration framework for Python. It provides a wrapper class for nested configuration dictionaries (usually loaded from YAML files), which can be used to configure complicated object hierarchies in a recursive fashion.

As an example, here is a simplified code snippet from a machine learning project which uses confugue:

@configurable
class Model:

    def __init__(self, vocabulary, use_sampling=False):
        self.embeddings = self._cfg['embedding_layer'].configure(EmbeddingLayer,
                                                                 input_size=len(vocabulary))
        self.decoder = self._cfg['decoder'].configure(RNNDecoder,
                                                      vocabulary=vocabulary,
                                                      embedding_layer=self.embeddings)

@configurable
class RNNDecoder:

    def __init__(self, vocabulary, embedding_layer):
        self.cell = self._cfg['cell'].configure(tf.keras.layers.GRUCell,
                                                units=100,
                                                dtype=tf.float32)
        self.output_projection = self._cfg['output_projection'].configure(
            tf.layers.Dense,
            units=len(vocabulary),
            use_bias=False)

The model could then be configured using the following config file, overriding the values specified in the code and filling in the ones that are missing.

embedding_layer:
  output_size: 300
decoder:
  cell:
    class: !!python/name:tensorflow.keras.layers.LSTMCell
    units: 1024
use_sampling: True

Installation & Documentation

A full documentation can be found here.

The package is available from PyPI and can be installed with pip install confugue.

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

confugue-0.0.1.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

confugue-0.0.1-py3-none-any.whl (8.4 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