예제 #1
0
def run_parameter_exploration(
        locator,
        pe_id,
        extra_info={},
        reason="Console Mode Parameter Exploration Execution"):
    """run_parameter_exploration(w_list: (locator, version),
                                 pe_id: str/int,
                                 reason: str) -> (pe_id, [error msg])
    Run parameter exploration in w, and returns an interpreter result object.
    version can be a tag name or a version id.
    
    """
    if is_running_gui():
        from vistrails.gui.vistrail_controller import VistrailController as \
             GUIVistrailController
        try:
            (v, abstractions, thumbnails, mashups) = load_vistrail(locator)
            controller = GUIVistrailController(v, locator, abstractions,
                                               thumbnails, mashups)
            try:
                pe_id = int(pe_id)
                pe = controller.vistrail.get_paramexp(pe_id)
            except ValueError:
                pe = controller.vistrail.get_named_paramexp(pe_id)
            controller.change_selected_version(pe.action_id)
            controller.executeParameterExploration(pe,
                                                   extra_info=extra_info,
                                                   showProgress=False)
        except Exception, e:
            return (locator, pe_id, debug.format_exception(e),
                    debug.format_exc())
예제 #2
0
    def open_workflow(self, locator):
        if isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)

        new_locator = UntitledLocator()
        controller = self.open_vistrail(new_locator)
        try:
            if locator is None:
                return False
            workflow = locator.load(Pipeline)
            action_list = []
            for module in workflow.module_list:
                action_list.append(('add', module))
            for connection in workflow.connection_list:
                action_list.append(('add', connection))
            action = vistrails.core.db.action.create_action(action_list)
            controller.add_new_action(action)
            controller.perform_action(action)
            controller.vistrail.set_tag(action.id, "Imported workflow")
            controller.change_selected_version(action.id)
        except VistrailsDBException as e:
            debug.unexpected_exception(e)
            debug.critical("Exception from the database: %s" % e,
                           debug.format_exc())
            return None

        controller.select_latest_version()
        controller.set_changed(True)
        return controller
예제 #3
0
    def open_workflow(self, locator):
        if isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)

        new_locator = UntitledLocator()
        controller = self.open_vistrail(new_locator)
        try:
            if locator is None:
                return False
            workflow = locator.load(Pipeline)
            action_list = []
            for module in workflow.module_list:
                action_list.append(('add', module))
            for connection in workflow.connection_list:
                action_list.append(('add', connection))
            action = vistrails.core.db.action.create_action(action_list)
            controller.add_new_action(action)
            controller.perform_action(action)
            controller.vistrail.set_tag(action.id, "Imported workflow")
            controller.change_selected_version(action.id)
        except VistrailsDBException:
            debug.critical("Exception from the database", debug.format_exc())
            return None

        controller.select_latest_version()
        controller.set_changed(True)
        return controller
예제 #4
0
def run_parameter_exploration(locator, pe_id, extra_info = {},
                              reason="Console Mode Parameter Exploration Execution"):
    """run_parameter_exploration(w_list: (locator, version),
                                 pe_id: str/int,
                                 reason: str) -> (pe_id, [error msg])
    Run parameter exploration in w, and returns an interpreter result object.
    version can be a tag name or a version id.
    
    """
    if is_running_gui():
        from vistrails.gui.vistrail_controller import VistrailController as \
             GUIVistrailController
        try:
            (v, abstractions , thumbnails, mashups)  = load_vistrail(locator)
            controller = GUIVistrailController(v, locator, abstractions, 
                                               thumbnails, mashups)
            try:
                pe_id = int(pe_id)
                pe = controller.vistrail.get_paramexp(pe_id)
            except ValueError:
                pe = controller.vistrail.get_named_paramexp(pe_id)
            controller.change_selected_version(pe.action_id)
            controller.executeParameterExploration(pe, extra_info=extra_info,
                                                   showProgress=False)
        except Exception, e:
            return (locator, pe_id,
                    debug.format_exception(e), debug.format_exc())
예제 #5
0
 def runAndGetCellEvents(self, useDefaultValues=False):
     spreadsheetController.setEchoMode(True)
     #will run to get Spreadsheet Cell events
     cellEvents = []
     errors = []
     try:
         (res, errors) = self.run(useDefaultValues)
         if res:
             cellEvents = spreadsheetController.getEchoCellEvents()
     except Exception, e:
         debug.unexpected_exception(e)
         print "Executing pipeline failed:", debug.format_exc()
예제 #6
0
 def runAndGetCellEvents(self, useDefaultValues=False):
     spreadsheetController.setEchoMode(True)
     # will run to get Spreadsheet Cell events
     cellEvents = []
     errors = []
     try:
         (res, errors) = self.run(useDefaultValues)
         if res:
             cellEvents = spreadsheetController.getEchoCellEvents()
     except Exception, e:
         debug.unexpected_exception(e)
         print "Executing pipeline failed:", debug.format_exc()
예제 #7
0
파일: vistrail.py 프로젝트: Nikea/VisTrails
    def reload(self, vistrail):
        if vistrail is not None:
            self.set_vistrail(vistrail)

            for version_id in self.vistrail.get_tagMap():
                self.add_workflow_entity(version_id)
            
            #mashups
            if hasattr(self.vistrail, 'mashups'):
                self._mshp_tag_map = {}
                for mashuptrail in self.vistrail.mashups:
                    self._mshp_tag_map[mashuptrail.id] = \
                         self.add_mashup_entities_from_mashuptrail(mashuptrail)

            #parameter explorations
            if hasattr(self.vistrail, 'parameter_explorations'):
                self.pe_entity_map = {}
                # find named pe's
                #max_pe = {}
                for pe in self.vistrail.parameter_explorations:
                    if pe.name:
                        self.pe_entity_map[pe.name] = \
                             self.add_parameter_exploration_entity(pe)
                #    if pe.action_id not in max_pe or max_pe[pe.action_id]<pe.id:
                #        max_pe[pe.action_id] = pe

                #for pe in max_pe.values():
                #    if pe.id not in self.pe_entity_map:
                #        self.pe_entity_map[pe.id] = \
                #             self.add_parameter_exploration_entity(pe)
                
            # read persisted log entries
            log = None
            try:
                log = vistrail.get_persisted_log()
            except Exception, e:
                debug.unexpected_exception(e)
                debug.critical("Failed to read log", debug.format_exc())
                
            if log is not None:
                for wf_exec in log.workflow_execs:
                    self.add_wf_exec_entity(wf_exec, False)

            # read unpersisted log entries
            if vistrail.log is not None:
                for wf_exec in self.vistrail.log.workflow_execs:
                    self.add_wf_exec_entity(wf_exec, True)

            self._vt_tag_map = copy.copy(self.vistrail.get_tagMap())
예제 #8
0
    def reload(self, vistrail):
        if vistrail is not None:
            self.set_vistrail(vistrail)

            for version_id in self.vistrail.get_tagMap():
                self.add_workflow_entity(version_id)

            #mashups
            if hasattr(self.vistrail, 'mashups'):
                self._mshp_tag_map = {}
                for mashuptrail in self.vistrail.mashups:
                    self._mshp_tag_map[mashuptrail.id] = \
                         self.add_mashup_entities_from_mashuptrail(mashuptrail)

            #parameter explorations
            if hasattr(self.vistrail, 'parameter_explorations'):
                self.pe_entity_map = {}
                # find named pe's
                #max_pe = {}
                for pe in self.vistrail.parameter_explorations:
                    if pe.name:
                        self.pe_entity_map[pe.name] = \
                             self.add_parameter_exploration_entity(pe)
                #    if pe.action_id not in max_pe or max_pe[pe.action_id]<pe.id:
                #        max_pe[pe.action_id] = pe

                #for pe in max_pe.values():
                #    if pe.id not in self.pe_entity_map:
                #        self.pe_entity_map[pe.id] = \
                #             self.add_parameter_exploration_entity(pe)

            # read persisted log entries
            log = None
            try:
                log = vistrail.get_persisted_log()
            except Exception, e:
                debug.unexpected_exception(e)
                debug.critical("Failed to read log", debug.format_exc())

            if log is not None:
                for wf_exec in log.workflow_execs:
                    self.add_wf_exec_entity(wf_exec, False)

            # read unpersisted log entries
            if vistrail.log is not None:
                for wf_exec in self.vistrail.log.workflow_execs:
                    self.add_wf_exec_entity(wf_exec, True)

            self._vt_tag_map = copy.copy(self.vistrail.get_tagMap())
예제 #9
0
 def add_workflow_entity(self, version_id):
     if version_id not in self.vistrail.actionMap:
         return
     action = self.vistrail.actionMap[version_id]
     tag = None
     if self.vistrail.has_tag(version_id):
         tag = self.vistrail.get_tag(version_id)
     try:
         workflow = self.vistrail.getPipeline(version_id)
     except Exception, e:
         debug.unexpected_exception(e)
         debug.critical(
             "Failed to construct pipeline '%s'" %
             (tag if tag else version_id), debug.format_exc())
         workflow = self.vistrail.getPipeline(0)
예제 #10
0
파일: vistrail.py 프로젝트: Nikea/VisTrails
 def add_workflow_entity(self, version_id):
     if version_id not in self.vistrail.actionMap:
         return
     action = self.vistrail.actionMap[version_id]
     tag = None
     if self.vistrail.has_tag(version_id):
         tag = self.vistrail.get_tag(version_id)
     try:
         workflow = self.vistrail.getPipeline(version_id)
     except Exception, e:
         debug.unexpected_exception(e)
         debug.critical("Failed to construct pipeline '%s'" % 
                            (tag if tag else version_id),
                        debug.format_exc())
         workflow = self.vistrail.getPipeline(0)
예제 #11
0
def getVersionDAO(version=None):
    if version is None:
        version = currentVersion
    persistence_dir = 'vistrails.db.versions.' + get_version_name(version) + \
        '.persistence'
    try:
        persistence = __import__(persistence_dir, {}, {}, [''])
    except ImportError as e:
        if str(e).startswith('No module named v'):
            # assume version is not available
            msg = "Cannot find DAO for version '%s'" % version
            raise VistrailsDBException(msg)
        # assume other error
        import traceback
        raise VistrailsDBException(debug.format_exc())
    return persistence.DAOList()
예제 #12
0
def getVersionDAO(version=None):
    if version is None:
        version = currentVersion
    persistence_dir = 'vistrails.db.versions.' + get_version_name(version) + \
        '.persistence'
    try:
        persistence = __import__(persistence_dir, {}, {}, [''])
    except ImportError as e:
        if str(e).startswith('No module named v'):
            # assume version is not available
            msg = "Cannot find DAO for version '%s'" % version
            raise VistrailsDBException(msg)
        # assume other error
        import traceback
        raise VistrailsDBException(debug.format_exc())
    return persistence.DAOList()
예제 #13
0
    def open_vistrail(self, locator=None, version=None, is_abstraction=False):
        if isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)
        elif locator is None:
            locator = UntitledLocator()

        controller = self.ensure_vistrail(locator)
        if controller is None:
            # vistrail is not already open
            try:
                loaded_objs = vistrails.core.db.io.load_vistrail(
                    locator, is_abstraction)
                controller = self.add_vistrail(loaded_objs[0], locator,
                                               *loaded_objs[1:])
                if locator.is_untitled():
                    return controller
                controller.is_abstraction = is_abstraction
                thumb_cache = ThumbnailCache.getInstance()
                controller.vistrail.thumbnails = controller.find_thumbnails(
                    tags_only=thumb_cache.conf.tagsOnly)
                controller.vistrail.abstractions = controller.find_abstractions(
                    controller.vistrail, True)
                controller.vistrail.mashups = controller._mashups
                collection = Collection.getInstance()
                url = locator.to_url()
                entity = collection.updateVistrail(url, controller.vistrail)
                # add to relevant workspace categories
                if not controller.is_abstraction:
                    collection.add_to_workspace(entity)
                collection.commit()
            except VistrailsDBException as e:
                debug.unexpected_exception(e)
                debug.critical("Exception from the database: %s" % e,
                               debug.format_exc())
                return None

        version = self.convert_version(version)
        if version is None:
            controller.select_latest_version()
            version = controller.current_version
        self.select_version(version)
        return controller
예제 #14
0
    def open_vistrail(self, locator=None, version=None, is_abstraction=False):
        if isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)
        elif locator is None:
            locator = UntitledLocator()

        controller = self.ensure_vistrail(locator)
        if controller is None:
            # vistrail is not already open
            try:
                loaded_objs = vistrails.core.db.io.load_vistrail(locator, is_abstraction)
                controller = self.add_vistrail(loaded_objs[0], locator, 
                                               *loaded_objs[1:])
                if locator.is_untitled():
                    return controller
                controller.is_abstraction = is_abstraction
                thumb_cache = ThumbnailCache.getInstance()
                controller.vistrail.thumbnails = controller.find_thumbnails(
                    tags_only=thumb_cache.conf.tagsOnly)
                controller.vistrail.abstractions = controller.find_abstractions(
                    controller.vistrail, True)
                controller.vistrail.mashups = controller._mashups
                collection = Collection.getInstance()
                url = locator.to_url()
                entity = collection.updateVistrail(url, controller.vistrail)
                # add to relevant workspace categories
                if not controller.is_abstraction:
                    collection.add_to_workspace(entity)
                collection.commit()
            except VistrailsDBException as e:
                debug.unexpected_exception(e)
                debug.critical("Exception from the database: %s" % e,
                               debug.format_exc())
                return None

        version = self.convert_version(version)
        if version is None:
            controller.select_latest_version()
            version = controller.current_version
        self.select_version(version)
        return controller
예제 #15
0
    def save_vistrail(self, locator=None, controller=None, export=False):
        if controller is None:
            controller = self.get_current_controller()
            if controller is None:
                return False
        if locator is None and controller is not None:
            locator = controller.locator
        elif isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)

        if not locator:
            return False
        old_locator = controller.locator

        controller.flush_delayed_actions()
        try:
            controller.write_vistrail(locator, export=export)
        except Exception, e:
            debug.unexpected_exception(e)
            debug.critical("Failed to save vistrail", debug.format_exc())
            raise
예제 #16
0
    def save_vistrail(self, locator=None, controller=None, export=False):
        if controller is None:
            controller = self.get_current_controller()
            if controller is None:
                return False
        if locator is None and controller is not None:
            locator = controller.locator
        elif isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)

        if not locator:
            return False
        old_locator = controller.locator

        controller.flush_delayed_actions()
        try:
            controller.write_vistrail(locator, export=export)
        except Exception, e:
            debug.unexpected_exception(e)
            debug.critical("Failed to save vistrail", debug.format_exc())
            raise
예제 #17
0
 def add_wf_exec_entity(self, wf_exec, add_to_map=False):
     version_id = wf_exec.parent_version
     is_new = False
     if version_id not in self.wf_entity_map:
         is_new = True
         # FIXME add new workflow entity for this version
         if version_id not in self.vistrail.actionMap:
             raise LookupError("Version %d does not occur in vistrail." %
                               version_id)
         action = self.vistrail.actionMap[version_id]
         try:
             workflow = self.vistrail.getPipeline(version_id)
         except Exception, e:
             debug.unexpected_exception(e)
             if self.vistrail.has_tag(version_id):
                 tag_str = self.vistrail.get_tag(version_id)
             else:
                 tag_str = str(version_id)
             debug.critical("Failed to construct pipeline '%s'" % tag_str,
                            debug.format_exc())
             workflow = self.vistrail.getPipeline(0)
         wf_entity = self.create_workflow_entity(workflow, action)
         self.wf_entity_map[version_id] = wf_entity
예제 #18
0
파일: vistrail.py 프로젝트: Nikea/VisTrails
 def add_wf_exec_entity(self, wf_exec, add_to_map=False):
     version_id = wf_exec.parent_version
     is_new = False
     if version_id not in self.wf_entity_map:
         is_new = True
         # FIXME add new workflow entity for this version
         if version_id not in self.vistrail.actionMap:
             raise LookupError("Version %d does not occur in vistrail." %
                               version_id)
         action = self.vistrail.actionMap[version_id]
         try:
             workflow = self.vistrail.getPipeline(version_id)
         except Exception, e:
             debug.unexpected_exception(e)
             if self.vistrail.has_tag(version_id):
                 tag_str = self.vistrail.get_tag(version_id)
             else:
                 tag_str = str(version_id)
             debug.critical("Failed to construct pipeline '%s'" % tag_str,
                            debug.format_exc())
             workflow = self.vistrail.getPipeline(0)
         wf_entity = self.create_workflow_entity(workflow, action)
         self.wf_entity_map[version_id] = wf_entity
예제 #19
0
                    for me in mes.module_errors:
                        me.module.logging.end_update(me.module, me)
                        logging_obj.signalError(me.module, me)
                        abort = abort or me.abort
                except ModuleError, me:
                    me.module.logging.end_update(me.module, me, me.errorTrace)
                    logging_obj.signalError(me.module, me)
                    abort = me.abort
                except ModuleBreakpoint, mb:
                    mb.module.logging.end_update(mb.module)
                    logging_obj.signalError(mb.module, mb)
                    abort = True
                except Exception, e:
                    debug.unexpected_exception(e)
                    debug.critical("Exception running generators: %s" % e,
                                   debug.format_exc())
                    abort = True
                if stop_on_error or abort:
                    break

        Generator.generators = self._streams.pop()

        if self.done_update_hook:
            self.done_update_hook(self._persistent_pipeline, self._objects)

        # objs, errs, and execs are mappings that use the local ids as keys,
        # as opposed to the persistent ids.
        # They are thus ideal to external consumption.
        objs = {}
        # dict([(i, self._objects[tmp_to_persistent_module_map[i]])
        #              for i in tmp_to_persistent_module_map.keys()])
예제 #20
0
        try:
            thumb_cache = ThumbnailCache.getInstance()
            controller.vistrail.thumbnails = controller.find_thumbnails(
                tags_only=thumb_cache.conf.tagsOnly)
            controller.vistrail.abstractions = controller.find_abstractions(
                controller.vistrail, True)
            controller.vistrail.mashups = controller._mashups

            collection = Collection.getInstance()
            url = locator.to_url()
            entity = collection.updateVistrail(url, controller.vistrail)
            # add to relevant workspace categories
            collection.add_to_workspace(entity)
            collection.commit()
        except Exception, e:
            debug.critical('Failed to index vistrail', debug.format_exc())
        return controller.locator

    def close_vistrail(self, locator=None, controller=None):
        if controller is None:
            controller = self.get_current_controller()
            if controller is None:
                return False
        if locator is None and controller is not None:
            locator = controller.locator
        elif isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)

        controller.close_vistrail(locator)
        controller.cleanup()
        self.remove_vistrail(locator)
예제 #21
0
        try:
            thumb_cache = ThumbnailCache.getInstance()
            controller.vistrail.thumbnails = controller.find_thumbnails(
                tags_only=thumb_cache.conf.tagsOnly)
            controller.vistrail.abstractions = controller.find_abstractions(
                controller.vistrail, True)
            controller.vistrail.mashups = controller._mashups

            collection = Collection.getInstance()
            url = locator.to_url()
            entity = collection.updateVistrail(url, controller.vistrail)
            # add to relevant workspace categories
            collection.add_to_workspace(entity)
            collection.commit()
        except Exception, e:
            debug.critical('Failed to index vistrail', debug.format_exc())
        return controller.locator

    def close_vistrail(self, locator=None, controller=None):
        if controller is None:
            controller = self.get_current_controller()
            if controller is None:
                return False
        if locator is None and controller is not None:
            locator = controller.locator
        elif isinstance(locator, basestring):
            locator = BaseLocator.from_url(locator)
        
        controller.close_vistrail(locator)
        controller.cleanup()
        self.remove_vistrail(locator)
예제 #22
0
                    for me in mes.module_errors:
                        me.module.logging.end_update(me.module, me)
                        logging_obj.signalError(me.module, me)
                        abort = abort or me.abort
                except ModuleError, me:
                    me.module.logging.end_update(me.module, me, me.errorTrace)
                    logging_obj.signalError(me.module, me)
                    abort = me.abort
                except ModuleBreakpoint, mb:
                    mb.module.logging.end_update(mb.module)
                    logging_obj.signalError(mb.module, mb)
                    abort = True
                except Exception, e:
                    debug.unexpected_exception(e)
                    debug.critical("Exception running generators: %s" % e,
                                   debug.format_exc())
                    abort = True
                if stop_on_error or abort:
                    break

        Generator.generators = self._streams.pop()

        if self.done_update_hook:
            self.done_update_hook(self._persistent_pipeline, self._objects)
                
        # objs, errs, and execs are mappings that use the local ids as keys,
        # as opposed to the persistent ids.
        # They are thus ideal to external consumption.
        objs = {}
        # dict([(i, self._objects[tmp_to_persistent_module_map[i]])
        #              for i in tmp_to_persistent_module_map.keys()])