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: import traceback debug.critical("Failed to construct pipeline '%s'" % (tag if tag else version_id), traceback.format_exc()) workflow = self.vistrail.getPipeline(0) if tag: workflow.name = tag # if workflow already exists, we want to update it... # spin through self.children and look for matching # workflow entity? # self.children.append(WorkflowEntity(workflow)) self.wf_entity_map[version_id] = \ self.create_workflow_entity(workflow, action) # get thumbnail thumbnail = self.vistrail.get_thumbnail(version_id) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) self.wf_entity_map[action.id].children.append(entity) entity.parent = self.wf_entity_map[action.id] return self.wf_entity_map[version_id]
def add_mashup_entities_from_mashuptrail(self, mashuptrail): added_entry_keys = set() inv_tag_map = {} tagMap = mashuptrail.getTagMap() tags = tagMap.keys() if len(tags) > 0: tags.sort() for tag in tags: version_id = tagMap[tag] inv_tag_map[version_id] = tag action = mashuptrail.actionMap[version_id] mashup = mashuptrail.getMashup(version_id) mashup.name = tag #make sure we identify a mashup by its version mashup.id = action.id entity_key = (mashuptrail.id,version_id) self.mshp_entity_map[entity_key] = \ self.create_mashup_entity(mashuptrail.id, mashup, action) added_entry_keys.add(entity_key) # get thumbnail for the workflow it points thumb_version = mashuptrail.vtVersion thumbnail = self.vistrail.get_thumbnail(thumb_version) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) mshp_entity = self.mshp_entity_map[entity_key] mshp_entity.children.append(entity) entity.parent = mshp_entity return inv_tag_map
def add_mashup_entity(self, mashuptrail, version_id, tag=None): if not hasattr(self.vistrail, 'mashups'): return if mashuptrail not in self.vistrail.mashups: return action = mashuptrail.actionMap[version_id] mashup = mashuptrail.getMashup(version_id) if tag: mashup.name = tag mashup.id = action.id entity_key = (mashuptrail.id,version_id) self.mshp_entity_map[entity_key] = \ self.create_mashup_entity(mashuptrail.id, mashup, action) # get thumbnail for the workflow it points thumb_version = mashuptrail.vtVersion thumbnail = self.vistrail.get_thumbnail(thumb_version) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) mshp_entity = self.mshp_entity_map[entity_key] mshp_entity.children.append(entity) entity.parent = mshp_entity return self.mshp_entity_map[entity_key]
def add_mashup_entities_from_mashuptrail(self, mashuptrail): added_entry_keys = set() inv_tag_map = {} tagMap = mashuptrail.getTagMap() tags = tagMap.keys() if len(tags) > 0: tags.sort() for tag in tags: version_id = tagMap[tag] inv_tag_map[version_id] = tag action = mashuptrail.actionMap[version_id] mashup = mashuptrail.getMashup(version_id) mashup.name = tag #make sure we identify a mashup by its version mashup.id = action.id entity_key = (mashuptrail.id, version_id) self.mshp_entity_map[entity_key] = \ self.create_mashup_entity(mashuptrail.id, mashup, action) added_entry_keys.add(entity_key) # get thumbnail for the workflow it points thumb_version = mashuptrail.vtVersion thumbnail = self.vistrail.get_thumbnail(thumb_version) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) mshp_entity = self.mshp_entity_map[entity_key] mshp_entity.children.append(entity) entity.parent = mshp_entity return inv_tag_map
def add_mashup_entity(self, mashuptrail, version_id, tag=None): if not hasattr(self.vistrail, 'mashups'): return if mashuptrail not in self.vistrail.mashups: return action = mashuptrail.actionMap[version_id] mashup = mashuptrail.getMashup(version_id) if tag: mashup.name = tag mashup.id = action.id entity_key = (mashuptrail.id, version_id) self.mshp_entity_map[entity_key] = \ self.create_mashup_entity(mashuptrail.id, mashup, action) # get thumbnail for the workflow it points thumb_version = mashuptrail.vtVersion thumbnail = self.vistrail.get_thumbnail(thumb_version) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) mshp_entity = self.mshp_entity_map[entity_key] mshp_entity.children.append(entity) entity.parent = mshp_entity return self.mshp_entity_map[entity_key]
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: import traceback debug.critical( "Failed to construct pipeline '%s'" % (tag if tag else version_id), traceback.format_exc()) workflow = self.vistrail.getPipeline(0) if tag: workflow.name = tag # if workflow already exists, we want to update it... # spin through self.children and look for matching # workflow entity? # self.children.append(WorkflowEntity(workflow)) self.wf_entity_map[version_id] = \ self.create_workflow_entity(workflow, action) # get thumbnail thumbnail = self.vistrail.get_thumbnail(version_id) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) self.wf_entity_map[action.id].children.append(entity) entity.parent = self.wf_entity_map[action.id] return self.wf_entity_map[version_id]
def add_parameter_exploration_entity(self, pe): if not hasattr(self.vistrail, 'parameter_explorations'): return self.pe_entity_map[pe.name] = \ self.create_parameter_exploration_entity(pe) # get thumbnail for the workflow it points thumbnail = self.vistrail.get_thumbnail(pe.action_id) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) pe_entity = self.pe_entity_map[pe.name] pe_entity.children.append(entity) entity.parent = self return self.pe_entity_map[pe.name]
class VistrailEntity(Entity): type_id = 1 def __init__(self, vistrail=None): Entity.__init__(self) self.id = None self.wf_entity_map = {} self.mshp_entity_map = {} self.pe_entity_map = {} self.wf_exec_entity_map = {} self._vt_tag_map = {} self._mshp_tag_map = {} # self._last_wf_exec_id = None self.reload(vistrail) @staticmethod def create(*args): entity = VistrailEntity() entity.load(*args) 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_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 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_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 get_vistrail_info(self, vistrail=None): if vistrail is None: vistrail = self.vistrail name = None if vistrail.locator: name = vistrail.locator.short_name if name is None: if vistrail.db_name: name = vistrail.db_name else: name = u"untitled" size = vistrail.get_version_count() if size < 1: # empty vistrail user = vistrails.core.system.current_user() mod_time = vistrails.core.system.current_time() create_time = vistrails.core.system.current_time() else: latestVersionId = vistrail.get_latest_version() latestVersion = vistrail.actionMap[latestVersionId] user = latestVersion.user mod_time = latestVersion.db_date # FIXME: relies on 1 being the first version... firstVersion = vistrail.actionMap[1] \ if 1 in vistrail.actionMap else latestVersion create_time = firstVersion.db_date url = vistrail.locator.to_url() if vistrail.locator else "untitled:" return (name, size, user, mod_time, create_time, url) def set_vistrail(self, vistrail): self.vistrail = vistrail (self.name, self.size, self.user, self.mod_time, self.create_time, \ self.url) = self.get_vistrail_info() self.description = "" self.was_updated = True 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) if tag: workflow.name = tag # if workflow already exists, we want to update it... # spin through self.children and look for matching # workflow entity? # self.children.append(WorkflowEntity(workflow)) self.wf_entity_map[version_id] = \ self.create_workflow_entity(workflow, action) # get thumbnail thumbnail = self.vistrail.get_thumbnail(version_id) if thumbnail is not None: cache = ThumbnailCache.getInstance() path = cache.get_abs_name_entry(thumbnail) if path: entity = ThumbnailEntity(path) self.wf_entity_map[action.id].children.append(entity) entity.parent = self.wf_entity_map[action.id] return self.wf_entity_map[version_id]