{"id":13737548,"url":"https://github.com/cifkao/confugue","last_synced_at":"2025-04-15T17:23:27.868Z","repository":{"id":53502316,"uuid":"240792044","full_name":"cifkao/confugue","owner":"cifkao","description":"Hierarchical configuration framework for Python","archived":false,"fork":false,"pushed_at":"2021-09-13T14:04:42.000Z","size":208,"stargazers_count":22,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:03:21.769Z","etag":null,"topics":["configuration","configuration-management","configurations","deep-learning","dependency-injection","hierarchical-configuration","python","scientific-experiment"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cifkao.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-15T21:44:41.000Z","updated_at":"2023-09-19T00:42:36.000Z","dependencies_parsed_at":"2022-09-13T22:42:12.731Z","dependency_job_id":null,"html_url":"https://github.com/cifkao/confugue","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cifkao%2Fconfugue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cifkao%2Fconfugue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cifkao%2Fconfugue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cifkao%2Fconfugue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cifkao","download_url":"https://codeload.github.com/cifkao/confugue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249116770,"owners_count":21215264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","configuration-management","configurations","deep-learning","dependency-injection","hierarchical-configuration","python","scientific-experiment"],"created_at":"2024-08-03T03:01:52.930Z","updated_at":"2025-04-15T17:23:27.804Z","avatar_url":"https://github.com/cifkao.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Confugue\n========\n\n|pypi-package| |build-status| |docs-status|\n\nConfugue 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 easily configure complicated object hierarchies.\n\nThe package is ideal for configuring **deep learning** experiments. These often have large numbers of hyperparameters, and managing all their values globally can quickly get tedious. Instead, Confugue allows each part of the deep learning model to be automatically supplied with hyperparameters from a YAML configuration file, eliminating the need to pass them around or to define them in multiple places. The nested structure of the configuration file follows the hierarchy of the model architecture, with each part of the model having access to the corresponding section of the file.\n\nAs an example, here is a simplified code snippet from a deep learning project which uses Confugue:\n\n.. code-block:: python\n\n   @configurable\n   class Model:\n   \n       def __init__(self, vocabulary, use_sampling=False):\n           self.embeddings = self._cfg['embedding_layer'].configure(EmbeddingLayer,\n                                                                    input_size=len(vocabulary))\n           self.decoder = self._cfg['decoder'].configure(RNNDecoder,\n                                                         vocabulary=vocabulary,\n                                                         embedding_layer=self.embeddings) \n\n   @configurable\n   class RNNDecoder:\n   \n       def __init__(self, vocabulary, embedding_layer):\n           self.cell = self._cfg['cell'].configure(tf.keras.layers.GRUCell,\n                                                   units=100,\n                                                   dtype=tf.float32)\n           self.output_projection = self._cfg['output_projection'].configure(\n               tf.layers.Dense,\n               units=len(vocabulary),\n               use_bias=False)\n\nThe 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.\n\n.. code-block:: yaml\n\n   embedding_layer:\n     output_size: 300\n   decoder:\n     cell:\n       class: !!python/name:tensorflow.keras.layers.LSTMCell\n       units: 1024\n   use_sampling: True\n\nInstallation \u0026 Documentation\n----------------------------\n\nThe package is available from PyPI and can be installed with :code:`pip install confugue`.\n\nThe `docs \u003chttps://confugue.readthedocs.io/\u003e`_ include:\n\n- `Quick start guide \u003chttps://confugue.readthedocs.io/en/latest/deep-learning.html\u003e`_ for deep learning users, available as a `Colab notebook \u003chttps://colab.research.google.com/github/cifkao/confugue/blob/master/docs/pytorch_tutorial.ipynb\u003e`_\n- `General guide \u003chttps://confugue.readthedocs.io/en/latest/general-guide.html\u003e`_ for Python users\n- `API reference \u003chttps://confugue.readthedocs.io/en/latest/api.html\u003e`_\n\nComparison with other frameworks\n--------------------------------\n\nGin\n~~~\n\nConfugue is somewhat similar to `Gin \u003chttps://github.com/google/gin-config\u003e`_, but is much more minimalistic yet, in some ways, more powerful.\nSome advantages of Confugue over Gin are:\n\n- It is straightforward to configure many objects of the same type with different parameters for each; with Gin, this is possible, but it requires using scopes.\n- Any function or class can be configured without having been explicitly registered. \n- Config files may override the type of an object (or the function being called) while preserving the default parameters provided by the caller.\n- It is possible to access (and even manipulate) configuration values explicitly instead of (or in addition to) having them supplied as parameters.\n- The structure of the config file is nested – typically following the call hierarchy – compared to Gin's linear structure.\n\nOn the other hand, Confugue doesn't have some of the advanced features of Gin, such as config file inclusion or 'operative configuration' logging. It also doesn't support macros, but a similar effect can be achieved using `PyYAML's aliases \u003chttps://pyyaml.org/wiki/PyYAMLDocumentation#aliases\u003e`_.\n\nSome other differences (which may be viewed as advantages or disadvantages in different situations) are:\n\n- Gin config files specify *default* values for function parameters, which can be overridden by the caller. In Confugue, on the other hand, the config file has the final say.\n- Gin will seamlessly load defaults from the configuration file every time a configurable function or class is called. Confugue is more explicit in that the caller first has to ask for a specific key from the configuration file.\n\nSacred\n~~~~~~\n\n`Sacred \u003chttps://github.com/IDSIA/sacred\u003e`_ also offers configuration functionality, but its goals are much broader, focusing on experiment management (including keeping track of metrics and other information). Confugue, on the other hand, is not specifically targeted to scientific experimentation (even though it is particularly well suited for machine learning experiments). As for the configuration mechanism itself, Sacred has so-called 'captured functions' which resemble configurable functions in Confugue or Gin, but does not offer the same ability to configure arbitrary objects in a hierarchical way.\n\n.. |build-status| image:: https://travis-ci.com/cifkao/confugue.svg?branch=master\n   :target: https://travis-ci.com/cifkao/confugue\n   :alt: Build Status\n.. |docs-status| image:: https://readthedocs.org/projects/confugue/badge/?version=latest\n   :target: https://confugue.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n.. |pypi-package| image:: https://badge.fury.io/py/confugue.svg?\n   :target: https://pypi.org/project/confugue/\n   :alt: PyPI Package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcifkao%2Fconfugue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcifkao%2Fconfugue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcifkao%2Fconfugue/lists"}