def processFunctionStack(self, callback, finished=None, dims=None, fixed_func=None, prange=None): """ Runs the FunctionManager's loadPreviewData on a background thread to create the partial function stack and corresponding dictionary for running slice previews and 3D previews. Parameters ---------- callback : function function to be called with the return values of manager.loadPreviewData: partial_stack, stack_dict This function is either self.run3DPreview or self.runSlicePreview finished : function/QtCore.Slot, optional Slot to receive the background threads finished signal dims : typle, optional Tuple containing dimensions of dataset to be reconstructed fixed_func : type class A dynamic class with only the necessary attributes to be run in a workflow pipeline. This is used for parameter range tests to create the class with the parameter to be run and send it to a background thread. See FunctionManager.testParameterRange for more details prange: dict, optional Dictionary containing parameter being tested for TestParamRange, and the function the parameter belongs to """ bg_functionstack = threads.method(callback_slot=callback, finished_slot=finished, lock=threads.mutex)( self.manager.loadPreviewData) bg_functionstack(self.centerwidget.widget(self.currentIndex()), dims=dims, ncore=cpu_count(), fixed_func=fixed_func, prange=prange)
def addPulseJob(self, job_type, job_desc, method, args, kwargs): job_entry = self.addJob(job_type, job_desc) job_entry.sigRemove.connect(self.removeJob) job_entry.pulseStart() bg_method = threads.method( finished_slot=job_entry.pulseStop, interrupt_signal=job_entry.sigCancel)(method) bg_method(*args, **kwargs)
def currentChanged(self, current, previous): item = self.itemFromIndex(current) try: if item.childCount() == 0: msg.showMessage('Loading preview...') dataset = item.parent().parent().text(0) stage = item.parent().text(0) bg_get_preview = threads.method( callback_slot=self.sigItemPreview.emit, except_slot=self.handleException)(self.client.get_image_as) bg_get_preview(dataset, stage, index=0) except AttributeError: pass
def foldPreviewStack(self, partial_stack, initializer, data_dict, callback, error_message): """ Calls the managers foldFunctionStack on a background thread. This is what tells the manager to compute a slice preview or a 3D preview from a specified workflow pipeline Parameters ---------- partial_stack : list of functools.partial List of partials that require only the input array to run. initializer : ndarray Array to use as initializer for folding operation callback : function function to be called with the return value of the fold (ie the resulting reconstruction). This is the current TomoViewers addSlicePreview or add3DPreview methods error_message : str Message to log/display if the fold process raises an exception """ except_slot = lambda: msg.showMessage(error_message) bg_fold = threads.method(callback_slot=callback, finished_slot=msg.clearMessage, lock=threads.mutex, except_slot=except_slot) # bg_fold(self.manager.foldFunctionStack)(partial_stack, initializer) bg_fold(self.manager.foldSliceStack)(partial_stack, data_dict)
def processFunctionStack(self, callback, finished=None, slc=None, fixed_func=None, prange=None): """ Runs the FunctionManager's loadPreviewData on a background thread to create the partial function stack and corresponding dictionary for running slice previews and 3D previews. Parameters ---------- callback : function function to be called with the return values of manager.loadPreviewData: partial_stack, stack_dict This function is either self.run3DPreview or self.runSlicePreview finished : function/QtCore.Slot, optional Slot to receive the background threads finished signal slc : slice slice object specifying the slices to take from the input tomographic array fixed_func : type class A dynamic class with only the necessary attributes to be run in a workflow pipeline. This is used for parameter range tests to create the class with the parameter to be run and send it to a background thread. See FunctionManager.testParameterRange for more details """ bg_functionstack = threads.method(callback_slot=callback, finished_slot=finished, lock=threads.mutex)(self.manager.loadPreviewData) bg_functionstack(self.centerwidget.widget(self.currentWidget()), slc=slc, ncore=cpu_count(), fixed_func=fixed_func, prange=prange)
def run_wf(self, wf_title): paw = self._paws[wf_title] if wf_title == self._current_wf_title(): self.run_wf_button.setText(self._stop_button_text) # harvest file list and (maybe) PyFAI.AzimuthalIntegrator settings # from GUI and Xi-cam internal variables, respectively file_list = [] nfiles = self.batch_list.count() for r in range(nfiles): p = self.batch_list.item(r).text() file_list.append(p) paw.set_input('Batch Execution', 'input_arrays', [file_list], None, self._batch_wf_names[wf_title]) if wf_title in ['saxs integrator']: paw.set_input('Integrator Setup', 'poni_dict', config.activeExperiment.getAI().getPyFAI(), None, self._batch_wf_names[wf_title]) #if wfmanager.client is not None: # wfmanager.run_paws(paw) #else: run_off_thread = threads.method()(paw.execute) run_off_thread(self._batch_wf_names[wf_title])
def getDatasets(self, query): msg.showMessage('Searching SPOT database...') search = threads.method(callback_slot=self.createDatasetDictionary, finished_slot=msg.clearMessage)( self.client.search) search(query, **self.search_params)
def addSFTPJob(self, job_desc, method, args, kwargs, finish_slot=None): job_entry = self.addJob(job_desc) kwargs['callback'] = job_entry.progressRaw bg_method = threads.method(finished_slot=finish_slot)(method) bg_method(*args, **kwargs)