def fullReconstruction(self): from .widgets.volumeviewer import VolumeViewer volumeviewer = VolumeViewer() self.recontabs.addTab(volumeviewer, '????') currentitem = self.headermodel.item(self.rawtabview.currentIndex()) if not currentitem: msg.showMessage( 'Error: You must open files before reconstructing.') try: msg.showBusy() msg.showMessage('Running slice reconstruction...', level=msg.INFO) currentheader = self.headermodel.item( self.rawtabview.currentIndex()).header readprocess = self.workflow.processes[ 0] # hopefully! TODO: require a readprocess first readprocess.path.value = currentheader.startdoc['path'] numofsinograms = currentheader.meta_array('primary').shape[1] self.workflow.execute_all(None, readprocess=range( 0, int(numofsinograms), int(readprocess.chunksize.value))) except Exception as ex: msg.logError(ex) msg.showReady() msg.clearMessage()
def process_queries(self): # If there is a backlog, process only the newer query. block = True while True: try: query = self.query_queue.get_nowait() block = False except queue.Empty: if block: query = self.query_queue.get() break log.debug('Submitting query %r', query) try: t0 = time.monotonic() msg.showMessage("Running Query") msg.showBusy() self._results_catalog = self.selected_catalog.search(query) found_new = self.check_for_new_entries() duration = time.monotonic() - t0 log.debug('Query yielded %r results (%.3f s).', len(self._results_catalog), duration) if found_new and self.show_results_event.is_set(): self.new_results_catalog.emit() except Exception as e: msg.logError(e) msg.showMessage("Problem running query") finally: msg.hideBusy()
def fullReconstruction(self): from xicam.Tomography.widgets.volumeviewer import VolumeViewer volumeviewer = VolumeViewer() self.recontabs.addTab(volumeviewer, '????') currentitem = self.headermodel.item(self.rawtabview.currentIndex()) if not currentitem: msg.showMessage('Error: You must open files before reconstructing.') try: msg.showBusy() msg.showMessage('Running slice reconstruction...', level=msg.INFO) currentheader = self.headermodel.item(self.rawtabview.currentIndex()).header readprocess = self.workflow.processes[0] # hopefully! TODO: require a readprocess first readprocess.path.value = currentheader.startdoc['path'] numofsinograms = currentheader.meta_array('primary').shape[1] executor = DaskExecutor() client = distributed.Client() def chunkiterator(workflow): for i in range(0, int(numofsinograms), int(readprocess.chunksize.value)): readprocess.sinoindex.value = i yield executor.execute(workflow) _reconthread = QThreadFutureIterator(chunkiterator, self.workflow, callback_slot=partial(self.showReconstruction, mode=self.fullrecon), except_slot=self.exceptionCallback) _reconthread.start() except Exception as ex: msg.logError(ex) msg.showReady() msg.clearMessage()
def sliceReconstruct(self): currentitem = self.headermodel.item(self.rawtabview.currentIndex()) if not currentitem: msg.showMessage('Error: You must open files before reconstructing.') try: msg.showBusy() msg.showMessage('Running slice reconstruction...', level=msg.INFO) paths = self.headermodel.item(self.rawtabview.currentIndex()).header.startdoc['paths'] self.workflow.execute(None, paths=paths, threadkey='slicereconstruct', callback_slot=partial(self.showReconstruction, mode=self.slice), except_slot=self.exceptionCallback) except Exception as ex: msg.logError(ex) msg.showReady() msg.clearMessage()
def show_results(self): header_labels_set = False self.show_results_event.clear() t0 = time.monotonic() counter = 0 try: msg.showBusy() while not self._new_uids_queue.empty(): counter += 1 row = [] new_uid = self._new_uids_queue.get() try: entry = self.get_run_by_uid(new_uid) row_data = self.apply_search_result_row(entry) except SkipRow as e: msg.showMessage(str(msg)) msg.logError(e) continue if not header_labels_set: # Set header labels just once. threads.invoke_in_main_thread( self.search_results_model.setHorizontalHeaderLabels, list(row_data)) header_labels_set = True for value in row_data.values(): item = QStandardItem() item.setData(value, Qt.DisplayRole) item.setData(new_uid, Qt.UserRole) row.append(item) if QThread.currentThread().isInterruptionRequested(): self.show_results_event.set() msg.logMessage("Interrupt requested") return threads.invoke_in_main_thread( self.search_results_model.appendRow, row) if counter: self.sig_update_header.emit() duration = time.monotonic() - t0 msg.showMessage("Displayed {} new results {}.".format( counter, duration)) self.show_results_event.set() except Exception as e: msg.showMessage("Error displaying runs") msg.logError(e) finally: msg.hideBusy()
def run_workflow(self, **kwargs): mixed_kwargs = self.kwargs.copy() if self.kwargs_callable is not None: try: msg.showBusy() called_kwargs = self.kwargs_callable(self) except RuntimeError as e: # NOTE: we do not want to raise an exception here (we are in a connected Qt slot) # Grab the user-oriented message from the kwargs callable exception msg.notifyMessage(str(e), title="Run Workflow Error", level=msg.ERROR) msg.logError(e) else: mixed_kwargs.update(called_kwargs) mixed_kwargs.update(kwargs) if self.execute_iterative: self.workflow.execute_all(**mixed_kwargs) else: self.workflow.execute(**mixed_kwargs)
def process_queue(self): while True: try: priority_plan = self.queue.get( block=True, timeout=.1) # timeout is arbitrary, we'll come right back except Empty: continue priority, (args, kwargs) = priority_plan.priority, priority_plan.args self.sigStart.emit() msg.showBusy() try: self.RE(*args, **kwargs) except Exception as ex: msg.showMessage( "An error occured during a Bluesky plan. See the Xi-CAM log for details." ) msg.logError(ex) self.sigException.emit(ex) finally: msg.showReady() self.sigFinish.emit()