def remap(old_conn, new_module): controller = _get_controller() create_new_connection = UpgradeWorkflowHandler.create_new_connection pipeline = _get_pipeline() module = pipeline.modules[old_conn.source.moduleId] x = (module.location.x + new_module.location.x) / 2 y = (module.location.y + new_module.location.y) / 2 path_module = controller.create_module(basic_pkg, 'Path', '', x, y) conn1 = create_new_connection(controller, module, old_conn.source, path_module, 'name') # Avoid descriptor lookup by explicitly creating Ports input_port_id = controller.id_scope.getNewId(Port.vtType) input_port = Port(id=input_port_id, name='value', type='source', signature=(Path, ), moduleId=path_module.id, moduleName=path_module.name) output_port_id = controller.id_scope.getNewId(Port.vtType) output_port = Port(id=output_port_id, name=name, type='destination', signature=(Path, ), moduleId=new_module.id, moduleName=new_module.name) conn2 = create_new_connection(controller, path_module, input_port, new_module, output_port) return [('add', path_module), ('add', conn1), ('add', conn2)]
def create_new_connection(controller, src_module, src_port, dst_module, dst_port): # spec -> name, type, signature output_port_id = controller.id_scope.getNewId(Port.vtType) if isinstance(src_port, basestring): output_port_spec = src_module.get_port_spec(src_port, 'output') output_port = Port(id=output_port_id, spec=output_port_spec, moduleId=src_module.id, moduleName=src_module.name) else: output_port = Port(id=output_port_id, name=src_port.name, type=src_port.type, signature=src_port.signature, moduleId=src_module.id, moduleName=src_module.name) input_port_id = controller.id_scope.getNewId(Port.vtType) if isinstance(dst_port, basestring): input_port_spec = dst_module.get_port_spec(dst_port, 'input') input_port = Port(id=input_port_id, spec=input_port_spec, moduleId=dst_module.id, moduleName=dst_module.name) else: input_port = Port(id=input_port_id, name=dst_port.name, type=dst_port.type, signature=dst_port.signature, moduleId=dst_module.id, moduleName=dst_module.name) conn_id = controller.id_scope.getNewId(Connection.vtType) connection = Connection(id=conn_id, ports=[input_port, output_port]) return connection
def convert(_connection): # print "ports: %s" % _Connection._get_ports(_connection) if _connection.__class__ == Connection: return _connection.__class__ = Connection for port in _connection.ports: Port.convert(port) # _connection.sourceInfo = \ # (_connection.source.moduleName, _connection.source.sig) # _connection.destinationInfo = \ # (_connection.destination.moduleName, _connection.destination.sig) # # print _connection.sourceInfo # # print _connection.destinationInfo # portFromRepresentation = registry.portFromRepresentation # newSource = \ # portFromRepresentation(_connection.source.moduleName, # _connection.source.sig, # PortEndPoint.Source, None, True) # newDestination = \ # portFromRepresentation(_connection.destination.moduleName, # _connection.destination.sig, # PortEndPoint.Destination, None, True) # newSource.moduleId = _connection.source.moduleId # newDestination.moduleId = _connection.destination.moduleId # _connection.source = newSource # _connection.destination = newDestination _connection.makeConnection = moduleConnection(_connection)
def do_copy(self, new_ids=False, id_scope=None, id_remap=None): cp = DBConnection.do_copy(self, new_ids, id_scope, id_remap) cp.__class__ = Connection cp.makeConnection = moduleConnection(cp) for port in cp.ports: Port.convert(port) return cp
def convert(_connection): # print "ports: %s" % _Connection._get_ports(_connection) if _connection.__class__ == Connection: return _connection.__class__ = Connection for port in _connection.ports: Port.convert(port)
def __init__(self, *args, **kwargs): """__init__() -> Connection Initializes source and destination ports. """ DBConnection.__init__(self, *args, **kwargs) if self.id is None: self.db_id = -1 if not len(self.ports) > 0: self.source = Port(type='source') self.destination = Port(type='destination')
def remap(old_conn, new_module): controller = _get_controller() create_new_connection = UpgradeWorkflowHandler.create_new_connection pipeline = _get_pipeline() module1 = pipeline.modules[old_conn.destination.moduleId] dest_port = old_conn.destination candidates = [ 'AddInputData_1', 'AddInputData', 'SetInputData_1', 'SetInputData', 'AddInput', 'SetInput' ] if 'Connection' in old_conn.destination.name: _desc = reg.get_descriptor_by_name(identifier, module1.name) ports = get_port_specs(_desc, 'input') for c in candidates: if c in ports: dest_port = c break output_port_spec = get_output_port_spec(new_module, 'StructuredGrid') src_port = Port(name=output_port_spec.name, type='source', spec=output_port_spec, moduleId=new_module.id, moduleName=new_module.name) conn = create_new_connection(controller, new_module, src_port, module1, dest_port) return [('add', conn)]
def remap_dst_connections(old_module, new_module, port_remap): # FIXME need use_registry flag passed through! use_registry = True create_new_connection = UpgradeWorkflowHandler.create_new_connection ops = [] for _, conn_id in pipeline.graph.edges_to(old_module.id): old_conn = pipeline.connections[conn_id] if old_conn.destination.name in port_remap: remap = port_remap[old_conn.destination.name] if remap is None: # don't add this connection back in continue elif not isinstance(remap, basestring): ops.extend(remap(old_conn, new_module)) continue else: destination_name = remap old_src_module = pipeline.modules[old_conn.source.moduleId] if use_registry: destination_port = destination_name else: destination_port = Port(name=destination_name, type='destination', signature=create_port_spec_string([ (basic_pkg, 'Variant', '') ])) new_conn = create_new_connection(controller, old_src_module, old_conn.source, new_module, destination_port) ops.append(('add', new_conn)) return ops
def create_connection(self, id_scope=IdScope()): from vistrails.core.vistrail.port import Port from vistrails.core.modules.basic_modules import identifier as basic_pkg source = Port(id=id_scope.getNewId(Port.vtType), type='source', moduleId=21L, moduleName='String', name='value', signature='(%s:String)' % basic_pkg) destination = Port(id=id_scope.getNewId(Port.vtType), type='destination', moduleId=20L, moduleName='Float', name='value', signature='(%s:Float)' % basic_pkg) connection = Connection(id=id_scope.getNewId(Connection.vtType), ports=[source, destination]) return connection
def __init__(self, *args, **kwargs): """__init__() -> Connection Initializes source and destination ports. """ DBConnection.__init__(self, *args, **kwargs) if self.id is None: self.db_id = -1 if not len(self.ports) > 0: self.source = Port(type='source') self.destination = Port(type='destination') # self.source.endPoint = PortEndPoint.Source # self.destination.endPoint = PortEndPoint.Destination self.makeConnection = moduleConnection(self)
def do_copy(self, new_ids=False, id_scope=None, id_remap=None): cp = DBConnection.do_copy(self, new_ids, id_scope, id_remap) cp.__class__ = Connection for port in cp.ports: Port.convert(port) return cp
class Connection(DBConnection): """ A Connection is a connection between two modules. Right now there's only Module connections. """ ########################################################################## # Constructors and copy @staticmethod def from_port_specs(source, dest): """from_port_specs(source: PortSpec, dest: PortSpec) -> Connection Static method that creates a Connection given source and destination ports. """ conn = Connection() conn.source = copy.copy(source) conn.destination = copy.copy(dest) return conn @staticmethod def fromID(id): """fromTypeID(id: int) -> Connection Static method that creates a Connection given an id. """ conn = Connection() conn.id = id conn.source.endPoint = PortEndPoint.Source conn.destination.endPoint = PortEndPoint.Destination return conn def __init__(self, *args, **kwargs): """__init__() -> Connection Initializes source and destination ports. """ DBConnection.__init__(self, *args, **kwargs) if self.id is None: self.db_id = -1 if not len(self.ports) > 0: self.source = Port(type='source') self.destination = Port(type='destination') def __copy__(self): """__copy__() -> Connection - Returns a clone of self. """ return Connection.do_copy(self) def do_copy(self, new_ids=False, id_scope=None, id_remap=None): cp = DBConnection.do_copy(self, new_ids, id_scope, id_remap) cp.__class__ = Connection for port in cp.ports: Port.convert(port) return cp ########################################################################## @staticmethod def convert(_connection): # print "ports: %s" % _Connection._get_ports(_connection) if _connection.__class__ == Connection: return _connection.__class__ = Connection for port in _connection.ports: Port.convert(port) ########################################################################## # Properties id = DBConnection.db_id ports = DBConnection.db_ports def add_port(self, port): self.db_add_port(port) def _get_sourceId(self): """ _get_sourceId() -> int Returns the module id of source port. Do not use this function, use sourceId property: c.sourceId """ return self.source.moduleId def _set_sourceId(self, id): """ _set_sourceId(id : int) -> None Sets this connection source id. It updates both self.source.moduleId and self.source.id. Do not use this function, use sourceId property: c.sourceId = id """ self.source.moduleId = id self.source.id = id sourceId = property(_get_sourceId, _set_sourceId) def _get_destinationId(self): """ _get_destinationId() -> int Returns the module id of dest port. Do not use this function, use sourceId property: c.destinationId """ return self.destination.moduleId def _set_destinationId(self, id): """ _set_destinationId(id : int) -> None Sets this connection destination id. It updates self.dest.moduleId. Do not use this function, use destinationId property: c.destinationId = id """ self.destination.moduleId = id destinationId = property(_get_destinationId, _set_destinationId) def _get_source(self): """_get_source() -> Port Returns source port. Do not use this function, use source property: c.source """ try: return self.db_get_port_by_type('source') except KeyError: pass return None def _set_source(self, source): """_set_source(source: Port) -> None Sets this connection source port. Do not use this function, use source property instead: c.source = source """ try: port = self.db_get_port_by_type('source') self.db_delete_port(port) except KeyError: pass if source is not None: self.db_add_port(source) source = property(_get_source, _set_source) def _get_destination(self): """_get_destination() -> Port Returns destination port. Do not use this function, use destination property: c.destination """ # return self.db_ports['destination'] try: return self.db_get_port_by_type('destination') except KeyError: pass return None def _set_destination(self, dest): """_set_destination(dest: Port) -> None Sets this connection destination port. Do not use this function, use destination property instead: c.destination = dest """ try: port = self.db_get_port_by_type('destination') self.db_delete_port(port) except KeyError: pass if dest is not None: self.db_add_port(dest) destination = property(_get_destination, _set_destination) dest = property(_get_destination, _set_destination) ########################################################################## # Operators def __str__(self): """__str__() -> str - Returns a string representation of a Connection object. """ rep = "<connection id='%s'>%s%s</connection>" return rep % (str(self.id), str(self.source), str(self.destination)) def __ne__(self, other): return not self.__eq__(other) def __eq__(self, other): if type(other) != type(self): return False return (self.source == other.source and self.dest == other.dest) def equals_no_id(self, other): """Checks equality up to ids (connection and ports).""" if type(self) != type(other): return False return (self.source.equals_no_id(other.source) and self.dest.equals_no_id(other.dest))
class Connection(DBConnection): """ A Connection is a connection between two modules. Right now there's only Module connections. """ ########################################################################## # Constructors and copy @staticmethod def from_port_specs(source, dest): """from_port_specs(source: PortSpec, dest: PortSpec) -> Connection Static method that creates a Connection given source and destination ports. """ conn = Connection() conn.source = copy.copy(source) conn.destination = copy.copy(dest) return conn @staticmethod def fromID(id): """fromTypeID(id: int) -> Connection Static method that creates a Connection given an id. """ conn = Connection() conn.id = id conn.source.endPoint = PortEndPoint.Source conn.destination.endPoint = PortEndPoint.Destination return conn def __init__(self, *args, **kwargs): """__init__() -> Connection Initializes source and destination ports. """ DBConnection.__init__(self, *args, **kwargs) if self.id is None: self.db_id = -1 if not len(self.ports) > 0: self.source = Port(type='source') self.destination = Port(type='destination') # self.source.endPoint = PortEndPoint.Source # self.destination.endPoint = PortEndPoint.Destination self.makeConnection = moduleConnection(self) def __copy__(self): """__copy__() -> Connection - Returns a clone of self. """ return Connection.do_copy(self) def do_copy(self, new_ids=False, id_scope=None, id_remap=None): cp = DBConnection.do_copy(self, new_ids, id_scope, id_remap) cp.__class__ = Connection cp.makeConnection = moduleConnection(cp) for port in cp.ports: Port.convert(port) return cp ########################################################################## @staticmethod def convert(_connection): # print "ports: %s" % _Connection._get_ports(_connection) if _connection.__class__ == Connection: return _connection.__class__ = Connection for port in _connection.ports: Port.convert(port) # _connection.sourceInfo = \ # (_connection.source.moduleName, _connection.source.sig) # _connection.destinationInfo = \ # (_connection.destination.moduleName, _connection.destination.sig) # # print _connection.sourceInfo # # print _connection.destinationInfo # portFromRepresentation = registry.portFromRepresentation # newSource = \ # portFromRepresentation(_connection.source.moduleName, # _connection.source.sig, # PortEndPoint.Source, None, True) # newDestination = \ # portFromRepresentation(_connection.destination.moduleName, # _connection.destination.sig, # PortEndPoint.Destination, None, True) # newSource.moduleId = _connection.source.moduleId # newDestination.moduleId = _connection.destination.moduleId # _connection.source = newSource # _connection.destination = newDestination _connection.makeConnection = moduleConnection(_connection) ########################################################################## # Debugging def show_comparison(self, other): if type(other) != type(self): print "Type mismatch" return if self.__source != other.__source: print "Source mismatch" self.__source.show_comparison(other.__source) return if self.__dest != other.__dest: print "Dest mismatch" self.__dest.show_comparison(other.__dest) return print "no difference found" assert self == other ########################################################################## # Properties id = DBConnection.db_id ports = DBConnection.db_ports def add_port(self, port): self.db_add_port(port) def _get_sourceId(self): """ _get_sourceId() -> int Returns the module id of source port. Do not use this function, use sourceId property: c.sourceId """ return self.source.moduleId def _set_sourceId(self, id): """ _set_sourceId(id : int) -> None Sets this connection source id. It updates both self.__source.moduleId and self.__source.id. Do not use this function, use sourceId property: c.sourceId = id """ self.source.moduleId = id self.source.id = id sourceId = property(_get_sourceId, _set_sourceId) def _get_destinationId(self): """ _get_destinationId() -> int Returns the module id of dest port. Do not use this function, use sourceId property: c.destinationId """ return self.destination.moduleId def _set_destinationId(self, id): """ _set_destinationId(id : int) -> None Sets this connection destination id. It updates self.__dest.moduleId. Do not use this function, use destinationId property: c.destinationId = id """ self.destination.moduleId = id destinationId = property(_get_destinationId, _set_destinationId) def _get_type(self): """_get_type() -> VistrailModuleType - Returns this connection type. Do not use this function, use type property: c.type = t """ return self.source.type def _set_type(self, t): """ _set_type(t: VistrailModuleType) -> None Sets this connection type and updates self.__source.type and self.__dest.type. It also updates the correct makeConnection function. Do not use this function, use type property: c.type = t """ self.source.type = t self.destination.type = t self.updateMakeConnection() type = property(_get_type, _set_type) def _get_source(self): """_get_source() -> Port Returns source port. Do not use this function, use source property: c.source """ try: return self.db_get_port_by_type('source') except KeyError: pass return None def _set_source(self, source): """_set_source(source: Port) -> None Sets this connection source port. It also updates this connection makeConnection function. Do not use this function, use source property instead: c.source = source """ try: port = self.db_get_port_by_type('source') self.db_delete_port(port) except KeyError: pass if source is not None: self.db_add_port(source) source = property(_get_source, _set_source) def _get_destination(self): """_get_destination() -> Port Returns destination port. Do not use this function, use destination property: c.destination """ # return self.db_ports['destination'] try: return self.db_get_port_by_type('destination') except KeyError: pass return None def _set_destination(self, dest): """_set_destination(dest: Port) -> None Sets this connection destination port. It also updates this connection makeConnection function. Do not use this function, use destination property instead: c.destination = dest """ try: port = self.db_get_port_by_type('destination') self.db_delete_port(port) except KeyError: pass if dest is not None: self.db_add_port(dest) destination = property(_get_destination, _set_destination) dest = property(_get_destination, _set_destination) ########################################################################## # Operators def __str__(self): """__str__() -> str - Returns a string representation of a Connection object. """ rep = "<connection id='%s'>%s%s</connection>" return rep % (str(self.id), str(self.source), str(self.destination)) def __ne__(self, other): return not self.__eq__(other) def __eq__(self, other): if type(other) != type(self): return False return (self.source == other.source and self.dest == other.dest) def equals_no_id(self, other): """Checks equality up to ids (connection and ports).""" if type(self) != type(other): return False return (self.source.equals_no_id(other.source) and self.dest.equals_no_id(other.dest))
def replace_generic(controller, pipeline, old_module, new_module, function_remap=None, src_port_remap=None, dst_port_remap=None, annotation_remap=None, control_param_remap=None, use_registry=True): if function_remap is None: function_remap = {} if src_port_remap is None: src_port_remap = {} if dst_port_remap is None: dst_port_remap = {} if annotation_remap is None: annotation_remap = {} if control_param_remap is None: control_param_remap = {} basic_pkg = get_vistrails_basic_pkg_id() 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 not isinstance(remap, basestring): 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) for control_param in old_module.control_parameters: if control_param.name not in control_param_remap: control_param_name = control_param.name else: remap = control_param_remap[control_param.name] if remap is None: # don't add the control param back in continue elif not isinstance(remap, basestring): ops.extend(remap(control_param)) continue else: control_param_name = remap new_control_param = \ ModuleControlParam(id=controller.id_scope.getNewId( ModuleControlParam.vtType), name=control_param_name, value=control_param.value) new_module.add_control_parameter(new_control_param) 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 not isinstance(remap, basestring): 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 not isinstance(remap, basestring): 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) function_ops = [] 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 not isinstance(remap, basestring): function_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 = [] if use_registry: function_port_spec = function_name else: def mk_psi(pos): psi = PortSpecItem(module="Module", package=basic_pkg, namespace="", pos=pos) return psi n_items = len(new_param_vals) function_port_spec = PortSpec( name=function_name, items=[mk_psi(i) for i in xrange(n_items)]) new_function = controller.create_function(new_module, function_port_spec, new_param_vals, aliases) new_module.add_function(new_function) if None in function_remap: # used to add new functions remap = function_remap[None] function_ops.extend(remap(None, new_module)) # add the new module ops.append(('add', new_module)) ops.extend(function_ops) 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 not isinstance(remap, basestring): ops.extend(remap(old_conn, new_module)) continue else: source_name = remap old_dst_module = pipeline.modules[old_conn.destination.moduleId] if use_registry: source_port = source_name else: source_port = Port(name=source_name, type='source', signature=create_port_spec_string([ (basic_pkg, 'Variant', '') ])) new_conn = create_new_connection(controller, new_module, source_port, 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 not isinstance(remap, basestring): ops.extend(remap(old_conn, new_module)) continue else: destination_name = remap old_src_module = pipeline.modules[old_conn.source.moduleId] if use_registry: destination_port = destination_name else: destination_port = Port(name=destination_name, type='destination', signature=create_port_spec_string([ (basic_pkg, 'Variant', '') ])) new_conn = create_new_connection(controller, old_src_module, old_conn.source, new_module, destination_port) ops.append(('add', new_conn)) return [vistrails.core.db.action.create_action(ops)]
def execute(modules, connections=[], add_port_specs=[], enable_pkg=True, full_results=False): """Build a pipeline and execute it. This is useful to simply build a pipeline in a test case, and run it. When doing that, intercept_result() can be used to check the results of each module. modules is a list of module tuples describing the modules to be created, with the following format: [('ModuleName', 'package.identifier', [ # Functions ('port_name', [ # Function parameters ('Signature', 'value-as-string'), ]), ])] connections is a list of tuples describing the connections to make, with the following format: [ (source_module_index, 'source_port_name', dest_module_index, 'dest_module_name'), ] add_port_specs is a list of specs to add to modules, with the following format: [ (mod_id, 'input'/'output', 'portname', '(port_sig)'), ] It is useful to test modules that can have custom ports through a configuration widget. The function returns the 'errors' dict it gets from the interpreter, so you should use a construct like self.assertFalse(execute(...)) if the execution is not supposed to fail. For example, this creates (and runs) an Integer module with its value set to 44, connected to a PythonCalc module, connected to a StandardOutput: self.assertFalse(execute([ ('Float', 'org.vistrails.vistrails.basic', [ ('value', [('Float', '44.0')]), ]), ('PythonCalc', 'org.vistrails.vistrails.pythoncalc', [ ('value2', [('Float', '2.0')]), ('op', [('String', '-')]), ]), ('StandardOutput', 'org.vistrails.vistrails.basic', []), ], [ (0, 'value', 1, 'value1'), (1, 'value', 2, 'value'), ])) """ from vistrails.core.db.locator import XMLFileLocator from vistrails.core.modules.module_registry import MissingPackage from vistrails.core.packagemanager import get_package_manager from vistrails.core.utils import DummyView from vistrails.core.vistrail.connection import Connection from vistrails.core.vistrail.module import Module from vistrails.core.vistrail.module_function import ModuleFunction from vistrails.core.vistrail.module_param import ModuleParam from vistrails.core.vistrail.pipeline import Pipeline from vistrails.core.vistrail.port import Port from vistrails.core.vistrail.port_spec import PortSpec from vistrails.core.interpreter.noncached import Interpreter pm = get_package_manager() port_spec_per_module = {} # mod_id -> [portspec: PortSpec] j = 0 for i, (mod_id, inout, name, sig) in enumerate(add_port_specs): mod_specs = port_spec_per_module.setdefault(mod_id, []) ps = PortSpec(id=i, name=name, type=inout, sigstring=sig, sort_key=-1) for psi in ps.port_spec_items: psi.id = j j += 1 mod_specs.append(ps) pipeline = Pipeline() module_list = [] for i, (name, identifier, functions) in enumerate(modules): function_list = [] try: pkg = pm.get_package(identifier) except MissingPackage: if not enable_pkg: raise dep_graph = pm.build_dependency_graph([identifier]) for pkg_id in pm.get_ordered_dependencies(dep_graph): pkg = pm.identifier_is_available(pkg_id) if pkg is None: raise pm.late_enable_package(pkg.codepath) pkg = pm.get_package(identifier) for func_name, params in functions: param_list = [] for j, (param_type, param_val) in enumerate(params): param_list.append( ModuleParam(pos=j, type=param_type, val=param_val)) function_list.append( ModuleFunction(name=func_name, parameters=param_list)) name = name.rsplit('|', 1) if len(name) == 2: namespace, name = name else: namespace = None name, = name module = Module(name=name, namespace=namespace, package=identifier, version=pkg.version, id=i, functions=function_list) for port_spec in port_spec_per_module.get(i, []): module.add_port_spec(port_spec) pipeline.add_module(module) module_list.append(module) for i, (sid, sport, did, dport) in enumerate(connections): s_sig = module_list[sid].get_port_spec(sport, 'output').sigstring d_sig = module_list[did].get_port_spec(dport, 'input').sigstring pipeline.add_connection( Connection(id=i, ports=[ Port(id=i * 2, type='source', moduleId=sid, name=sport, signature=s_sig), Port(id=i * 2 + 1, type='destination', moduleId=did, name=dport, signature=d_sig), ])) interpreter = Interpreter.get() result = interpreter.execute(pipeline, locator=XMLFileLocator('foo.xml'), current_version=1, view=DummyView()) if full_results: return result else: # Allows to do self.assertFalse(execute(...)) return result.errors