{"id":19724359,"url":"https://github.com/jungerm2/modularyze","last_synced_at":"2025-04-29T22:31:17.223Z","repository":{"id":57442720,"uuid":"312430102","full_name":"jungerm2/modularyze","owner":"jungerm2","description":"Modular, composable, and dynamic configuration","archived":false,"fork":false,"pushed_at":"2020-11-19T02:21:00.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T15:38:40.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://modularyze.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jungerm2.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-13T00:27:47.000Z","updated_at":"2024-01-04T21:06:30.000Z","dependencies_parsed_at":"2022-09-26T17:21:19.762Z","dependency_job_id":null,"html_url":"https://github.com/jungerm2/modularyze","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2Fmodularyze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2Fmodularyze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2Fmodularyze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2Fmodularyze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jungerm2","download_url":"https://codeload.github.com/jungerm2/modularyze/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251593029,"owners_count":21614460,"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":[],"created_at":"2024-11-11T23:25:35.831Z","updated_at":"2025-04-29T22:31:16.825Z","avatar_url":"https://github.com/jungerm2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========\nModularyze\n==========\n\n\n.. image:: https://img.shields.io/pypi/v/modularyze.svg\n        :target: https://pypi.python.org/pypi/modularyze\n\n.. image:: https://img.shields.io/travis/jungerm2/modularyze.svg\n        :target: https://travis-ci.com/jungerm2/modularyze\n\n.. image:: https://readthedocs.org/projects/modularyze/badge/?version=latest\n        :target: https://modularyze.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\n\n\nModularyze is a modular, composable and dynamic configuration engine that mixes the power of dynamic webpage rendering with that of YAML. It relies on Jinja_ and `ruamel.yaml`_ and inherits their flexibility.\n\n\nQuick Start\n-----------\n\nInstallation\n^^^^^^^^^^^^\n\nTo install the latest version of modularyze, run this command in your terminal:\n\n.. code-block:: console\n\n    $ pip install modularyze\n\n\nExample\n^^^^^^^\n\nThe Modularize package exposes one central config-builder class called ConfBuilder_. Using this class you can register arbitrary constructors and callables, render templated multi-file and dynamic configs, instantiate them and compare configs by hash or their normalized form.\n\nTo use modularyze in a project simply import it, register any callables your config might be using and point it to your configuration file. From there you can simply call build_ to build the config.\n\nA simple example where we instantiate a machine learning pipeline could look something like this:\n\n.. code-block::\n\n    # File: imagenet.yaml\n\n    {% set use_pretrained = use_pretrained | default(True) %}\n    {% set imagenet_root = imagenet_root | default('datasets/imagenet') %}\n\n    network: \u0026network\n        !torchvision.models.resnet18\n        pretrained: {{ use_pretrained }}\n\n    val_transforms: \u0026val_transforms\n        !torchvision.transforms.Compose\n        - !torchvision.transforms.Resize [256]\n        - !torchvision.transforms.CenterCrop [224]\n        - !torchvision.transforms.ToTensor\n\n    dataset: \u0026dataset\n        !torchvision.transforms.datasets.ImageNet\n        args:\n          - {{ imagenet_root }}\n        kwargs:\n          split: 'val'\n          transforms: *val_transforms\n\n\n.. code-block:: python\n\n    import torchvision\n    from modularyze import ConfBuilder\n\n    builder = ConfBuilder()\n    builder.register_multi_constructors_from_modules(torchvision)\n    conf = builder.build('imagenet.yaml')\n\nNow the ``conf`` object is a python dictionary containing a fully initialized model, dataset and validation transforms. What about if you want to change a parameter on the fly? Say the imagenet folder changes? Easy, simply pass in a context:\n\n.. code-block:: python\n\n    conf = builder.build('imagenet.yaml', context={\"imagenet_root\": \"new/path/to/dataset\"})\n\nIn this way ypu can easily parameterize you configuration files. The provided context is usually a dictionary but it can even be the path to a (non-parameterized/vanilla) YAML file.\n\nWhat about if we have the configuration for a model trainer in a different file? Imagine the file ``trainer.yaml`` instantiates a neural network trainer instance, we can include it by adding the following line to the above config file:\n\n.. code-block:: jinja\n\n    {% include 'trainer.yaml' %}\n\nThere are many more neat things you can do when you combine the powers of YAML and Jinja, please refer to the documentation_ for more.\n\n\n.. _Jinja: https://jinja.palletsprojects.com/en/2.11.x/\n.. _`ruamel.yaml`: https://pypi.org/project/ruamel.yaml/\n.. _documentation: https://modularyze.readthedocs.io/en/latest/\n.. _ConfBuilder: https://modularyze.readthedocs.io/en/latest/api.html#modularyze.modularyze.ConfBuilder/\n.. _build: https://modularyze.readthedocs.io/en/latest/api.html#modularyze.modularyze.ConfBuilder.build/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjungerm2%2Fmodularyze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjungerm2%2Fmodularyze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjungerm2%2Fmodularyze/lists"}