Yaml to Dataclass parser for Config files
Project description
heracless
Config Manager using yaml.
Description
heracless aims to make working with config files in python easy. It parses a config file into a dataclass and creates types as a python file with can be used for type hints. Generated types also make autocompletion a dreamy!
Usage
first create a config file in yaml format and put in your desired fields. to access the config information do like in following sample code.
from heracless.decorator import heracless
from config.types import Config
@heracless()
def main(cfg:Config) -> Any:
"""
simply add a cfg parameter to any function at the first place
and access config attributes like you do any with any other object
"""
some_sample_config_value = config.sample.some_value
its as simple as that!
Decorator arguments:
- cfg_path:Path yaml config file path -> Default ./config/config.yaml
- dump_dir:Path Path where types are going to be written to -> Default ./config/types.py
- dump_func:Callable control's the dumping behavior -> options: heracless.dump_in_file|heracless.dump_in_console| heracless.dump_dummy -> Default dump_in_file
- frozen:bool whether dataclass config objects are mutable or not -> Default True
- make_dir:bool make given paths or not if not existing -> Default True
installation
pip install heracless
Version
heracless 0.1
written in python 3.11
Future
add clitool
add config variants
add ray wrapper for hyperparameter optimization configs
Author
Felix Schelling
github: felixscode
Witten with <3 in Mexico
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
Built Distribution
Hashes for heracless-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45c9589f07392eb8c75c380c1bfc974fbf1a03ae3d1feeeee24d06e2aab6bf47 |
|
MD5 | ce71f6781bbbc3dcef647d2b7ee65754 |
|
BLAKE2b-256 | 6188a305f7d137fdccd26831a771dfb562a9b72309c02b93e515534f40133ca6 |