def _compare_config()

in dora/hydra.py [0:0]


def _compare_config(ref, other, path=[]):
    """
    Given two configs, gives an iterator over all the differences. For each difference,
    this will give a _Difference namedtuple.
    """
    keys = sorted(ref.keys())
    remaining = sorted(set(other.keys()) - set(ref.keys()))
    delta = []
    path.append(None)
    for key in keys:
        path[-1] = key
        ref_value = ref[key]
        assert key in other, f"Structure of config should be identical between XPs. Extra key {key}"
        other_value = other[key]

        if isinstance(ref_value, DictConfig):
            assert isinstance(other_value, DictConfig), \
                "Structure of config should be identical between XPs. "\
                f"Wrong type for {key}, expected DictConfig, got {type(other_value)}."
            yield from _compare_config(ref_value, other_value, path)
        elif other_value != ref_value:
            yield _Difference(list(path), key, ref, other, ref_value, other_value)
    assert len(remaining) == 0, "Structure of config should be identical between XPs. "\
                                f"Missing keys: {remaining}"
    path.pop(-1)
    return delta