示例#1
0
 def convert(_group):
     if _group.__class__ == Group:
         return
     _group.__class__ = Group
     if _group.db_location:
         Location.convert(_group.db_location)
     if _group.db_workflow:
         from vistrails.core.vistrail.pipeline import Pipeline
         Pipeline.convert(_group.db_workflow)
     for _function in _group.db_functions:
         ModuleFunction.convert(_function)
     for _annotation in _group.db_get_annotations():
         Annotation.convert(_annotation)
     _group.set_defaults()
示例#2
0
文件: io.py 项目: cjh1/VisTrails
def get_workflow_diff_with_connections(vt_pair_1, vt_pair_2):
    """get_workflow_diff_with_connections

    Similar to get_workflow_diff but with connection pairings.
    """

    from vistrails.core.vistrail.pipeline import Pipeline
    (v1, v2, m_pairs, m_heuristic, v1_only, v2_only, param_changes, \
         c_pairs, c_heuristic, c1_only, c2_only) = \
         vistrails.db.services.vistrail.getWorkflowDiff(vt_pair_1, vt_pair_2, False)
    Pipeline.convert(v1)
    Pipeline.convert(v2)
    return (v1, v2, m_pairs, m_heustric, v1_only, v2_only, param_changes,
            c_pairs, c_heuristic, c1_only, c2_only)
示例#3
0
文件: io.py 项目: cjh1/VisTrails
def get_workflow_diff(vt_pair_1, vt_pair_2):
    """get_workflow_diff( tuple(Vistrail, id), tuple(Vistrail, id) ) ->
            Pipeline, Pipeline, [tuple(id, id)], [tuple(id, id)], 
            [id], [id], [tuple(id, id, list)]

    Return a difference between two workflows referenced as vistrails.
    """

    from vistrails.core.vistrail.pipeline import Pipeline
    (v1, v2, pairs, heuristic_pairs, v1_only, v2_only, param_changes, \
         _, _, _, _) = \
         vistrails.db.services.vistrail.getWorkflowDiff(vt_pair_1, vt_pair_2, True)
    Pipeline.convert(v1)
    Pipeline.convert(v2)
    return (v1, v2, pairs, heuristic_pairs, v1_only, v2_only, param_changes)
示例#4
0
文件: io.py 项目: hjanime/VisTrails
def get_workflow_diff_with_connections(vt_pair_1, vt_pair_2):
    """get_workflow_diff_with_connections

    Similar to get_workflow_diff but with connection pairings.
    """

    from vistrails.core.vistrail.pipeline import Pipeline
    (v1, v2, m_pairs, m_heuristic, v1_only, v2_only, param_changes,
     cparam_changes, annot_changes, c_pairs, c_heuristic, c1_only, c2_only) =\
         vistrails.db.services.vistrail.getWorkflowDiff(vt_pair_1, vt_pair_2,
                                                        False)
    Pipeline.convert(v1)
    Pipeline.convert(v2)
    return (v1, v2, m_pairs, m_heuristic, v1_only, v2_only, param_changes,
            cparam_changes, annot_changes, c_pairs, c_heuristic, c1_only,
            c2_only)
示例#5
0
 def convert(_group):
     if _group.__class__ == Group:
         return
     _group.__class__ = Group
     if _group.db_location:
         Location.convert(_group.db_location)
     if _group.db_workflow:
         from vistrails.core.vistrail.pipeline import Pipeline
         Pipeline.convert(_group.db_workflow)
     for _function in _group.db_functions:
         ModuleFunction.convert(_function)
     for _annotation in _group.db_get_annotations():
         Annotation.convert(_annotation)
     for _control_parameter in _group.db_get_controlParameters():
         ModuleControlParam.convert(_control_parameter)
     _group.set_defaults()
示例#6
0
文件: io.py 项目: hjanime/VisTrails
def get_workflow_diff(vt_pair_1, vt_pair_2):
    """get_workflow_diff( tuple(Vistrail, id), tuple(Vistrail, id) ) ->
            Pipeline, Pipeline, [tuple(id, id)], [tuple(id, id)], 
            [id], [id], [tuple(id, id, list)]

    Return a difference between two workflows referenced as vistrails.
    """

    from vistrails.core.vistrail.pipeline import Pipeline
    (v1, v2, pairs, heuristic_pairs, v1_only, v2_only, param_changes,
     cparam_changes, annot_changes, _, _, _, _) = \
         vistrails.db.services.vistrail.getWorkflowDiff(vt_pair_1, vt_pair_2,
                                                        True)
    Pipeline.convert(v1)
    Pipeline.convert(v2)
    return (v1, v2, pairs, heuristic_pairs, v1_only, v2_only, param_changes,
            cparam_changes, annot_changes)
示例#7
0
文件: map.py 项目: licode/VisTrails
    def serialize_module(self, module):
        """
        Serializes a module to be executed in parallel.
        """
        def process_group(group):
            group.pipeline.id = None
            for module in group.pipeline.module_list:
                if module.is_group():
                    process_group(module)

        pipeline = Pipeline(version=vistrails.db.versions.currentVersion)

        if module.is_group():
            process_group(module)

        module = module.do_copy()
        pipeline.add_module(module)

        return serialize(pipeline)
示例#8
0
文件: map.py 项目: cjh1/VisTrails
    def serialize_module(self, module):
        """
        Serializes a module to be executed in parallel.
        """

        def process_group(group):
            group.pipeline.id = None
            for module in group.pipeline.module_list:
                if module.is_group():
                    process_group(module)

        pipeline = Pipeline(version=vistrails.db.versions.currentVersion)

        if module.is_group():
            process_group(module)

        module = module.do_copy()
        pipeline.add_module(module)

        return serialize(pipeline)
示例#9
0
文件: io.py 项目: hjanime/VisTrails
def open_workflow(filename):
    from vistrails.core.vistrail.pipeline import Pipeline
    workflow = vistrails.db.services.io.open_workflow_from_xml(filename)
    Pipeline.convert(workflow)
    return workflow
示例#10
0
文件: io.py 项目: hjanime/VisTrails
def get_workflow(vt, version):
    from vistrails.core.vistrail.pipeline import Pipeline
    workflow = vistrails.db.services.vistrail.materializeWorkflow(vt, version)
    Pipeline.convert(workflow)
    return workflow
示例#11
0
 def __init__(self, parent=None):
     QPipelineView.__init__(self, parent)
     self.setBackgroundBrush(CurrentTheme.QUERY_BACKGROUND_BRUSH)
     self.scene().current_pipeline = Pipeline()
     self.query_controller = None
示例#12
0
文件: utils.py 项目: cjh1/VisTrails
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
示例#13
0
文件: utils.py 项目: licode/VisTrails
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