def open_workflow(self, locator): if isinstance(locator, basestring): locator = BaseLocator.from_url(locator) vistrail = Vistrail() try: if locator is None: return False if locator is not None: 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) vistrail.add_action(action, 0L) vistrail.update_id_scope() vistrail.addTag("Imported workflow", action.id) # FIXME might need different locator? controller = self.add_vistrail(vistrail, locator) except VistrailsDBException, e: import traceback debug.critical("Exception from the database", traceback.format_exc()) return None
def updateVistrail(self, url, vistrail=None): """ updateVistrail(self, string:url, Vistrail:vistrail) Update the specified entity url. Delete or reload as necessary. Need to make sure workspaces are updated if the entity is changed. """ entities = [e for e in self.entities.itervalues() if e.url == url] entity = entities[0] if len(entities) else None while entity and entity.parent: entity = entity.parent url = entity.url workspaces = [p for p in self.workspaces if entity in self.workspaces[p]] if entity: for p in workspaces: self.del_from_workspace(entity, p) self.delete_entity(entity) locator = BaseLocator.from_url(url) if locator.is_valid(): if not vistrail: (vistrail, abstractions, thumbnails, mashups) = load_vistrail(locator) vistrail.abstractions = abstractions vistrail.thumbnails = thumbnails vistrail.mashups = mashups entity = self.create_vistrail_entity(vistrail) for p in workspaces: self.add_to_workspace(entity, p) return entity else: # probably an unsaved vistrail pass
def updateVistrail(self, url, vistrail=None): """ updateVistrail(self, string:url, Vistrail:vistrail) Update the specified entity url. Delete or reload as necessary. Need to make sure workspaces are updated if the entity is changed. """ entities = [e for e in self.entities.itervalues() if e.url == url] entity = entities[0] if len(entities) else None while entity and entity.parent: entity = entity.parent url = entity.url workspaces = [ p for p in self.workspaces if entity in self.workspaces[p] ] if entity: for p in workspaces: self.del_from_workspace(entity, p) self.delete_entity(entity) locator = BaseLocator.from_url(url) if locator.is_valid(): if not vistrail: (vistrail, abstractions, thumbnails, mashups) = load_vistrail(locator) vistrail.abstractions = abstractions vistrail.thumbnails = thumbnails vistrail.mashups = mashups entity = self.create_vistrail_entity(vistrail) for p in workspaces: self.add_to_workspace(entity, p) return entity else: # probably an unsaved vistrail pass
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
def load_running_jobs(self): conf = configuration.get_vistrails_configuration() if conf.has('runningJobsList') and conf.runningJobsList: for url in conf.runningJobsList.split(';'): loc, version = url.split('?') locator = BaseLocator.from_url(loc) msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Question, "Running Job Found", "Running Job Found:\n %s\n" "Continue now?" % url) msgBox.addButton("Later", msgBox.ActionRole) delete = msgBox.addButton("Delete", msgBox.ActionRole) yes = msgBox.addButton("Yes", msgBox.ActionRole) msgBox.exec_() if msgBox.clickedButton() == yes: from vistrails.gui.vistrails_window import _app _app.open_vistrail_without_prompt(locator, int(version.split('=')[1])) _app.get_current_view().execute() if msgBox.clickedButton() == delete: conf_jobs = conf.runningJobsList.split(';') conf_jobs.remove(url) conf.runningJobsList = ';'.join(conf_jobs) configuration.get_vistrails_persistent_configuration( ).runningJobsList = conf.runningJobsList else: conf.runningJobsList = '' configuration.get_vistrails_persistent_configuration( ).runningJobsList = conf.runningJobsList
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", traceback.format_exc()) return None controller.select_latest_version() controller.set_changed(True) return controller
def create_wf_exec_entity(self, wf_exec, wf_entity): entity = WorkflowExecEntity(wf_exec) wf_entity.children.append(entity) entity.parent = wf_entity locator = BaseLocator.from_url(self.url) locator.kwargs['workflow_exec'] = entity.name entity.url = locator.to_url() return entity
def __init__(self, workflow, parent): self.locator = BaseLocator.from_url(workflow.vistrail) QtGui.QTreeWidgetItem.__init__(self, parent, ['', '']) self.setToolTip(0, "Double-Click to View Pipeline") self.setToolTip(1, workflow.id) self.workflow = workflow self.has_queue = True self.setIcon(0, theme.get_current_theme().JOB_CHECKING) self.setExpanded(True) self.workflowFinished = False self.jobs = {} self.intermediates = {} self.updateJobs()
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)
def create_parameter_exploration_entity(self, pe): entity = ParameterExplorationEntity(pe) self.children.append(entity) entity.parent = self entity.name = pe.name if pe.name: entity.name = pe.name else: # find logical name using vistrail tag entity.name = "Latest for " + \ self.vistrail.get_pipeline_name(pe.action_id) locator = BaseLocator.from_url(self.url) locator.kwargs['parameterExploration'] = pe.id entity.url = locator.to_url() return entity
def create_workflow_entity(self, workflow, action): entity = WorkflowEntity(workflow) self.children.append(entity) entity.parent = self if self.vistrail.has_notes(action.id): plain_notes = extract_text(self.vistrail.get_notes(action.id)) entity.description = plain_notes else: entity.description = '' entity.user = action.user entity.mod_time = action.db_date entity.create_time = action.db_date locator = BaseLocator.from_url(self.url) locator.kwargs['version_node'] = action.id entity.url = locator.to_url() return entity
def create_workflow_entity(self, workflow, action): entity = WorkflowEntity(workflow) self.children.append(entity) entity.parent = self if self.vistrail.has_notes(action.id): plain_notes = extract_text(self.vistrail.get_notes(action.id)) entity.description = plain_notes else: entity.description = '' entity.user = action.user entity.mod_time = action.date entity.create_time = action.date locator = BaseLocator.from_url(self.url) locator.kwargs['version_node'] = action.id entity.url = locator.to_url() return entity
def create_mashup_entity(self, trail_id, mashup, action): entity = MashupEntity(mashup) self.children.append(entity) entity.parent = self vt_version = mashup.version if self.vistrail.has_notes(vt_version): plain_notes = extract_text(self.vistrail.get_notes(vt_version)) entity.description = plain_notes else: entity.description = '' entity.user = action.user entity.mod_time = action.date entity.create_time = action.date locator = BaseLocator.from_url(self.url) locator.kwargs['mashuptrail'] = trail_id locator.kwargs['mashup'] = action.id entity.url = locator.to_url() return entity
def create_mashup_entity(self, trail_id, mashup, action): entity = MashupEntity(mashup) self.children.append(entity) entity.parent = self vt_version = mashup.version if self.vistrail.has_notes(vt_version): plain_notes = extract_text(self.vistrail.get_notes(vt_version)) entity.description = plain_notes else: entity.description = '' entity.user = action.user entity.mod_time = action.db_date entity.create_time = action.db_date locator = BaseLocator.from_url(self.url) locator.kwargs['mashuptrail'] = trail_id locator.kwargs['mashup'] = action.id entity.url = locator.to_url() return entity
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
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
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
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", traceback.format_exc()) raise
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 try: controller.write_vistrail(locator, export=export) except Exception, e: import traceback debug.critical('Failed to save vistrail: %s' % str(e), traceback.format_exc()) raise
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, False) controller = self.add_vistrail(loaded_objs[0], locator, *loaded_objs[1:]) if locator.is_untitled(): return True 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, e: import traceback debug.critical("Exception from the database", traceback.format_exc()) return None except Exception, e: #debug.critical('An error has occurred', e) #print "An error has occurred", str(e) raise
def locator(self): locator = BaseLocator.from_url(self.url) return locator
def urlExists(self, url): """ Check if entity with this url exist """ locator = BaseLocator.from_url(url) if locator.is_valid(): return True return False