<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_index(self, index_name, index):
 """ add an index to the schema for the most part, you will use the __getattr__ method of adding indexes for a more fluid interface, but you can use this if you want to get closer to the bare metal index_name -- string -- the name of the index index -- Index() -- an Index instance """

        if not index_name:
            raise ValueError("index_name must have a value")
        if index_name in self.indexes:
            raise ValueError("index_name {} has already been defined on {}".format(
                index_name, str(self.indexes[index_name].fields)
            ))
        if not isinstance(index, Index): raise ValueError("{} is not an Index instance".format(type(index)))

        index.name = index_name
        self.indexes[index_name] = index
        return self