Beispiel #1
0
def get_vt_graph(vt_list, tree_info, pdf=False):
    """get_vt_graph(vt_list: list of locator, tree_info:str)
    Load all vistrails in vt_list and dump their tree to tree_info.
    
    """
    result = []
    if is_running_gui():
        from gui.vistrail_controller import VistrailController as \
             GUIVistrailController
        for locator in vt_list:
            try:
                (v, abstractions, thumbnails, mashups) = load_vistrail(locator)
                controller = GUIVistrailController()
                if tree_info is not None:
                    from gui.version_view import QVersionTreeView
                    version_view = QVersionTreeView()
                    from gui.pipeline_view import QPipelineView
                    pipeline_view = QPipelineView()
                    controller.current_pipeline_view = pipeline_view.scene()
                    controller.set_vistrail(v, locator, abstractions,
                                            thumbnails, mashups)
                    version_view.scene().setupScene(controller)
                    if pdf:
                        base_fname = "graph_%s.pdf" % locator.short_name
                        filename = os.path.join(tree_info, base_fname)
                        version_view.scene().saveToPDF(filename)
                    else:
                        base_fname = "graph_%s.png" % locator.short_name
                        filename = os.path.join(tree_info, base_fname)
                        version_view.scene().saveToPNG(filename)
                    del version_view
                    result.append((True, ""))
            except Exception, e:
                result.append((False, str(e)))
Beispiel #2
0
def get_wf_graph(w_list, workflow_info=None, pdf=False):
    """run_and_get_results(w_list: list of (locator, version), 
                           workflow_info:str, pdf:bool)
    Load all workflows in wf_list and dump their graph to workflow_info.
    
    """
    result = []
    if is_running_gui():
        from gui.vistrail_controller import VistrailController as \
             GUIVistrailController
        for locator, workflow in w_list:
            try:
                (v, abstractions, thumbnails, mashups) = load_vistrail(locator)
                controller = GUIVistrailController()
                if type(workflow) == type("str"):
                    version = v.get_version_number(workflow)
                elif type(workflow) in [type(1), long]:
                    version = workflow
                elif workflow is None:
                    version = controller.get_latest_version_in_graph()
                else:
                    msg = "Invalid version tag or number: %s" % workflow
                    raise VistrailsInternalError(msg)
                controller.change_selected_version(version)

                if (workflow_info is not None
                        and controller.current_pipeline is not None):
                    from gui.pipeline_view import QPipelineView
                    pipeline_view = QPipelineView()
                    controller.current_pipeline_view = pipeline_view.scene()
                    controller.set_vistrail(v, locator, abstractions,
                                            thumbnails, mashups)
                    pipeline_view.scene().setupScene(
                        controller.current_pipeline)
                    if pdf:
                        base_fname = "%s_%s_pipeline.pdf" % (
                            locator.short_name, version)
                        filename = os.path.join(workflow_info, base_fname)
                        pipeline_view.scene().saveToPDF(filename)
                    else:
                        base_fname = "%s_%s_pipeline.png" % (
                            locator.short_name, version)
                        filename = os.path.join(workflow_info, base_fname)
                        pipeline_view.scene().saveToPNG(filename)
                    del pipeline_view
                    result.append((True, ""))
            except Exception, e:
                result.append((False, str(e)))
Beispiel #3
0
    def __init__(self, parent=None):
        """ QPipelineTab(parent: QWidget) -> QPipelineTab        
        Make it a main window with dockable area and a QPipelineView
        in the middle
        
        """
        QDockContainer.__init__(self, parent)
        self.setWindowTitle('Pipeline')
        self.pipelineView = QPipelineView()
        self.pipelineView.scene().pipeline_tab = proxy(self)
        self.setCentralWidget(self.pipelineView)
        self.toolWindow().setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
        self.toolWindow().hide()

        self.methodPalette = QMethodPalette(self)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.methodPalette.toolWindow())

        self.moduleMethods = QModuleMethods(self)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.moduleMethods.toolWindow())

        self.moduleConfig = QModuleConfiguration(self,
                                                 self.pipelineView.scene())
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.moduleConfig.toolWindow())

        self.vistrailVars = QVistrailVariables(self)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.vistrailVars.toolWindow())

        self.connect(self.toolWindow(), QtCore.SIGNAL('topLevelChanged(bool)'),
                     self.updateWindowTitle)
        self.connect(self.pipelineView.scene(),
                     QtCore.SIGNAL('moduleSelected'), self.moduleSelected)
        self.connect(self.moduleConfig, QtCore.SIGNAL('doneConfigure'),
                     self.pipelineView.scene().perform_configure_done_actions)
        self.connect(self.pipelineView.scene(),
                     QtCore.SIGNAL('showConfigureWindow'),
                     self.moduleConfig.activate)
        self.connect(self.pipelineView, QtCore.SIGNAL('resetQuery()'),
                     self.resetQuery)

        self.controller = None
Beispiel #4
0
def run_and_get_results(w_list,
                        parameters='',
                        workflow_info=None,
                        update_vistrail=True,
                        extra_info=None,
                        reason='Console Mode Execution'):
    """run_and_get_results(w_list: list of (locator, version), parameters: str,
                           workflow_info:str, update_vistrail: boolean,
                           extra_info:dict)
    Run all workflows in w_list, and returns an interpreter result object.
    version can be a tag name or a version id.
    
    """
    elements = parameters.split("$&$")
    aliases = {}
    result = []
    for locator, workflow in w_list:
        (v, abstractions, thumbnails, mashups) = load_vistrail(locator)
        controller = VistrailController(auto_save=update_vistrail)
        controller.set_vistrail(v, locator, abstractions, thumbnails, mashups)
        if type(workflow) == type("str"):
            version = v.get_version_number(workflow)
        elif type(workflow) in [type(1), long]:
            version = workflow
        elif workflow is None:
            version = controller.get_latest_version_in_graph()
        else:
            msg = "Invalid version tag or number: %s" % workflow
            raise VistrailsInternalError(msg)
        controller.change_selected_version(version)

        for e in elements:
            pos = e.find("=")
            if pos != -1:
                key = e[:pos].strip()
                value = e[pos + 1:].strip()

                if controller.current_pipeline.has_alias(key):
                    aliases[key] = value

        if workflow_info is not None and controller.current_pipeline is not None:
            if is_running_gui():
                from gui.pipeline_view import QPipelineView
                pipeline_view = QPipelineView()
                pipeline_view.scene().setupScene(controller.current_pipeline)
                base_fname = "%s_%s_pipeline.pdf" % (locator.short_name,
                                                     version)
                filename = os.path.join(workflow_info, base_fname)
                pipeline_view.scene().saveToPDF(filename)
                del pipeline_view
            else:
                debug.critical("Cannot save pipeline figure when not "
                               "running in gui mode")
            base_fname = "%s_%s_pipeline.xml" % (locator.short_name, version)
            filename = os.path.join(workflow_info, base_fname)
            core.db.io.save_workflow(controller.current_pipeline, filename)
        if not update_vistrail:
            conf = get_vistrails_configuration()
            if conf.has('thumbs'):
                conf.thumbs.autoSave = False

        (results, _) = \
            controller.execute_current_workflow(custom_aliases=aliases,
                                                extra_info=extra_info,
                                                reason=reason)
        new_version = controller.current_version
        if new_version != version:
            debug.warning("Version '%s' (%s) was upgraded. The actual "
                          "version executed was %s" % \
                              (workflow, version, new_version))
        run = results[0]
        run.workflow_info = (locator.name, new_version)
        run.pipeline = controller.current_pipeline

        if update_vistrail:
            controller.write_vistrail(locator)
        result.append(run)
    return result