示例#1
0
    def pipeline_from_generator(variable_gen):
        # Get the original OutputPort module
        orig_controller = variable_gen._generator.controller
        base_pipeline = orig_controller.vistrail.getPipeline('dat-vars')
        if len(base_pipeline.module_list) != 1:
            raise ValueError("dat-vars version is invalid")
        output_port = base_pipeline.module_list[0]

        controller = VistrailController(Vistrail())
        # OutputPort
        operations = [('add', output_port)]
        # Rest of the pipeline
        operations += variable_gen._generator.operations
        # Connection
        connection = controller.create_connection(
            variable_gen._output_module,
            variable_gen._outputport_name,
            output_port,
            'InternalPipe')
        operations.append(('add', connection))
        # Materialize this
        action = create_action(operations)
        controller.add_new_action(action)
        version = controller.perform_action(action)
        controller.change_selected_version(version)
        assert version == controller.current_version == 1
        return controller.current_pipeline, 1
示例#2
0
文件: __init__.py 项目: rbax/DAT
    def pipeline_from_generator(variable_gen):
        # Get the original OutputPort module
        orig_controller = variable_gen._generator.controller
        base_pipeline = orig_controller.vistrail.getPipeline('dat-vars')
        if len(base_pipeline.module_list) != 1:
            raise ValueError("dat-vars version is invalid")
        output_port = base_pipeline.module_list[0]

        controller = VistrailController(Vistrail())
        # OutputPort
        operations = [('add', output_port)]
        # Rest of the pipeline
        operations += variable_gen._generator.operations
        # Connection
        connection = controller.create_connection(
            variable_gen._output_module, variable_gen._outputport_name,
            output_port, 'InternalPipe')
        operations.append(('add', connection))
        # Materialize this
        action = create_action(operations)
        controller.add_new_action(action)
        version = controller.perform_action(action)
        controller.change_selected_version(version)
        assert version == controller.current_version == 1
        return controller.current_pipeline, 1
示例#3
0
def handle_module_upgrade_request(controller, module_id, pipeline):
    old_module = pipeline.modules[module_id]
    if old_module.name == "JSONFile" and old_module.version != "0.1.5" and old_module.namespace == "read":
        from vistrails.core.db.action import create_action
        from vistrails.core.modules.module_registry import get_module_registry
        from .read.read_json import JSONObject

        reg = get_module_registry()
        new_desc = reg.get_descriptor(JSONObject)
        new_module = controller.create_module_from_descriptor(new_desc, old_module.location.x, old_module.location.y)
        actions = UpgradeWorkflowHandler.replace_generic(controller, pipeline, old_module, new_module)

        new_function = controller.create_function(new_module, "key_name", ["_key"])
        actions.append(create_action([("add", new_function, "module", new_module.id)]))
        return actions

    module_remap = {
        "read|csv|CSVFile": [(None, "0.1.1", "read|CSVFile", {"src_port_remap": {"self": "value"}})],
        "read|numpy|NumPyArray": [(None, "0.1.1", "read|NumPyArray", {"src_port_remap": {"self": "value"}})],
        "read|CSVFile": [("0.1.1", "0.1.2", None, {"src_port_remap": {"self": "value"}}), ("0.1.3", "0.1.5", None, {})],
        "read|NumPyArray": [("0.1.1", "0.1.2", None, {"src_port_remap": {"self": "value"}})],
        "read|ExcelSpreadsheet": [
            ("0.1.1", "0.1.2", None, {"src_port_remap": {"self": "value"}}),
            ("0.1.3", "0.1.4", None, {}),
        ],
        "read|JSONFile": [(None, "0.1.5", "read|JSONObject")],
    }

    return UpgradeWorkflowHandler.remap_module(controller, module_id, pipeline, module_remap)
示例#4
0
def handle_module_upgrade_request(controller, module_id, pipeline):
    # Before 0.0.3, SQLSource's resultSet output was type ListOfElements (which
    #   doesn't exist anymore)
    # In 0.0.3, SQLSource's resultSet output was type List
    # In 0.1.0, SQLSource's output was renamed to result and is now a Table;
    #   this is totally incompatible and no upgrade code is possible
    #   the resultSet is kept for now for compatibility

    # Up to 0.0.4, DBConnection would ask for a password if one was necessary;
    #   this behavior has not been kept. There is now a password input port, to
    #   which you can connect a PasswordDialog from package dialogs if needed

    old_module = pipeline.modules[module_id]
    # DBConnection module from before 0.1.0: automatically add the password
    # prompt module
    if (old_module.name == 'DBConnection'
            and versions_increasing(old_module.version, '0.1.0')):
        reg = get_module_registry()
        # Creates the new module
        new_module = controller.create_module_from_descriptor(
            reg.get_descriptor(DBConnection))
        # Create the password module
        mod_desc = reg.get_descriptor_by_name(
            'org.vistrails.vistrails.dialogs', 'PasswordDialog')
        mod = controller.create_module_from_descriptor(mod_desc)
        # Adds a 'label' function to the password module
        ops = [('add', mod)]
        ops.extend(
            controller.update_function_ops(mod, 'label', ['Server password']))
        # Connects the password module to the new module
        conn = controller.create_connection(mod, 'result', new_module,
                                            'password')
        ops.append(('add', conn))
        # Replaces the old module with the new one
        upgrade_actions = UpgradeWorkflowHandler.replace_generic(
            controller,
            pipeline,
            old_module,
            new_module,
            src_port_remap={'self': 'connection'})
        password_fix_action = create_action(ops)
        return upgrade_actions + [password_fix_action]

    return UpgradeWorkflowHandler.attempt_automatic_upgrade(
        controller, pipeline, module_id)
示例#5
0
文件: init.py 项目: Nikea/VisTrails
def handle_module_upgrade_request(controller, module_id, pipeline):
    # Before 0.0.3, SQLSource's resultSet output was type ListOfElements (which
    #   doesn't exist anymore)
    # In 0.0.3, SQLSource's resultSet output was type List
    # In 0.1.0, SQLSource's output was renamed to result and is now a Table;
    #   this is totally incompatible and no upgrade code is possible
    #   the resultSet is kept for now for compatibility

    # Up to 0.0.4, DBConnection would ask for a password if one was necessary;
    #   this behavior has not been kept. There is now a password input port, to
    #   which you can connect a PasswordDialog from package dialogs if needed

    old_module = pipeline.modules[module_id]
    # DBConnection module from before 0.1.0: automatically add the password
    # prompt module
    if (old_module.name == 'DBConnection' and
            versions_increasing(old_module.version, '0.1.0')):
        reg = get_module_registry()
        # Creates the new module
        new_module = controller.create_module_from_descriptor(
                reg.get_descriptor(DBConnection))
        # Create the password module
        mod_desc = reg.get_descriptor_by_name(
                'org.vistrails.vistrails.dialogs', 'PasswordDialog')
        mod = controller.create_module_from_descriptor(mod_desc)
        # Adds a 'label' function to the password module
        ops = [('add', mod)]
        ops.extend(controller.update_function_ops(mod,
                                                  'label', ['Server password']))
        # Connects the password module to the new module
        conn = controller.create_connection(mod, 'result',
                                            new_module, 'password')
        ops.append(('add', conn))
        # Replaces the old module with the new one
        upgrade_actions = UpgradeWorkflowHandler.replace_generic(
                controller, pipeline,
                old_module, new_module,
                src_port_remap={'self': 'connection'})
        password_fix_action = create_action(ops)
        return upgrade_actions + [password_fix_action]

    return UpgradeWorkflowHandler.attempt_automatic_upgrade(
            controller, pipeline,
            module_id)
示例#6
0
    def _get_variables_root(controller=None):
        """Create or get the version tagged 'dat-vars'

        This is the base version of all DAT variables. It consists of a single
        OutputPort module with name 'value'.
        """
        if controller is None:
            controller = get_vistrails_application().get_controller()
            assert controller is not None
        if controller.vistrail.has_tag_str('dat-vars'):
            root_version = controller.vistrail.get_version_number('dat-vars')
        else:
            # Create the 'dat-vars' version
            controller.change_selected_version(0)
            reg = get_module_registry()
            operations = []

            # Add an OutputPort module
            descriptor = reg.get_descriptor_by_name(
                'org.vistrails.vistrails.basic', 'OutputPort')
            out_mod = controller.create_module_from_descriptor(descriptor)
            operations.append(('add', out_mod))

            # Add a function to this module
            operations.extend(
                controller.update_function_ops(
                    out_mod,
                    'name',
                    ['value']))

            # Perform the operations
            action = create_action(operations)
            controller.add_new_action(action)
            root_version = controller.perform_action(action)
            # Tag as 'dat-vars'
            controller.vistrail.set_tag(root_version, 'dat-vars')

        controller.change_selected_version(root_version)
        pipeline = controller.current_pipeline
        outmod_id = pipeline.modules.keys()
        assert len(outmod_id) == 1
        outmod_id = outmod_id[0]
        return controller, root_version, outmod_id
示例#7
0
        def test_delete(to_delete, expected_survivors,
                        controller=None, modules=None,
                        **kwargs):
            if controller is None:
                controller, modules = self.make_pipeline()
            rmodules = {m.id: i for i, m in enumerate(modules)}
            to_delete = [modules[i] for i in to_delete]

            operations = []
            delete_linked(controller, to_delete, operations, **kwargs)
            action = create_action(operations)
            controller.add_new_action(action)
            controller.change_selected_version(
                controller.perform_action(action))

            survivors = [rmodules[m.id]
                         for m in controller.current_pipeline.module_list]
            survivors.sort()
            self.assertEqual(survivors, expected_survivors)
示例#8
0
    def updateVistrail(self):
        """ updateVistrail() -> None
        Update functions on the metadata port of the module
        """
        # Remove the keys that we loaded
        ops = [('delete', func) for func in self._loaded_keys]

        # Add the metadata in the list
        for i in xrange(self._list_layout.count()):
            widget = self._list_layout.itemAt(i).widget()
            ops.extend(self.controller.update_function_ops(
                    self.module, 'metadata',
                    [widget.to_string()]))

        # This code should really be in VistrailController
        self.controller.flush_delayed_actions()
        action = create_action(ops)
        self.controller.add_new_action(action,
                                       "Updated PersistedPath metadata")
        self.controller.perform_action(action)

        return True
示例#9
0
    def perform_action(self):
        """Layout all the modules and create the action.
        """
        self._ensure_version()

        pipeline = self.controller.current_pipeline

        self.operations.extend(self.controller.layout_modules_ops(
            old_modules=[m
                         for m in self.all_modules
                         if m.id in pipeline.modules],
            new_modules=[m
                         for m in self.all_modules
                         if m.id not in pipeline.modules],
            new_connections=[c
                             for c in self.all_connections
                             if c.id not in pipeline.connections],
            preserve_order=True))

        action = create_action(self.operations)
        self.controller.add_new_action(action)
        return self.controller.perform_action(action)
示例#10
0
文件: pipelines.py 项目: rbax/DAT
    def perform_action(self):
        """Layout all the modules and create the action.
        """
        self._ensure_version()

        pipeline = self.controller.current_pipeline

        self.operations.extend(self.controller.layout_modules_ops(
            old_modules=[m
                         for m in self.all_modules
                         if m.id in pipeline.modules],
            new_modules=[m
                         for m in self.all_modules
                         if m.id not in pipeline.modules],
            new_connections=[c
                             for c in self.all_connections
                             if c.id not in pipeline.connections],
            preserve_order=True))

        action = create_action(self.operations)
        self.controller.add_new_action(action)
        return self.controller.perform_action(action)
示例#11
0
    def updateVistrail(self):
        """ updateVistrail() -> None
        Update functions on the metadata port of the module
        """
        # Remove the keys that we loaded
        ops = [('delete', func) for func in self._loaded_keys]

        # Add the metadata in the list
        for i in xrange(self._list_layout.count()):
            widget = self._list_layout.itemAt(i).widget()
            ops.extend(
                self.controller.update_function_ops(self.module, 'metadata',
                                                    [widget.to_string()]))

        # This code should really be in VistrailController
        self.controller.flush_delayed_actions()
        action = create_action(ops)
        self.controller.add_new_action(action,
                                       "Updated PersistedPath metadata")
        self.controller.perform_action(action)

        return True
示例#12
0
        def test_delete(to_delete,
                        expected_survivors,
                        controller=None,
                        modules=None,
                        **kwargs):
            if controller is None:
                controller, modules = self.make_pipeline()
            rmodules = {m.id: i for i, m in enumerate(modules)}
            to_delete = [modules[i] for i in to_delete]

            operations = []
            delete_linked(controller, to_delete, operations, **kwargs)
            action = create_action(operations)
            controller.add_new_action(action)
            controller.change_selected_version(
                controller.perform_action(action))

            survivors = [
                rmodules[m.id] for m in controller.current_pipeline.module_list
            ]
            survivors.sort()
            self.assertEqual(survivors, expected_survivors)