from pathlib import Path
import yaml


def load_yaml(yamlpath: str):
    """
    Loads a yaml file from a path.
    :param yamlpath: Path to yaml settings file
    :returns: dict settings object """
    yamlpath_full = Path(yamlpath).absolute()

    with open(yamlpath_full, 'r', encoding="utf-8") as stream:
        try:
            outdict = yaml.safe_load(stream)
            return outdict

        except yaml.YAMLError as exc:
            print(exc)
            raise RuntimeError(f"Could not load yaml file at {yamlpath}")