import yaml


def _load_yaml(config_path, logger=None):
    """Load config yaml file

    Args:
        config_path (str): the path of config yaml.
        logger (logging.Logger): the logger object to store logs.

    Returns:
        dict: config, a dictionary of configs.
    """
    try:
        with open(config_path, 'r') as yaml_file:
            config = yaml.safe_load(yaml_file)
            return config
    except OSError:
        if logger is None:
            print("Cannot open", config_path)
        else:
            logger.error("Cannot open", config_path)
        raise