def __init__(self): """ SpreadsheetCell() -> SpreadsheetCell Initialize attributes """ Module.__init__(self) self.location = None
def __init__(self): """ vtkBaseModule() -> vtkBaseModule Instantiate an empty VTK Module with real VTK instance """ Module.__init__(self) self.vtkInstance = None
def transfer_attrs(self, module): self.pipeline = module.pipeline if module._port_specs is None: module.make_port_specs() self.input_remap = module._input_remap self.output_remap = module._output_remap Module.transfer_attrs(self, module)
def __init__(self): """ vtkBaseModule() -> vtkBaseModule Instantiate an emptt VTK Module with real VTK instance """ Module.__init__(self) self.vtkInstance = None
def __init__(self): """ SheetReference() -> SheetReference Instantiate an empty SheetReference """ Module.__init__(self) self.sheetReference = None
def transfer_attrs(self, module): Module.transfer_attrs(self, module) self.input_ports_order = [p.name for p in module.input_port_specs] self.output_ports_order = [ p.name for p in module.output_port_specs if p.name in module.connected_output_ports ]
def __init__(self): Module.__init__(self) self.locator = None self.version = -1 self.pipeline = None self.execute = False self.embedWorkflow = False self.showSpreadsheetOnly = False self.forceDB = False
def clear(self): """ clear() -> None Remove event handler so the object can be freed correctly """ # Remove all observers if self.observer: for e in vtkInteractionHandler.vtkEvents: self.observer.vtkInstance.RemoveObservers(e) Module.clear(self)
def __init__(self): """ CellLocation() -> CellLocation Instantiate an empty cell location, i.e. any available cell """ Module.__init__(self) self.row = -1 self.col = -1 self.rowSpan = -1 self.colSpan = -1 self.sheetReference = None
def mock_get_input(self, name): if name == 'host': return host elif name == 'port': return port else: return Module.get_input(self, name)
def __init__(self): Module.__init__(self) config = get_vistrails_persistent_configuration() if config.check('webRepositoryURL'): self.base_url = config.webRepositoryURL else: raise ModuleError(self, ("No webRepositoryURL value defined" " in the Expert Configuration")) # check if we are running in server mode # this effects how the compute method functions if config.check('isInServerMode'): self.is_server = bool(config.isInServerMode) else: self.is_server = False # TODO: this '/' check should probably be done in core/configuration.py if self.base_url[-1] == '/': self.base_url = self.base_url[:-1]
def compute(self): of = self.interpreter.filePool.create_file() os.unlink(of.name) os.mkdir(of.name) dir = basic.Directory dir.name = of.name o = self.interpreter.filePool.create_file() if self.hasInputFromPort('simulationid'): base_name = self.getInputFromPort('simulationid') else: base_name = os.path.basename(o.name) print(base_name) ofile = basic.File() ofile.name = os.path.join(dir.name, base_name + '.in.xml') if self.hasInputFromPort('parms'): input_values = self.forceGetInputListFromPort('parms') l = [] for p in input_values: if isinstance(p, list): l += p else: l += [p] if self.hasInputFromPort('baseseed'): baseseed = self.getInputFromPort('baseseed') else: baseseed = pyalps.generateSeed() Module.annotate(self, {'baseseed': baseseed}) pyalps.writeInputFiles(os.path.join(dir.name, base_name), l, baseseed) pyalps.copyStylesheet(dir.name) self.setResult("output_dir", dir) self.setResult("output_file", ofile)
def __init__(self): Module.__init__(self) self.is_group = True self.persistent_modules = []
def setResult(self, port_name, value): if value is not None and port_name == "value": if value.name is None: value.name = self.forceGetInputFromPort("name", None) Module.setResult(self, port_name, value)
def __init__(self): Module.__init__(self) self.qgis_obj = None
def transfer_attrs(self, module): Module.transfer_attrs(self, module) self.input_ports_order = [p.name for p in module.input_port_specs]
def set_output(self, port_name, value): if self.list_depth == 0 and value is not None and port_name == 'value': if value.name is None: value.name = self.force_get_input('name', None) Module.set_output(self, port_name, value)
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
def __init__(self, pattern, constraints=None): Module.__init__(self) self.pattern = pattern self.constraints = constraints
def __init__(self): Module.__init__(self) self.is_looping_module = True
def transfer_attrs(self, module): Module.transfer_attrs(self, module)
def __init__(self): Module.__init__(self) self.input_ports_order = [] self.output_ports_order = []
def __init__(self): Module.__init__(self) self.is_cacheable = self.cachedOff
def __init__(self): Module.__init__(self) self.observer = None self.handler = None self.shareddata = None
def __init__(self): Module.__init__(self)
def updateUpstream(self): if self.figInstance is None: self.figInstance = pylab.figure() pylab.hold(True) Module.updateUpstream(self)
def transfer_attrs(self, module): Module.transfer_attrs(self, module) self.input_ports_order = [p.name for p in module.input_port_specs] self.output_ports_order = [p.name for p in module.output_port_specs if p.name in module.connected_output_ports]
def __init__(self): Module.__init__(self) self.figInstance = None
def __init__(self): AssembleDirectoryMixin.__init__(self) Module.__init__(self)
def __init__(self): Module.__init__(self) self.conn = None self.protocol = 'mysql'
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 pkg = pm.identifier_is_available(identifier) if pkg: pm.late_enable_package(pkg.codepath) pkg = pm.get_package(identifier) for func_name, params in functions: param_list = [] for param_type, param_val in params: param_list.append(ModuleParam(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