'Load ring data from a file.
:param filename: Path to a file serialized by the save() method.
:param bool metadata_only: If True, only load `devs` and `part_shift`.
:returns: A RingData instance containing the loaded data.'

@classmethod
def load(cls, filename, metadata_only=False):

    gz_file = GzipFile(filename, 'rb')
    if hasattr(gz_file, '_checkReadable'):
        gz_file = BufferedReader(gz_file)
    magic = gz_file.read(4)
    if (magic == 'R1NG'):
        (format_version,) = struct.unpack('!H', gz_file.read(2))
        if (format_version == 1):
            ring_data = cls.deserialize_v1(gz_file, metadata_only=metadata_only)
        else:
            raise Exception(('Unknown    ring    format    version    %d' % format_version))
    else:
        gz_file.seek(0)
        ring_data = pickle.load(gz_file)
    if (not hasattr(ring_data, 'devs')):
        ring_data = RingData(ring_data['replica2part2dev_id'], ring_data['devs'], ring_data['part_shift'], ring_data.get('next_part_power'))
    return ring_data
