<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def modify_origin(self, from_state, from_key):
 """Set both from_state and from_key at the same time to modify data flow origin :param str from_state: State id of the origin state :param int from_key: Data port id of the origin port :raises exceptions.ValueError: If parameters have wrong types or the new data flow is not valid """

        if not isinstance(from_state, string_types):
            raise ValueError("Invalid data flow origin port: from_state must be a string")
        if not isinstance(from_key, int):
            raise ValueError("Invalid data flow origin port: from_key must be of type int")

        old_from_state = self.from_state
        old_from_key = self.from_key
        self._from_state = from_state
        self._from_key = from_key

        valid, message = self._check_validity()
        if not valid:
            self._from_state = old_from_state
            self._from_key = old_from_key
            raise ValueError("The data flow origin could not be changed: {0}".format(message))