Ejemplo n.º 1
0
 def previewChanges(self, aliases):
     print "previewChanges", aliases
     # we will just execute the pipeline with the given alias dictionary
     controller = VistrailController()
     controller.set_vistrail(self.plot_vistrail, self.locator)
     version = self.plot_vistrail.get_version_number(
         self.workflow_tag
     ) if self.workflow_tag else controller.get_latest_version_in_graph()
     controller.change_selected_version(version)
     (results, _) = controller.execute_current_workflow(aliases)
Ejemplo n.º 2
0
 def previewChanges(self, aliases):
     print "previewChanges", aliases
     # we will just execute the pipeline with the given alias dictionary
     controller = VistrailController()
     controller.set_vistrail(self.plot_vistrail, self.locator)
     version = self.plot_vistrail.get_version_number(self.workflow_tag) if self.workflow_tag else controller.get_latest_version_in_graph()
     controller.change_selected_version(version)
     (results, _) = controller.execute_current_workflow(aliases)
Ejemplo n.º 3
0
    def load(self, loadworkflow=True):
        config = ConfigParser.ConfigParser()
        if config.read(self.config_file):
            if config.has_section('global'):
                if config.has_option('global', 'cellnum'):
                    self.cellnum = config.getint('global', 'cellnum')
                if config.has_option('global', 'filenum'):
                    self.filenum = config.getint('global', 'filenum')
                if config.has_option('global', 'varnum'):
                    self.varnum = config.getint('global', 'varnum')
                    print "   ------ Loaded plot %s, varnum = %d ------ " % ( self.name, self.varnum )
                if config.has_option('global', 'workflow_tag'):
                    self.workflow_tag = config.get('global', 'workflow_tag')
#                else:
#                    debug.warning("CDAT Package: file %s does not contain a required option 'workflow_tag'. Widget will not be loaded."%self.config_file)
#                    self.loaded = False
#                    return
                if config.has_option('global', 'filetypes'):
                    types = config.get('global', 'filetypes')
                    tlist = [t.strip() for t in types.split(";")]
                    for t in tlist:
                        kv = t.split(":")
                        self.filetypes[kv[0].strip()] = [v.strip() 
                                                         for v in kv[1].split(",")]
                if config.has_option('global', 'qt_filter'):
                    self.qt_filter = config.get('global', 'qt_filter')
                if config.has_option('global', 'dependencies'):
                    deps = config.get('global', 'dependencies')
                    self.dependencies = [d.strip() for d in deps.split(",")]
            
                if config.has_option('global', 'serialized_config_alias'):
                    self.serializedConfigAlias = config.get('global', 'serialized_config_alias')

                    for y in range(self.filenum):
                        self.files.append( 'Filename' + str(y+1) )
                            
                    for v in range(self.varnum):
                        self.vars.append( 'VariableName' + str(v+1) )
                        self.axes.append( 'Axes' + str(v+1) )

                    for x in range(self.cellnum):
                        section_name = 'cell' + str(x+1)
                        if config.has_section(section_name):
                            cellType = config.get(section_name, 'celltype')
                            if config.has_option(section_name, 'address_alias'):
                                self.cells.append( Cell( cellType, None, None,
                                                     config.get(section_name, 'address_alias') ) )
                            else:
                                self.cells.append(Cell( cellType,"Row"+str(x+1), "Column"+str(x+1) ) )                                                              
                else:
                    
                    for y in range(self.filenum):
                        option_name = 'filename_alias' + str(y+1)
                        if config.has_option('global', option_name):
                            self.files.append(config.get('global', option_name))
                            
                    for v in range(self.varnum):
                        option_name = 'varname_alias' + str(v+1)
                        if config.has_option('global', option_name):
                            self.vars.append(config.get('global', option_name))
                        axes_name = 'axes_alias' + str(v+1)
                        if config.has_option('global', axes_name):
                            self.axes.append(config.get('global', axes_name))
                        
                    for x in range(self.cellnum):
                        section_name = 'cell' + str(x+1)
                        if (config.has_section(section_name) and
                            config.has_option(section_name, 'celltype') and
                            config.has_option(section_name, 'row_alias') and
                            config.has_option(section_name, 'col_alias')):
                            self.cells.append(Cell(config.get(section_name, 'celltype'),
                                                   config.get(section_name, 'row_alias'),
                                                   config.get(section_name, 'col_alias')))
                
                if loadworkflow:
                    #load workflow in vistrail
                    #only if dependencies are enabled
                    manager = get_package_manager()
                    self.unsatisfied_deps = []
                    for dep in self.dependencies:
                        if not manager.has_package(dep):
                            self.unsatisfied_deps.append(dep)
                    if len(self.unsatisfied_deps) == 0:
                        try:
                            (self.plot_vistrail, abstractions , thumbnails, mashups) = load_vistrail(self.locator)
                            controller = VistrailController()
                            controller.set_vistrail(self.plot_vistrail, self.locator, 
                                                    abstractions, thumbnails,
                                                    mashups) 
    
                            self.workflow_version = self.plot_vistrail.get_version_number(self.workflow_tag) if self.workflow_tag else controller.get_latest_version_in_graph()
                            print " Loaded %s version: %s" % (  self.name, str( self.workflow_version ) )
                            controller.change_selected_version(self.workflow_version)
                            self.workflow = controller.current_pipeline
                            self.loaded = True
                        except Exception, err:
                            debug.warning( "Error loading workflow %s: %s" % ( self.name, err ) )
                            self.loaded = False
                    else:
                        debug.warning("UV-CDAT: %s widget could not be loaded \
    because it depends on packages that are not loaded:"%self.name)
                        debug.warning("  %s"%", ".join(self.unsatisfied_deps))
                        self.loaded = False
            else:
                debug.warning("UV-CDAT: file %s does not contain a 'global'\
 section. Widget will not be loaded."%self.config_file)
                self.loaded = False
Ejemplo n.º 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
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