def run(self, controller, name): if self.search_str: reportusage.record_feature('query', controller) if self.queryPipeline is not None and \ len(self.queryPipeline.modules) > 0: VisualQuery.run(self, controller, name) compiler = SearchCompiler(self.search_str, self.use_regex) self.search_stmt = compiler.searchStmt
def run(self, controller, name): reportusage.record_feature('visualquery', controller) result = [] self.tupleLength = 2 for version in self.versions_to_check: from vistrails.core.configuration import get_vistrails_configuration hide_upgrades = getattr(get_vistrails_configuration(), 'hideUpgrades', True) if hide_upgrades: version = controller.create_upgrade(version, delay_update=True) p = controller.get_pipeline(version, do_validate=False) matches = set() queryModuleNameIndex = {} for moduleId, module in p.modules.iteritems(): append_to_dict_of_lists(queryModuleNameIndex, module.name, moduleId) for querySourceId in self.queryPipeline.graph.sources(): querySourceName = self.queryPipeline.modules[ querySourceId].name if not queryModuleNameIndex.has_key(querySourceName): # need to reset matches here! matches = set() continue candidates = queryModuleNameIndex[querySourceName] atLeastOneMatch = False for candidateSourceId in candidates: querySource = self.queryPipeline.modules[querySourceId] candidateSource = p.modules[candidateSourceId] if not self.matchQueryModule(candidateSource, querySource): continue (match, targetIds) = self.heuristicDAGIsomorphism \ (template = self.queryPipeline, target = p, template_ids = [querySourceId], target_ids = [candidateSourceId]) if match: atLeastOneMatch = True matches.update(targetIds) # We always perform AND operation if not atLeastOneMatch: matches = set() break for m in matches: result.append((version, m)) self.queryResult = result self.computeIndices() return result
def run(self, controller, name): reportusage.record_feature('visualquery', controller) result = [] self.tupleLength = 2 for version in self.versions_to_check: from vistrails.core.configuration import get_vistrails_configuration hide_upgrades = getattr(get_vistrails_configuration(), 'hideUpgrades', True) if hide_upgrades: version = controller.create_upgrade(version, delay_update=True) p = controller.get_pipeline(version, do_validate=False) matches = set() queryModuleNameIndex = {} for moduleId, module in p.modules.iteritems(): append_to_dict_of_lists(queryModuleNameIndex, module.name, moduleId) for querySourceId in self.queryPipeline.graph.sources(): querySourceName = self.queryPipeline.modules[querySourceId].name if not queryModuleNameIndex.has_key(querySourceName): # need to reset matches here! matches = set() continue candidates = queryModuleNameIndex[querySourceName] atLeastOneMatch = False for candidateSourceId in candidates: querySource = self.queryPipeline.modules[querySourceId] candidateSource = p.modules[candidateSourceId] if not self.matchQueryModule(candidateSource, querySource): continue (match, targetIds) = self.heuristicDAGIsomorphism \ (template = self.queryPipeline, target = p, template_ids = [querySourceId], target_ids = [candidateSourceId]) if match: atLeastOneMatch = True matches.update(targetIds) # We always perform AND operation if not atLeastOneMatch: matches = set() break for m in matches: result.append((version, m)) self.queryResult = result self.computeIndices() return result
def performParameterExploration(self): """ performParameterExploration() -> None Perform the exploration by collecting a list of actions corresponding to each dimension """ reportusage.record_feature('paramexplore', self.controller) registry = get_module_registry() actions = self.peWidget.table.collectParameterActions() spreadsheet_pkg = 'org.vistrails.vistrails.spreadsheet' # 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(spreadsheet_pkg, 'CellLocation') and registry.has_module(spreadsheet_pkg, '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_scene, 'module_executed_hook': [moduleExecuted], 'reason': 'Parameter Exploration', 'actions': performedActions[pi], } interpreter.execute(modifiedPipelines[pi], **kwargs) progress.setValue(totalProgress)
def performParameterExploration(self): """ performParameterExploration() -> None Perform the exploration by collecting a list of actions corresponding to each dimension """ reportusage.record_feature('paramexplore', self.controller) registry = get_module_registry() actions = self.peWidget.table.collectParameterActions() spreadsheet_pkg = 'org.vistrails.vistrails.spreadsheet' # 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(spreadsheet_pkg, 'CellLocation') and registry.has_module(spreadsheet_pkg, '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_scene, 'module_executed_hook': [moduleExecuted], 'reason': 'Parameter Exploration', 'actions': performedActions[pi], } interpreter.execute(modifiedPipelines[pi], **kwargs) progress.setValue(totalProgress)