Loads python modules from a configuration file.
Project description
Model Configuration Loader
Loads and instantiates python classes from a configuration file.
Free software: MIT license
Documentation: https://cfloader.readthedocs.io.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cfloader-0.1.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30fce02382b43e7895b9efbc1717c677d44368504dd247b01e6e491dc23a6d31 |
|
MD5 | 24bb6c8771db078ee2a2314c6b8e5eed |
|
BLAKE2b-256 | a5c5bcb02646efce78f2d154faa61182d614d08e22785cc1fc13c2c0d3986f65 |