def __init__(self, api, node_id, constraints,
                 parent=None, prim=None, ns=None, applied_consequences=None):

        self.constraints = copy.deepcopy([api.regularize_expression(x)
                                          for x in constraints])
        self.node_id = node_id
        self.base_api = api
        self.applied_consequences = copy.deepcopy(applied_consequences) if \
            applied_consequences is not None else []

        self.children = []
        classname = self.__class__.__name__.lower()
        self.logger = logging.getLogger('%s.%s' % (__name__, classname))
        self.parent = parent
        self.prim = prim
        self.task_primitives = {}
        self.adventures = []
        self.ns = ns if ns is not None else {}

        self.logger.info('New solver for constraints %s' % constraints)
        self.logger.info('With applied constraints %s' % applied_consequences)

        # roll the applied consequences forward in an ephemeral
        # api, and do our resolution from that.
        self.api = db_api.ephemeral_api_from_api(self.base_api)
        pre_node = self.api._model_get_by_id('nodes', self.node_id)

        for consequence in self.applied_consequences:
            node = self.api._model_get_by_id('nodes', self.node_id)
            ast.apply_expression(node, consequence, self.api)

        # get rid of constraints we've already solved
        self.constraints = [x for x in self.constraints if not
                            self._constraint_satisfied(x)]

        node = self.api._model_get_by_id('nodes', self.node_id)

        # grab the tasks published from this node as possible primitives
        # ...
        # we aren't actually solving through tasks and adventures
        # yet, but likely have the need
        if node['attrs'] in 'opencenter_agent_actions' and \
                'backends' in node['facts'] and \
                'agent' in node['facts']['backends']:
            for task_name in node['attrs']['opencenter_agent_actions']:
                mangled_name = task_name
                task = node['attrs']['opencenter_agent_actions'][task_name]

                id = hash(mangled_name) & 0xFFFFFFFF
                # should verify this unique against backends
                self.task_primitives[id] = {}
                self.task_primitives[id]['id'] = id
                self.task_primitives[id]['name'] = mangled_name
                self.task_primitives[id]['task_name'] = task_name
                self.task_primitives[id]['constraints'] = \
                    task['constraints']
                self.task_primitives[id]['consequences'] = \
                    task['consequences']
                self.task_primitives[id]['args'] = task['args']
                self.task_primitives[id]['weight'] = 50
                self.task_primitives[id]['timeout'] = task['timeout'] if \
                    'timeout' in task else 30

        self.logger.debug('Node before applying consequences: %s' % pre_node)
        self.logger.debug('Applied consequences: %s' %
                          self.applied_consequences)
        # ephemeral_node = self.api._model_get_by_id('nodes', self.node_id)
        self.logger.debug('Node after applying consequences: %s' % node)
dataset/ETHPy150Open rcbops/opencenter/opencenter/webapp/solver.py/Solver.__init__/swapped operands of `in`