Ejemplo n.º 1
0
    def get_pending_cmd(self, watch_nodes):
        """Return the watchpoint in proto format."""
        # construct SetCMD
        condition_id = self._condition.get('id')
        set_cmd = SetCMD()
        set_cmd.id = self._id
        set_cmd.delete = False
        set_cmd.watch_condition.condition = WATCHPOINT_CONDITION_MAPPING.get(
            condition_id)
        condition_mgr = ConditionMgr()
        condition = condition_mgr.get_condition(condition_id)
        param_dict = {
            param.get('name'): param
            for param in self._condition.get('params')
        }
        for param_name in condition.ordered_parameter_names:
            param = param_dict.get(param_name)
            if param:
                param_proto = set_cmd.watch_condition.params.add()
                param_proto.name = param.get('name')
                param_proto.value = param.get('value')
                param_proto.disabled = False
                # Only one parameter of condition in old mindspore version.
                set_cmd.watch_condition.value = param.get('value')
            else:
                param_proto = set_cmd.watch_condition.params.add()
                param_proto.name = param_name
                param_proto.disabled = True

        for watch_node in watch_nodes:
            event_node = set_cmd.watch_nodes.add()
            event_node.node_name = watch_node.full_name
            event_node.node_type = watch_node.type
        return set_cmd
Ejemplo n.º 2
0
    def delete_watchpoint(self, watch_point_id):
        """
        Delete watchpoint.

        Args:
            watch_point_id (int): The id of watchpoint.

        Returns:
            dict, empty response.
        """
        self.validate_watchpoint_id(watch_point_id)
        self._watchpoints.pop(watch_point_id)
        set_cmd = SetCMD()
        set_cmd.id = watch_point_id
        set_cmd.delete = True
        self._deleted_watchpoints.append(set_cmd)
        log.debug("Delete watchpoint %d in cache.", watch_point_id)
Ejemplo n.º 3
0
    def _delete_single_watchpoint(self, watch_point_id):
        """
        Delete single watchpoint.

        Args:
            watch_point_id (int): The id of watchpoint.
        """
        self._watchpoints.pop(watch_point_id)
        # if the watchpoint has not been created by MindSpore, clean the relative cache directly
        if watch_point_id in self._created_watchpoints:
            self._created_watchpoints.remove(watch_point_id)
            self._updated_watchpoints.pop(watch_point_id)
            log.debug("Cancel create watchpoint %d in cache.", watch_point_id)
            return
        set_cmd = SetCMD()
        set_cmd.id = watch_point_id
        set_cmd.delete = True
        self._deleted_watchpoints.append(set_cmd)
        log.debug("Delete watchpoint %d in cache.", watch_point_id)
Ejemplo n.º 4
0
    def get_set_cmd(self):
        """Return the watchpoint in proto format."""
        # get watch nodes.
        watch_nodes = []
        self.get_watch_node(self._watch_node, watch_nodes)
        # construct SetCMD
        set_cmd = SetCMD()
        set_cmd.id = self._id
        set_cmd.delete = False
        set_cmd.watch_condition.condition = WATCHPOINT_CONDITION_MAPPING.get(
            self._condition.get('condition'))
        if self._condition.get('param'):
            # at most one param is provided
            set_cmd.watch_condition.value = self._condition.get('param')
        for watch_node in watch_nodes:
            event_node = set_cmd.watch_nodes.add()
            event_node.node_name = watch_node.full_name
            event_node.node_type = watch_node.node_type

        return set_cmd
 def get_set_cmd():
     """Get set command"""
     event = get_ack_reply()
     event.set_cmd.CopyFrom(SetCMD(id=1, watch_condition=1))
     return event