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
File details
Details for the file cfloader-0.1.4.tar.gz
.
File metadata
- Download URL: cfloader-0.1.4.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9500a64f3321fe9506306ac4558dbc3cb36f48866b1a881e2236f70571372f6 |
|
MD5 | 0cff51d1cde100b55c5581a66656a571 |
|
BLAKE2b-256 | 02484bf8e8019bbeacce3eed0ac94de15d808b734477b7e2ca8bb3f8acf920cf |
File details
Details for the file cfloader-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: cfloader-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30fce02382b43e7895b9efbc1717c677d44368504dd247b01e6e491dc23a6d31 |
|
MD5 | 24bb6c8771db078ee2a2314c6b8e5eed |
|
BLAKE2b-256 | a5c5bcb02646efce78f2d154faa61182d614d08e22785cc1fc13c2c0d3986f65 |