예제 #1
0
    def test_constructor(self):
        m1_param = ModuleParam(
            val="1.2",
            type="Float",
            alias="",
        )
        m1_function = ModuleFunction(
            name="value",
            parameters=[m1_param],
        )
        m1 = Module(
            id=0,
            name='Float',
            functions=[m1_function],
        )

        m2 = Module()
        m2.name = "Float"
        m2.id = 0
        f = ModuleFunction()
        f.name = "value"
        m2.functions.append(f)
        param = ModuleParam()
        param.strValue = "1.2"
        param.type = "Float"
        param.alias = ""
        f.params.append(param)
        assert m1 == m2
예제 #2
0
파일: init.py 프로젝트: painter1/vistrails
 def testIncorrectURL_2(self):
     import core.vistrail
     from core.db.locator import XMLFileLocator
     from core.vistrail.module import Module
     from core.vistrail.module_function import ModuleFunction
     from core.vistrail.module_param import ModuleParam
     import core.interpreter
     p = core.vistrail.pipeline.Pipeline()
     m_param = ModuleParam(
         type='String',
         val='http://neitherodesthisohrly',
     )
     m_function = ModuleFunction(
         name='url',
         parameters=[m_param],
     )
     p.add_module(
         Module(
             name='HTTPFile',
             package=identifier,
             version=version,
             id=0,
             functions=[m_function],
         ))
     interpreter = core.interpreter.default.get_default_interpreter()
     kwargs = {
         'locator': XMLFileLocator('foo'),
         'current_version': 1L,
         'view': DummyView(),
     }
예제 #3
0
    def create_action(self, id_scope=None):
        from core.vistrail.action import Action
        from core.vistrail.module import Module
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.operation import AddOp
        from db.domain import IdScope
        from datetime import datetime

        if id_scope is None:
            id_scope = IdScope()
        param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                            type='Integer',
                            val='1')
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='value',
                                  parameters=[param])
        m = Module(id=id_scope.getNewId(Module.vtType),
                   name='Float',
                   package='edu.utah.sci.vistrails.basic',
                   functions=[function])

        add_op = AddOp(id=id_scope.getNewId('operation'),
                       what='module',
                       objectId=m.id,
                       data=m)
        action = Action(id=id_scope.getNewId(Action.vtType),
                        prevId=0,
                        date=datetime(2007, 11, 18),
                        operations=[add_op])
        return action
예제 #4
0
        def from_destination_port():
            f = ModuleFunction()
            f.name = self.name
            for descriptor in self._descriptors:
                p = ModuleParam()
                p.identifier = descriptor.identifier
                p.namespace = descriptor.namespace
                p.type = descriptor.name

                p.name = '<no description>'
                f.addParameter(p)
            return f
예제 #5
0
    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]
예제 #6
0
 def test_str(self):
     m = Module(
         id=0,
         name='Float',
         functions=[
             ModuleFunction(
                 name='value',
                 parameters=[ModuleParam(
                     type='Int',
                     val='1',
                 )],
             )
         ],
     )
     str(m)
예제 #7
0
    def create_module(self, id_scope=None):
        from db.domain import IdScope
        if id_scope is None:
            id_scope = IdScope()

        params = [
            ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                        type='Int',
                        val='1')
        ]
        functions = [
            ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                           name='value',
                           parameters=params)
        ]
        module = Module(id=id_scope.getNewId(Module.vtType),
                        name='Float',
                        package='edu.utah.sci.vistrails.basic',
                        functions=functions)
        return module
예제 #8
0
    def test_tuple(self):
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.module_function import ModuleFunction
        from core.utils import DummyView
        from core.vistrail.module import Module
        import db.domain

        id_scope = db.domain.IdScope()
        interpreter = core.interpreter.default.get_default_interpreter()
        v = DummyView()
        p = core.vistrail.pipeline.Pipeline()
        params = [
            ModuleParam(
                id=id_scope.getNewId(ModuleParam.vtType),
                pos=0,
                type='Float',
                val='2.0',
            ),
            ModuleParam(
                id=id_scope.getNewId(ModuleParam.vtType),
                pos=1,
                type='Float',
                val='2.0',
            )
        ]
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='input')
        function.add_parameters(params)
        module = Module(id=id_scope.getNewId(Module.vtType),
                        name='TestTupleExecution',
                        package='edu.utah.sci.vistrails.console_mode_test',
                        version='0.9.0')
        module.add_function(function)

        p.add_module(module)

        kwargs = {
            'locator': XMLFileLocator('foo'),
            'current_version': 1L,
            'view': v,
        }
예제 #9
0
    def perform(self, pipeline, step):
        """ perform(pipeline: VisPipeline, step: int) -> None        
        This will takes a pipeline and apply the interpolated values
        at step 'step' to the pipeline. Then return the updated
        pipeline

        """
        m = pipeline.modules[self.module.id]
        f = ModuleFunction()
        f.name = self.function
        f.returnType = 'void'
        value = self.values[step]
        for v in value:
            p = ModuleParam()
            convert = {
                'int': 'Integer',
                'str': 'String',
                'float': 'Float',
                'double': 'Float'
            }
            p.type = convert[type(v).__name__]
            p.strValue = str(v)
            f.params.append(p)
        m.functions.append(f)
예제 #10
0
파일: group.py 프로젝트: painter1/vistrails
    def create_group(self, id_scope=IdScope()):
        from core.vistrail.location import Location
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam

        params = [
            ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                        type='Int',
                        val='1')
        ]
        functions = [
            ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                           name='value',
                           parameters=params)
        ]
        location = Location(id=id_scope.getNewId(Location.vtType),
                            x=12.342,
                            y=-19.432)
        module = \
            Group(id=id_scope.getNewId(Group.vtType),
                  location=location,
                  functions=functions,
                  )
        return module
예제 #11
0
 def from_source_port():
     f = ModuleFunction()
     f.name = self.name
     if len(self._descriptors) > 0:
         f.returnType = self._descriptors[0].name
     return f