Skip to main content

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

heracless-0.1.0.tar.gz (9.2 kB view hashes)

Uploaded Source

Built Distribution

heracless-0.1.0-py3-none-any.whl (10.4 kB view hashes)

Uploaded 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