def convert(_module_exec): if _module_exec.__class__ == ModuleExec: return _module_exec.__class__ = ModuleExec for annotation in _module_exec.annotations: Annotation.convert(annotation) for loop_exec in _module_exec.loop_execs: LoopExec.convert(loop_exec)
def convert(_abstraction): if _abstraction.__class__ == Abstraction: return _abstraction.__class__ = Abstraction if _abstraction.db_location: Location.convert(_abstraction.db_location) for _function in _abstraction.db_functions: ModuleFunction.convert(_function) for _annotation in _abstraction.db_get_annotations(): Annotation.convert(_annotation) _abstraction.set_defaults()
def convert(_module): if _module.__class__ == Module: return _module.__class__ = Module for _port_spec in _module.db_portSpecs: PortSpec.convert(_port_spec) if _module.db_location: Location.convert(_module.db_location) for _function in _module.db_functions: ModuleFunction.convert(_function) for _annotation in _module.db_get_annotations(): Annotation.convert(_annotation) _module.set_defaults()
def convert(_wf_exec): if _wf_exec.__class__ == WorkflowExec: return _wf_exec.__class__ = WorkflowExec for annotation in _wf_exec.annotations: Annotation.convert(annotation) for item_exec in _wf_exec.item_execs: if item_exec.vtType == ModuleExec.vtType: ModuleExec.convert(item_exec) elif item_exec.vtType == GroupExec.vtType: GroupExec.convert(item_exec) elif item_exec.vtType == LoopExec.vtType: LoopExec.convert(item_exec)
def convert(_abstraction_module): if _abstraction_module.__class__ == AbstractionModule: return _abstraction_module.__class__ = AbstractionModule if _abstraction_module.db_location: Location.convert(_abstraction_module.db_location) for _function in _abstraction_module.db_functions: ModuleFunction.convert(_function) for _annotation in _abstraction_module.db_get_annotations(): Annotation.convert(_annotation) _abstraction_module.portVisible = set() _abstraction_module._registry = None _abstraction_module.abstraction = None
def convert(_module): _module.__class__ = Module _module.registry = None for _port_spec in _module.db_portSpecs: PortSpec.convert(_port_spec) _module.add_port_to_registry(_port_spec) if _module.db_location: Location.convert(_module.db_location) for _function in _module.db_functions: ModuleFunction.convert(_function) for _annotation in _module.db_get_annotations(): Annotation.convert(_annotation) _module.portVisible = set()
def convert(_group): if _group.__class__ == Group: return _group.__class__ = Group if _group.db_location: Location.convert(_group.db_location) if _group.db_workflow: from core.vistrail.pipeline import Pipeline Pipeline.convert(_group.db_workflow) for _function in _group.db_functions: ModuleFunction.convert(_function) for _annotation in _group.db_get_annotations(): Annotation.convert(_annotation) _group.set_defaults()
def convert(_group): if _group.__class__ == Group: return _group.__class__ = Group _group._registry = None _group.portVisible = set() if _group.db_location: Location.convert(_group.db_location) if _group.db_workflow: from core.vistrail.pipeline import Pipeline Pipeline.convert(_group.db_workflow) for _function in _group.db_functions: ModuleFunction.convert(_function) for _annotation in _group.db_get_annotations(): Annotation.convert(_annotation)
def convert(_action): if _action.__class__ == Action: return _action.__class__ = Action for _annotation in _action.annotations: Annotation.convert(_annotation) for _operation in _action.operations: if _operation.vtType == 'add': AddOp.convert(_operation) elif _operation.vtType == 'change': ChangeOp.convert(_operation) elif _operation.vtType == 'delete': DeleteOp.convert(_operation) else: raise Exception("Unknown operation type '%s'" % \ _operation.vtType)
def insert_module_annotations(self, module, a_dict): for k,v in a_dict.iteritems(): a_id = self.log.id_scope.getNewId(Annotation.vtType) annotation = Annotation(id=a_id, key=k, value=v) if hasattr(module, 'is_group'): module.group_exec.add_annotation(annotation) else: module.module_exec.add_annotation(annotation)
def insert_workflow_exec_annotations(self, a_dict): """insert_workflow_exec_annotations(a_dict)-> None This will create an annotation for each pair in a_dict in self.workflow_exec""" if self.workflow_exec: for k,v in a_dict.iteritems(): a_id = self.log.id_scope.getNewId(Annotation.vtType) annotation = Annotation(id=a_id, key=k, value=v) self.workflow_exec.add_annotation(annotation)
def create_ops(self, id_scope=IdScope()): from core.vistrail.module import Module from core.vistrail.module_function import ModuleFunction from core.vistrail.module_param import ModuleParam from core.vistrail.annotation import Annotation if id_scope is None: id_scope = IdScope( remap={ AddOp.vtType: 'operation', ChangeOp.vtType: 'operation', DeleteOp.vtType: 'operation' }) m = Module(id=id_scope.getNewId(Module.vtType), name='Float', package='edu.utah.sci.vistrails.basic') add_op = AddOp(id=id_scope.getNewId(AddOp.vtType), what=Module.vtType, objectId=m.id, data=m) function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType), name='value') change_op = ChangeOp(id=id_scope.getNewId(ChangeOp.vtType), what=ModuleFunction.vtType, oldObjId=2, newObjId=function.real_id, parentObjId=m.id, parentObjType=Module.vtType, data=function) param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType), type='Float', val='1.0') delete_op = DeleteOp(id=id_scope.getNewId(DeleteOp.vtType), what=ModuleParam.vtType, objectId=param.real_id, parentObjId=function.real_id, parentObjType=ModuleFunction.vtType) annotation = Annotation(id=id_scope.getNewId(Annotation.vtType), key='foo', value='bar') add_annotation = AddOp(id=id_scope.getNewId(AddOp.vtType), what=Annotation.vtType, objectId=m.id, data=annotation) return [add_op, change_op, delete_op, add_annotation]
def finish_module_execution(self, module, error, errorTrace=None, suspended=False): module.module_exec.ts_end = core.system.current_time() if suspended: module.module_exec.completed = -2 module.module_exec.error = error elif not error: module.module_exec.completed = 1 else: module.module_exec.completed = -1 module.module_exec.error = error if errorTrace: a_id = self.log.id_scope.getNewId(Annotation.vtType) annotation = Annotation(id=a_id, key="errorTrace", value=errorTrace) module.module_exec.add_annotation(annotation) del module.module_exec if module.is_fold_module: return True
def convert(_module_exec): if _module_exec.__class__ == ModuleExec: return _module_exec.__class__ = ModuleExec for annotation in _module_exec.annotations: Annotation.convert(annotation)
def replace_generic(controller, pipeline, old_module, new_module, function_remap={}, src_port_remap={}, dst_port_remap={}, annotation_remap={}): ops = [] ops.extend(controller.delete_module_list_ops(pipeline, [old_module.id])) for annotation in old_module.annotations: if annotation.key not in annotation_remap: annotation_key = annotation.key else: remap = annotation_remap[annotation.key] if remap is None: # don't add the annotation back in continue elif type(remap) != type(""): ops.extend(remap(annotation)) continue else: annotation_key = remap new_annotation = \ Annotation(id=controller.id_scope.getNewId(Annotation.vtType), key=annotation_key, value=annotation.value) new_module.add_annotation(new_annotation) if not old_module.is_group() and not old_module.is_abstraction(): for port_spec in old_module.port_spec_list: if port_spec.type == 'input': if port_spec.name not in dst_port_remap: spec_name = port_spec.name else: remap = dst_port_remap[port_spec.name] if remap is None: continue elif type(remap) != type(""): ops.extend(remap(port_spec)) continue else: spec_name = remap elif port_spec.type == 'output': if port_spec.name not in src_port_remap: spec_name = port_spec.name else: remap = src_port_remap[port_spec.name] if remap is None: continue elif type(remap) != type(""): ops.extend(remap(port_spec)) continue else: spec_name = remap new_spec = port_spec.do_copy(True, controller.id_scope, {}) new_spec.name = spec_name new_module.add_port_spec(new_spec) for function in old_module.functions: if function.name not in function_remap: function_name = function.name else: remap = function_remap[function.name] if remap is None: # don't add the function back in continue elif type(remap) != type(""): ops.extend(remap(function, new_module)) continue else: function_name = remap if len(function.parameters) > 0: new_param_vals, aliases = zip(*[(p.strValue, p.alias) for p in function.parameters]) else: new_param_vals = [] aliases = [] new_function = controller.create_function(new_module, function_name, new_param_vals, aliases) new_module.add_function(new_function) # add the new module ops.append(('add', new_module)) create_new_connection = UpgradeWorkflowHandler.create_new_connection for _, conn_id in pipeline.graph.edges_from(old_module.id): old_conn = pipeline.connections[conn_id] if old_conn.source.name not in src_port_remap: source_name = old_conn.source.name else: remap = src_port_remap[old_conn.source.name] if remap is None: # don't add this connection back in continue elif type(remap) != type(""): ops.extend(remap(old_conn, new_module)) continue else: source_name = remap old_dst_module = pipeline.modules[old_conn.destination.moduleId] new_conn = create_new_connection(controller, new_module, source_name, old_dst_module, old_conn.destination) ops.append(('add', new_conn)) for _, conn_id in pipeline.graph.edges_to(old_module.id): old_conn = pipeline.connections[conn_id] if old_conn.destination.name not in dst_port_remap: destination_name = old_conn.destination.name else: remap = dst_port_remap[old_conn.destination.name] if remap is None: # don't add this connection back in continue elif type(remap) != type(""): ops.extend(remap(old_conn, new_module)) continue else: destination_name = remap old_src_module = pipeline.modules[old_conn.source.moduleId] new_conn = create_new_connection(controller, old_src_module, old_conn.source, new_module, destination_name) ops.append(('add', new_conn)) return [core.db.action.create_action(ops)]