def performParameterExploration(self): """ performParameterExploration() -> None Perform the exploration by collecting a list of actions corresponding to each dimension """ actions = self.peWidget.table.collectParameterActions() if self.controller.current_pipeline and actions: explorer = ActionBasedParameterExploration() (pipelines, performedActions) = explorer.explore( self.controller.current_pipeline, actions) dim = [max(1, len(a)) for a in actions] if (registry.has_module('edu.utah.sci.vistrails.spreadsheet', 'CellLocation') and registry.has_module('edu.utah.sci.vistrails.spreadsheet', 'SheetReference')): modifiedPipelines = self.virtualCell.positionPipelines( 'PE#%d %s' % (QParameterExplorationTab.explorationId, self.controller.name), dim[2], dim[1], dim[0], pipelines) else: modifiedPipelines = pipelines mCount = [] for p in modifiedPipelines: if len(mCount)==0: mCount.append(0) else: mCount.append(len(p.modules)+mCount[len(mCount)-1]) # Now execute the pipelines totalProgress = sum([len(p.modules) for p in modifiedPipelines]) progress = QtGui.QProgressDialog('Performing Parameter ' 'Exploration...', '&Cancel', 0, totalProgress) progress.setWindowTitle('Parameter Exploration') progress.setWindowModality(QtCore.Qt.WindowModal) progress.show() QParameterExplorationTab.explorationId += 1 interpreter = get_default_interpreter() for pi in xrange(len(modifiedPipelines)): progress.setValue(mCount[pi]) QtCore.QCoreApplication.processEvents() if progress.wasCanceled(): break def moduleExecuted(objId): if not progress.wasCanceled(): progress.setValue(progress.value()+1) QtCore.QCoreApplication.processEvents() interpreter.execute( None, modifiedPipelines[pi], self.controller.locator, self.controller.current_version, self.controller.current_pipeline_view, moduleExecutedHook=[moduleExecuted], reason='Parameter Exploration', actions=performedActions[pi]) progress.setValue(totalProgress)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent=parent) self.app = gui.application.get_vistrails_application() self.inspector = QObjectInspector() layout = QtGui.QVBoxLayout() layout.setMargin(0) layout.setSpacing(0) layout.addWidget(self.inspector) self.setLayout(layout) # self.setTitleBarWidget(QtGui.QLabel("Debugger")) self.setWindowTitle("Debugger") self.controller = None self.vistrails_interpreter = get_default_interpreter() self.vistrails_interpreter.debugger = self
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent=parent) #locals() returns the original dictionary, not a copy as #the docs say self.firstLocals = copy.copy(locals()) self.shell = QShell(self.firstLocals, None) layout = QtGui.QVBoxLayout() layout.setMargin(0) layout.setSpacing(0) layout.addWidget(self.shell) self.setLayout(layout) # self.setWidget(self.shell) self.setWindowTitle(self.shell.windowTitle()) # self.setTitleBarWidget(QtGui.QLabel(self.shell.windowTitle())) # self.monitorWindowTitle(self.shell) self.vistrails_interpreter = get_default_interpreter()
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent=parent) #locals() returns the original dictionary, not a copy as #the docs say self.firstLocals = copy.copy(locals()) self.shell = QShell(self.firstLocals,None) layout = QtGui.QVBoxLayout() layout.setMargin(0) layout.setSpacing(0) layout.addWidget(self.shell) self.setLayout(layout) # self.setWidget(self.shell) self.setWindowTitle(self.shell.windowTitle()) # self.setTitleBarWidget(QtGui.QLabel(self.shell.windowTitle())) # self.monitorWindowTitle(self.shell) self.vistrails_interpreter = get_default_interpreter()
def execute_workflow_list(self, vistrails): """execute_workflow_list(vistrails: [(name, version, pipeline, view]) -> None Executes a list of pipelines, where: - name: str is the vistrails filename - version: int is the version number - pipeline: Pipeline object - view: interface to a QPipelineScene """ interpreter = get_default_interpreter() for vis in vistrails: (locator, version, pipeline, view) = vis (objs, errors, executed) = interpreter.execute(None, pipeline, locator, version, view)
def executePipelineWithProgress(pipeline, pTitle='Pipeline Execution', pCaption='Executing...', pCancel='&Cancel', **kwargs): """ executePipelineWithProgress(pipeline: Pipeline, pTitle: str, pCaption: str, pCancel: str, kwargs: keyword arguments) -> bool Execute the pipeline while showing a progress dialog with title pTitle, caption pCaption and the cancel button text pCancel. kwargs is the keyword arguments that will be passed to the interpreter. A bool will be returned indicating if the execution was performed without cancel or not. """ withoutCancel = True totalProgress = len(pipeline.modules) progress = QtGui.QProgressDialog(pCaption, pCancel, 0, totalProgress) progress.setWindowTitle(pTitle) progress.setWindowModality(QtCore.Qt.WindowModal) progress.show() def moduleExecuted(objId): if not progress.wasCanceled(): progress.setValue(progress.value() + 1) QtCore.QCoreApplication.processEvents() else: withoutCancel = False interpreter = get_default_interpreter() if kwargs.has_key('module_executed_hook'): kwargs['module_executed_hook'].append(moduleExecuted) else: kwargs['module_executed_hook'] = [moduleExecuted] kwargs['view'] = DummyView() interpreter.execute(pipeline, **kwargs) progress.setValue(totalProgress) return withoutCancel
def executePipelineWithProgress(pipeline, pTitle='Pipeline Execution', pCaption='Executing...', pCancel='&Cancel', **kwargs): """ executePipelineWithProgress(pipeline: Pipeline, pTitle: str, pCaption: str, pCancel: str, kwargs: keyword arguments) -> bool Execute the pipeline while showing a progress dialog with title pTitle, caption pCaption and the cancel button text pCancel. kwargs is the keyword arguments that will be passed to the interpreter. A bool will be returned indicating if the execution was performed without cancel or not. """ withoutCancel = True totalProgress = len(pipeline.modules) progress = QtGui.QProgressDialog(pCaption, pCancel, 0, totalProgress) progress.setWindowTitle(pTitle) progress.setWindowModality(QtCore.Qt.WindowModal) progress.show() def moduleExecuted(objId): if not progress.wasCanceled(): progress.setValue(progress.value()+1) QtCore.QCoreApplication.processEvents() else: withoutCancel = False interpreter = get_default_interpreter() if kwargs.has_key('module_executed_hook'): kwargs['module_executed_hook'].append(moduleExecuted) else: kwargs['module_executed_hook'] = [moduleExecuted] kwargs['view'] = DummyView() interpreter.execute(pipeline, **kwargs) progress.setValue(totalProgress) return withoutCancel
def openSpreadsheet(self, fileName): """ openSpreadsheet(fileName: str) -> None Open a saved spreadsheet assuming that all VTK files must exist and have all the version using the saved spreadsheet """ def parse_locator(text): locator = None wrapper = XMLWrapper() dom = wrapper.create_document_from_string(text) root = dom.documentElement version = None version = root.getAttribute('version') if version == '1.0': for element in named_elements(root, 'locator'): if str(element.getAttribute('type')) == 'file': locator = FileLocator.parse(element) elif str(element.getAttribute('type')) == 'db': locator = DBLocator.parse(element) return locator locators = {} indexFile = open(fileName, 'r') contents = indexFile.read() self.clearTabs() lidx = 0 lines = contents.split('\n') tabCount = int(lines[lidx]) lidx += 1 for tabIdx in xrange(tabCount): # FIXME: eval should pretty much never be used tabInfo = eval(lines[lidx]) lidx += 1 sheet = spreadsheetRegistry.getSheet(tabInfo[1])(self) sheet.setDimension(tabInfo[2], tabInfo[3]) self.addTabWidget(sheet, tabInfo[0]) while lines[lidx]!='---': (r, c, vistrail, pid, cid) = eval(lines[lidx]) locator = vistrail['locator'] if locators.has_key(locator): vistrail['locator'] = locators[locator] else: locators[locator] = parse_locator(vistrail['locator']) vistrail['locator'] = locators[locator] self.appendMonitoredLocations((vistrail, pid, cid), (sheet, r, c)) lidx += 1 lidx += 1 pipelineCount = int(lines[lidx]) lidx += 1 self.loadingMode = True progress = QtGui.QProgressDialog("Loading spreadsheet...", "&Cancel", 0, pipelineCount, self, QtCore.Qt.WindowStaysOnTopHint ); progress.show() for pipelineIdx in xrange(pipelineCount): # FIXME: eval should pretty much never be used (serializedLocator, version) = eval(lines[lidx]) try: locator = locators[serializedLocator] except KeyError: locator = parse_locator(serializedLocator) if locator: bundle = locator.load() if isinstance(bundle, SaveBundle): pipeline = bundle.vistrail.getPipeline(version) else: pipeline = bundle.getPipeline(version) execution = get_default_interpreter() progress.setValue(pipelineIdx) QtCore.QCoreApplication.processEvents() if progress.wasCanceled(): break kwargs = {'locator': locator, 'current_version': version, 'view': DummyView(), } execution.execute(pipeline, **kwargs) else: raise Exception("Couldn't load spreadsheet") lidx += 1 progress.setValue(pipelineCount) QtCore.QCoreApplication.processEvents() self.changeSpreadsheetFileName(fileName) self.loadingMode = False indexFile.close()
def performParameterExploration(self): """ performParameterExploration() -> None Perform the exploration by collecting a list of actions corresponding to each dimension """ registry = get_module_registry() actions = self.peWidget.table.collectParameterActions() # Set the annotation to persist the parameter exploration # TODO: For now, we just replace the existing exploration - Later we should append them. xmlString = "<paramexps>\n" + self.getParameterExploration() + "\n</paramexps>" self.controller.vistrail.set_paramexp(self.currentVersion, xmlString) self.controller.set_changed(True) if self.controller.current_pipeline and actions: explorer = ActionBasedParameterExploration() (pipelines, performedActions) = explorer.explore( self.controller.current_pipeline, actions) dim = [max(1, len(a)) for a in actions] if (registry.has_module('edu.utah.sci.vistrails.spreadsheet', 'CellLocation') and registry.has_module('edu.utah.sci.vistrails.spreadsheet', 'SheetReference')): modifiedPipelines = self.virtualCell.positionPipelines( 'PE#%d %s' % (QParameterExplorationTab.explorationId, self.controller.name), dim[2], dim[1], dim[0], pipelines, self.controller) else: modifiedPipelines = pipelines mCount = [] for p in modifiedPipelines: if len(mCount)==0: mCount.append(0) else: mCount.append(len(p.modules)+mCount[len(mCount)-1]) # Now execute the pipelines totalProgress = sum([len(p.modules) for p in modifiedPipelines]) progress = QtGui.QProgressDialog('Performing Parameter ' 'Exploration...', '&Cancel', 0, totalProgress) progress.setWindowTitle('Parameter Exploration') progress.setWindowModality(QtCore.Qt.WindowModal) progress.show() QParameterExplorationTab.explorationId += 1 interpreter = get_default_interpreter() for pi in xrange(len(modifiedPipelines)): progress.setValue(mCount[pi]) QtCore.QCoreApplication.processEvents() if progress.wasCanceled(): break def moduleExecuted(objId): if not progress.wasCanceled(): #progress.setValue(progress.value()+1) #the call above was crashing when used by multithreaded #code, replacing with the call below (thanks to Terence #for submitting this fix). QtCore.QMetaObject.invokeMethod(progress, "setValue", QtCore.Q_ARG(int,progress.value()+1)) QtCore.QCoreApplication.processEvents() kwargs = {'locator': self.controller.locator, 'current_version': self.controller.current_version, 'view': self.controller.current_pipeline_view, 'module_executed_hook': [moduleExecuted], 'reason': 'Parameter Exploration', 'actions': performedActions[pi], } interpreter.execute(modifiedPipelines[pi], **kwargs) progress.setValue(totalProgress)
def execute(self): """ execute() -> None Perform the exploration by collecting a list of actions corresponding to each dimension """ registry = get_module_registry() actions = self.table.collectParameterActions() palette = self.get_palette() # Set the annotation to persist the parameter exploration # TODO: For now, we just replace the existing exploration - Later we should append them. xmlString = "<paramexps>\n" + self.getParameterExploration() + "\n</paramexps>" self.controller.vistrail.set_paramexp(self.controller.current_version, xmlString) self.controller.set_changed(True) if palette.pipeline and actions: explorer = ActionBasedParameterExploration() (pipelines, performedActions) = explorer.explore( palette.pipeline, actions) dim = [max(1, len(a)) for a in actions] if (registry.has_module('edu.utah.sci.vistrails.spreadsheet', 'CellLocation') and registry.has_module('edu.utah.sci.vistrails.spreadsheet', 'SheetReference')): modifiedPipelines = palette.virtual_cell.positionPipelines( 'PE#%d %s' % (QParamExploreView.explorationId, self.controller.name), dim[2], dim[1], dim[0], pipelines, self.controller) else: modifiedPipelines = pipelines mCount = [] for p in modifiedPipelines: if len(mCount)==0: mCount.append(0) else: mCount.append(len(p.modules)+mCount[len(mCount)-1]) # Now execute the pipelines totalProgress = sum([len(p.modules) for p in modifiedPipelines]) progress = QtGui.QProgressDialog('Performing Parameter ' 'Exploration...', '&Cancel', 0, totalProgress) progress.setWindowTitle('Parameter Exploration') progress.setWindowModality(QtCore.Qt.WindowModal) progress.show() QParamExploreView.explorationId += 1 interpreter = get_default_interpreter() for pi in xrange(len(modifiedPipelines)): progress.setValue(mCount[pi]) QtCore.QCoreApplication.processEvents() if progress.wasCanceled(): break def moduleExecuted(objId): if not progress.wasCanceled(): progress.setValue(progress.value()+1) QtCore.QCoreApplication.processEvents() kwargs = {'locator': self.controller.locator, 'current_version': self.controller.current_version, 'view': palette.pipeline_view.scene(), 'module_executed_hook': [moduleExecuted], 'reason': 'Parameter Exploration', 'actions': performedActions[pi], } interpreter.execute(modifiedPipelines[pi], **kwargs) progress.setValue(totalProgress)
def openSpreadsheet(self, fileName): """ openSpreadsheet(fileName: str) -> None Open a saved spreadsheet assuming that all VTK files must exist and have all the version using the saved spreadsheet """ def parse_locator(text): locator = None wrapper = XMLWrapper() dom = wrapper.create_document_from_string(text) root = dom.documentElement version = None version = root.getAttribute('version') if version == '1.0': for element in named_elements(root, 'locator'): if str(element.getAttribute('type')) == 'file': locator = FileLocator.parse(element) elif str(element.getAttribute('type')) == 'db': locator = DBLocator.parse(element) return locator locators = {} indexFile = open(fileName, 'r') contents = indexFile.read() self.clearTabs() lidx = 0 lines = contents.split('\n') tabCount = int(lines[lidx]) lidx += 1 for tabIdx in xrange(tabCount): # FIXME: eval should pretty much never be used tabInfo = eval(lines[lidx]) lidx += 1 sheet = spreadsheetRegistry.getSheet(tabInfo[1])(self) sheet.setDimension(tabInfo[2], tabInfo[3]) self.addTabWidget(sheet, tabInfo[0]) while lines[lidx] != '---': (r, c, vistrail, pid, cid) = eval(lines[lidx]) locator = vistrail['locator'] if locators.has_key(locator): vistrail['locator'] = locators[locator] else: locators[locator] = parse_locator(vistrail['locator']) vistrail['locator'] = locators[locator] self.appendMonitoredLocations((vistrail, pid, cid), (sheet, r, c)) lidx += 1 lidx += 1 pipelineCount = int(lines[lidx]) lidx += 1 self.loadingMode = True progress = QtGui.QProgressDialog("Loading spreadsheet...", "&Cancel", 0, pipelineCount, self, QtCore.Qt.WindowStaysOnTopHint) progress.show() for pipelineIdx in xrange(pipelineCount): # FIXME: eval should pretty much never be used (serializedLocator, version) = eval(lines[lidx]) try: locator = locators[serializedLocator] except KeyError: locator = parse_locator(serializedLocator) if locator: bundle = locator.load() if isinstance(bundle, SaveBundle): pipeline = bundle.vistrail.getPipeline(version) else: pipeline = bundle.getPipeline(version) execution = get_default_interpreter() progress.setValue(pipelineIdx) QtCore.QCoreApplication.processEvents() if progress.wasCanceled(): break kwargs = { 'locator': locator, 'current_version': version, 'view': DummyView(), } execution.execute(pipeline, **kwargs) else: raise Exception("Couldn't load spreadsheet") lidx += 1 progress.setValue(pipelineCount) QtCore.QCoreApplication.processEvents() self.changeSpreadsheetFileName(fileName) self.loadingMode = False indexFile.close()