import yaml
import logging


def load_colorscale(settings_filepath, scale_name="saigreen"):
    """Returns colorscale as list, e.g. from settings.yaml in ci/colorscale/saigreen"""

    with open(settings_filepath) as file:
        settings = yaml.full_load(file)
    try:
        colorscale = settings["ci"]["colorscale"][scale_name]
    except Exception as e:
        logging.error(
            f"Colorscale {scale_name} failed to load from {settings_filepath}. Return empty scale. Error: {e}"
        )
        colorscale = []

    return colorscale