import yaml


def load_config(file, append_static=True, static = "../config/static.yaml"):

    """

    Load a YAML file with specifications for one ML pipeline run.

    Parameters
    ==========
    file : str
        Local path to .yaml file.
    append_static : boolean
        Whether to append static.yaml. Defaults to True.
    static : str
        Local path to static.yaml file.

    Returns
    =======
    ignition : dict
        Specifications for one model run.
    """

    if append_static:
        with open(static, 'r') as f:
            try:
                static = yaml.safe_load(f)
            except yaml.YAMLError as err:
                print(err)
                return None

    with open(file, 'r') as f:
        try:
            ignition = yaml.safe_load(f)
            if append_static:
                ignition.update(static)
        except yaml.YAMLError as err:
            print(err)
            return None

    return ignition