def node_evaluation_finished(self, node, error=False): qt_node = QTGRAPH.get_node_by_name(node.name) self.index += 1.0 self.progressbar.setValue((self.index / len(self.graph.nodes)) * 100) qt_node.set_color(*COLORS["success"]) QtWidgets.QApplication.instance().processEvents() self.update_logs("Evaluated: {0}".format(node.name))
def evaluate_locally(self): print self.graph self.index = 0.0 self.progressbar.setValue(0) self.current_node = None for qt_node in self.qt_nodes_map.values(): qt_node.set_color(*COLORS["scheduled"]) flowpipe.node.INode.EVENTS["evaluation-started"].register( self.node_evaluation_started) flowpipe.node.INode.EVENTS["evaluation-finished"].register( self.node_evaluation_finished) try: self.graph.evaluate() self.progress_label.setText("Evaluation successful") except Exception as error: qt_node = QTGRAPH.get_node_by_name(self.current_node.name) qt_node.set_color(*COLORS["error"]) self.progress_label.setText("Evaluation failed!") tb = ''.join(traceback.format_exception(*sys.exc_info())) self.logs[self.current_node] = ( '<span style="white-space: pre-wrap; color: #ff9999;">{0}' '</span>'.format(tb)) log.exception(error) self.update_logs(tb) flowpipe.node.INode.EVENTS["evaluation-started"].deregister( self.node_evaluation_started) flowpipe.node.INode.EVENTS["evaluation-finished"].deregister( self.node_evaluation_finished) self.refresh_node_attributes()
def load_graph(self, graph): self.new() self.graph = graph self.graph_name_lineedit.setText(graph.name) x = 0 for row in graph.evaluation_matrix: y = 0 x_diff = 250 for fp_node in row: self._add_node(fp_node, QtCore.QPoint(x, y)) y += 150 x += x_diff for fp_node in graph.nodes: for i, output in enumerate(fp_node.all_outputs().values()): for c in output.connections: in_index = c.node.all_inputs().values().index(c) QTGRAPH.get_node_by_name(fp_node.name).set_output( i, QTGRAPH.get_node_by_name(c.node.name).input(in_index))
def node_evaluation_started(self, node): qt_node = QTGRAPH.get_node_by_name(node.name) self.current_node = node qt_node.set_color(*COLORS["evaluating"]) self.progress_label.setText(node.name) QtWidgets.QApplication.instance().processEvents()