Skip to main content

Loads python modules from a configuration file.

Project description

Model Configuration Loader

https://img.shields.io/pypi/v/cfloader https://img.shields.io/travis/shachibista/cfloader.svg Documentation Status

Loads and instantiates python classes from a configuration file.

Features

  • Auto class instantiation from json configuration

  • Read configuration from archives

  • Load dependencies between classes

  • Load configuration parameter as class or as object

Installation

pip install cfloader

Usage

Create a configuration file with parameters:

{
    "model": {
        "model_name": "SomeClass",
        "param_1": 20
    },
    "epochs": 10
}

Now you can load the configuration parameters, either as primitive dicts or as a class:

import cfloader

class SomeClass:
    def __init__(self, param_1):
        self.param_1 = param_1

loader = cfloader.open("config.json")
num_epochs = loader.load("epochs") # = int(10)
model_param_1 = loader.load("model.param_1") # = int(20)
model_configuration = loader.load("model") # = {"model_name": "SomeClass", "param_1": 20}
model_class = loader.load("model", as_class=True) # = <SomeClass object (param_1 = 20)>

For a more extensive example, see examples/pytorch/example_pytorch.py.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-10-06)

  • First release on PyPI.

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

cfloader-0.1.4.tar.gz (13.8 kB view hashes)

Uploaded Source

Built Distribution

cfloader-0.1.4-py2.py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 2 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