Beispiel #1
0
    def create_action(self, id_scope=None):
        from vistrails.core.modules.basic_modules import identifier as basic_pkg
        from vistrails.core.vistrail.action import Action
        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.db.domain import IdScope

        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=basic_pkg,
                   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
Beispiel #2
0
    def create_ops(self, id_scope=IdScope()):
        from vistrails.core.modules.basic_modules import identifier as basic_pkg
        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.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=basic_pkg)
        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)
        cparam = ModuleControlParam(id=id_scope.getNewId(
            ModuleControlParam.vtType),
                                    name='foo',
                                    value='bar')
        add_cparam = AddOp(id=id_scope.getNewId(AddOp.vtType),
                           what=ModuleControlParam.vtType,
                           objectId=m.id,
                           data=cparam)

        return [add_op, change_op, delete_op, add_annotation]
Beispiel #3
0
    def test_tuple(self):
        from vistrails.core.vistrail.module_param import ModuleParam
        from vistrails.core.vistrail.module_function import ModuleFunction
        from vistrails.core.utils import DummyView
        from vistrails.core.vistrail.module import Module
        import vistrails.db.domain

        id_scope = vistrails.db.domain.IdScope()
        interpreter = vistrails.core.interpreter.default.get_default_interpreter(
        )
        v = DummyView()
        p = vistrails.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='org.vistrails.vistrails.console_mode_test',
                        version='0.9.1')
        module.add_function(function)

        p.add_module(module)

        interpreter.execute(p,
                            locator=XMLFileLocator('foo'),
                            current_version=1L,
                            view=v)
Beispiel #4
0
    def test_tuple(self):
        from vistrails.core.vistrail.module_param import ModuleParam
        from vistrails.core.vistrail.module_function import ModuleFunction
        from vistrails.core.utils import DummyView
        from vistrails.core.vistrail.module import Module
        import vistrails.db.domain
       
        id_scope = vistrails.db.domain.IdScope()
        interpreter = vistrails.core.interpreter.default.get_default_interpreter()
        v = DummyView()
        p = vistrails.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='org.vistrails.vistrails.console_mode_test',
                           version='0.9.1')
        module.add_function(function)

        p.add_module(module)

        interpreter.execute(p,
                            locator=XMLFileLocator('foo'),
                            current_version=1L,
                            view=v)
Beispiel #5
0
    def create_vistrail(self):
        vistrail = Vistrail()

        m = Module(id=vistrail.idScope.getNewId(Module.vtType),
                   name='Float',
                   package=get_vistrails_basic_pkg_id())
        add_op = AddOp(id=vistrail.idScope.getNewId(AddOp.vtType),
                       what=Module.vtType,
                       objectId=m.id,
                       data=m)
        function_id = vistrail.idScope.getNewId(ModuleFunction.vtType)
        function = ModuleFunction(id=function_id, name='value')
        change_op = ChangeOp(id=vistrail.idScope.getNewId(ChangeOp.vtType),
                             what=ModuleFunction.vtType,
                             oldObjId=2,
                             newObjId=function.real_id,
                             parentObjId=m.id,
                             parentObjType=Module.vtType,
                             data=function)
        param = ModuleParam(id=vistrail.idScope.getNewId(ModuleParam.vtType),
                            type='Integer',
                            val='1')
        delete_op = DeleteOp(id=vistrail.idScope.getNewId(DeleteOp.vtType),
                             what=ModuleParam.vtType,
                             objectId=param.real_id,
                             parentObjId=function.real_id,
                             parentObjType=ModuleFunction.vtType)

        action1 = Action(id=vistrail.idScope.getNewId(Action.vtType),
                         operations=[add_op])
        action2 = Action(id=vistrail.idScope.getNewId(Action.vtType),
                         operations=[change_op, delete_op])

        vistrail.add_action(action1, 0)
        vistrail.add_action(action2, action1.id)
        vistrail.addTag('first action', action1.id)
        vistrail.addTag('second action', action2.id)
        return vistrail
Beispiel #6
0
 def set_defaults(self, other=None):
     Module.set_defaults(self, other)
     self._is_latest_version = True
     self.check_latest_version()
Beispiel #7
0
 def set_defaults(self, other=None):
     Module.set_defaults(self, other)
Beispiel #8
0
 def _get_output_port_specs(self):
     if self._port_specs is None:
         self.make_port_specs()
     return Module._get_output_port_specs(self)
Beispiel #9
0
 def set_defaults(self, other=None):
     Module.set_defaults(self, other)
Beispiel #10
0
 def _get_output_port_specs(self):
     if self._port_specs is None:
         self.make_port_specs()
     return Module._get_output_port_specs(self)
Beispiel #11
0
 def set_defaults(self, other=None):
     Module.set_defaults(self, other)
     self._is_latest_version = True
     self.check_latest_version()