# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/config_file.ipynb.

# %% auto 0
__all__ = ['get_config_file_path']

# %% ../nbs/config_file.ipynb 1
import os
from pathlib import Path


def get_config_file_path() -> Path:
    possible_path_from_envvar = os.getenv("ENILM_CONFIG_FILE_PATH")
    if possible_path_from_envvar is not None:
        if not Path(possible_path_from_envvar).exists():
            raise ValueError(
                f"ENILM_CONFIG_FILE_PATH env var is set to {possible_path_from_envvar} but this file does not exist"
            )
        return Path(possible_path_from_envvar)
    elif "__file__" in globals():
        config_file_path = Path(globals()["__file__"]).parent.parent / "config.yaml"
        if not config_file_path.exists():
            raise ValueError(
                f"config_file_path inferred from __file__ is {config_file_path} but this file does not exist"
            )
        return config_file_path
    else:
        raise ValueError(
            "config_file_path is None and could not be inferred from globals() or ENILM_CONFIG_FILE_PATH env var"
        )
