def clearHighlightPaths(self): for node in self.mNodes: if (node.isHighlighted()): node.setHighlighted(False) node.update() for link in node.mLinks: if link.isHighlighted(): link.setHighlighted(False) link.trackNodes() link.update() self.mCenterNode.setHighlighted(False)
def highlightPathToParent(self, node): infoMessage("groogleView::highlightPathToParent: highlighting path to parent: ", node.mName) if (node == self.mCenterNode): warningMessage("groogleView::highlightPathToParent: shouldn't be parent node") while node != "": node.setHighlighted(True) node.update() if not node.mParent == "": link = node.getLink(node.mParent) link.setHighlighted(True) link.trackNodes() link.update() node = node.mParent
def updateNode(nextRun): if datetime.now() >= nextRun: #print 'Start updating the node...' log.current_state = "Getting node info from server" scn.update(node_updating="Updating node info [Calling Server]") response = httpclient.get(api.__get_node__(node.node_info['id']), auth.checkResponse) scn.update(server_resp="{} {}".format(response.status, response.reason)) log.current_state = "Deserializing node info" body = json.loads(response.body) log.current_state = "Updating node info" scn.update(node_updating="Updating node info [Saving Info]") node.update(body) scn.update(node_updating="Last update at " + datetime.now().isoformat()) nextRun = datetime.now() + timedelta(seconds=60) #print 'Node update finised\n' return nextRun
def learn(self): """ Iterate over all nodes in topological order starting with the leaves and perform updates on each node. Collects and stores the sum of the log-probabilities. """ graph = BayesNetGraph(self.nodes) sorted_nodes = graph.topological_sorting() # initialize a dictionary for passing evidence, keyed on Node objects # (first key: node that will consume the evidence, second key: source node of the evidence) LOGGER.info("Beginning learning") while self.iter < self.max_iterations: self.iter += 1 # clear terms update_terms = defaultdict(dict) self.log_posterior = 0. for node in sorted_nodes: LOGGER.debug("Updating %s", node.name) evidence_terms = node.update(evidence_terms=update_terms[node]) if not node.held_out: for target_node, evidence_term in evidence_terms.iteritems( ): update_terms[target_node][node] = evidence_term self.log_posterior += node.log_prob LOGGER.debug("Finished iteration %4.d, log-posterior = %f", self.iter, self.log_posterior) if not self.callback(self): LOGGER.debug( "Stopping updates because of callback termination condition" ) break LOGGER.info("Learning finished at iteration %d, log-posterior = %f", self.iter, self.log_posterior)
user_input = "n" user_input = user_input.lower() if user_input == "y" or user_input == "n": if user_input == "y": new_node = True else: new_node = False break log.current_state = "Ready to do the handshake" response = httpclient.post(api.__handshake__, node.get(new_node, auth.__user_id__), auth.checkResponse) print response.status, response.reason if response.status == 200: #print response.body body = json.loads(response.body) node.update(body) log.current_state = "Handshake succeeded" print "handshake succeeded" except: error_msg = "handshake fail" e = sys.exc_info()[0] print error_msg error_msg = "\n" + error_msg + "\n" + str(e) log.log_error(error_msg) try: print "\n----------------------\n" log.current_state = "Ready to setup the GPIO pins" sys_gpio.setup() print "GPIO Setup Succeeded"
def remove_resource(dataset): return update(dataset)
def add_resource(dataset): return update(dataset)