power_cogs.config.load — power_cogs 0.1.0 documentation

# Source code for power_cogs.config.load

    import os
    from typing import Any, Optional

    from hydra.experimental import compose, initialize_config_dir

    from power_cogs.config.config_utils import setup_config

    def load_config(config_path: Optional[str] = None) -> Any:
        setup_config()
        if config_path is not None:
            config_path = os.path.abspath(config_path)
            config_dir, config_file = os.path.split(config_path)
            with initialize_config_dir(config_dir):
                _config = compose(config_name=config_file)
        else:
            config_dir = os.path.abspath(os.getcwd())
            with initialize_config_dir(config_dir):
                _config = compose(config_name="config")
        return _config