コード例 #1
0
 def _get_pipeline(self):
     from core.vistrail.pipeline import Pipeline
     import db.services.vistrail
     workflow = db.services.vistrail.materializeWorkflow(self.abstraction, 
                                                         self.version)
     Pipeline.convert(workflow)
     return workflow
コード例 #2
0
def getPipeline(actions):
    from db.domain import DBWorkflow
    from db.services.vistrail import performActions
    from core.vistrail.pipeline import Pipeline

    workflow = DBWorkflow()
    performActions(actions, workflow)
    Pipeline.convert(workflow)
    return workflow
コード例 #3
0
ファイル: io.py プロジェクト: gzt200361/ThirdParty-2.0.0
def get_workflow_diff(vt, v1, v2):
    from core.vistrail.pipeline import Pipeline
    (v1, v2, pairs, v1Only, v2Only, paramChanges, _, _, _) = \
        db.services.vistrail.getWorkflowDiff(vt, v1, v2, True)
    Pipeline.convert(v1)
    v1.set_abstraction_map(vt.abstractionMap)
    Pipeline.convert(v2)
    v2.set_abstraction_map(vt.abstractionMap)
    #     print 'pairs:', pairs
    #     print 'v1Only:', v1Only
    #     print 'v2Only:', v2Only
    #     print 'paramChanges:', paramChanges
    return (v1, v2, pairs, v1Only, v2Only, paramChanges)
コード例 #4
0
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 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) = \
         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)
コード例 #5
0
ファイル: group.py プロジェクト: painter1/vistrails
 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 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()
コード例 #6
0
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 core.vistrail.pipeline import Pipeline
    (v1, v2, pairs, heuristic_pairs, v1_only, v2_only, param_changes, \
         _, _, _, _) = \
         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)
コード例 #7
0
ファイル: group.py プロジェクト: gzt200361/ThirdParty-2.0.0
    def convert(_group):
        if _group.__class__ == Group:
            return
        _group.__class__ = Group
        _group._registry = None
        _group.portVisible = set()
        if _group.db_location:
            Location.convert(_group.db_location)
        if _group.db_workflow:
            from 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)
コード例 #8
0
ファイル: io.py プロジェクト: gzt200361/ThirdParty-2.0.0
def get_workflow_diff_with_connections(vt, v1, v2):
    from core.vistrail.pipeline import Pipeline
    (v1, v2, mPairs, v1Only, v2Only, paramChanges, cPairs, c1Only, c2Only) = \
        db.services.vistrail.getWorkflowDiff(vt, v1, v2, False)
    Pipeline.convert(v1)
    v1.set_abstraction_map(vt.abstractionMap)
    Pipeline.convert(v2)
    v2.set_abstraction_map(vt.abstractionMap)
    #     print 'mPairs:', mPairs
    #     print 'v1Only:', v1Only
    #     print 'v2Only:', v2Only
    #     print 'paramChanges:', paramChanges
    #     print 'cPairs:', cPairs
    #     print 'c1Only:', c1Only
    #     print 'c2Only:', c2Only
    return (v1, v2, pairs, v1Only, v2Only, paramChanges,
            cPairs, c1Only, c2Only)
コード例 #9
0
            def copy_modules_and_connections(self, module_ids, connection_ids):
                """copy_modules_and_connections(module_ids: [long],
                                             connection_ids: [long]) -> str
                Serializes a list of modules and connections
                """

                pipeline = Pipeline()
                pipeline.set_abstraction_map( \
                    self.current_pipeline.abstraction_map)
                for module_id in module_ids:
                    module = self.current_pipeline.modules[module_id]
                    if module.vtType == AbstractionModule.vtType:
                        abstraction = \
                            pipeline.abstraction_map[module.abstraction_id]
                        pipeline.add_abstraction(abstraction)
                    pipeline.add_module(module)
                for connection_id in connection_ids:
                    connection = self.current_pipeline.connections[connection_id]
                    pipeline.add_connection(connection)
                return core.db.io.serialize(pipeline)
コード例 #10
0
    def getClearPipelines(self, dimensions, clientDimensions):
        result = []
        for row in range(dimensions[3]):
            for column in range(dimensions[2]):
                localPipeline = Pipeline()
                vtkversion = self.getPackageVersion("edu.utah.sci.vistrails.vtk")
                vtkCell = Module(id=localPipeline.fresh_module_id(), name="VTKCell", 
                                 package="edu.utah.sci.vistrails.vtk",
                                 version=vtkversion)
                action = create_action([('add',vtkCell)])
                localPipeline.perform_action(action) 

                vtkRenderer = Module(id=localPipeline.fresh_module_id(), 
                                     name="vtkRenderer", 
                                     package="edu.utah.sci.vistrails.vtk",
                                     version=vtkversion)
                action = create_action([('add',vtkRenderer)])
                localPipeline.perform_action(action)

                src = registry.get_port_spec('edu.utah.sci.vistrails.vtk','vtkRenderer', None, 'self','output')
                dst = registry.get_port_spec('edu.utah.sci.vistrails.vtk','VTKCell', None, 'AddRenderer','input')
                inputPort = Port(id=localPipeline.get_tmp_id(Port.vtType), spec=dst, moduleId=vtkCell.id, moduleName=vtkCell.name)
                outputPort = Port(id=localPipeline.get_tmp_id(Port.vtType), spec=src, moduleId=vtkRenderer.id, moduleName=vtkRenderer.name)
                connection = Connection(id=localPipeline.fresh_connection_id(), ports=[inputPort,outputPort])
                action = create_action([('add',connection)])
                localPipeline.perform_action(action)        

                cellLocation = self.getCellLocationModule(vtkCell, localPipeline)
                if not cellLocation is None:
                    self.deleteModule(cellLocation, localPipeline)
                dim = clientDimensions[(column+dimensions[0], row+dimensions[1])]
                self.addCellLocation(vtkCell, localPipeline, (column, row), dimensions, dim)

                result.append(((dimensions[0]+column,dimensions[1]+row), serialize(localPipeline)))
        return result
コード例 #11
0
ファイル: query_view.py プロジェクト: painter1/vistrails
 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
    def getClearPipelines(self, dimensions, clientDimensions):
        result = []
        for row in range(dimensions[3]):
            for column in range(dimensions[2]):
                localPipeline = Pipeline()
                vtkversion = self.getPackageVersion("edu.utah.sci.vistrails.vtk")
                vtkCell = Module(
                    id=localPipeline.fresh_module_id(),
                    name="VTKCell",
                    package="edu.utah.sci.vistrails.vtk",
                    version=vtkversion,
                )
                action = create_action([("add", vtkCell)])
                localPipeline.perform_action(action)

                vtkRenderer = Module(
                    id=localPipeline.fresh_module_id(),
                    name="vtkRenderer",
                    package="edu.utah.sci.vistrails.vtk",
                    version=vtkversion,
                )
                action = create_action([("add", vtkRenderer)])
                localPipeline.perform_action(action)

                src = registry.get_port_spec("edu.utah.sci.vistrails.vtk", "vtkRenderer", None, "self", "output")
                dst = registry.get_port_spec("edu.utah.sci.vistrails.vtk", "VTKCell", None, "AddRenderer", "input")
                inputPort = Port(
                    id=localPipeline.get_tmp_id(Port.vtType), spec=dst, moduleId=vtkCell.id, moduleName=vtkCell.name
                )
                outputPort = Port(
                    id=localPipeline.get_tmp_id(Port.vtType),
                    spec=src,
                    moduleId=vtkRenderer.id,
                    moduleName=vtkRenderer.name,
                )
                connection = Connection(id=localPipeline.fresh_connection_id(), ports=[inputPort, outputPort])
                action = create_action([("add", connection)])
                localPipeline.perform_action(action)

                cellLocation = self.getCellLocationModule(vtkCell, localPipeline)
                if not cellLocation is None:
                    self.deleteModule(cellLocation, localPipeline)
                dim = clientDimensions[(column + dimensions[0], row + dimensions[1])]
                self.addCellLocation(vtkCell, localPipeline, (column, row), dimensions, dim)

                result.append(((dimensions[0] + column, dimensions[1] + row), serialize(localPipeline)))
        return result
コード例 #13
0
    def createDiffPipeline(self):
        """ createDiffPipeline() -> None        
        Actually walk through the self.diff result and add all modules
        into the pipeline view
        
        """

        # Interprete the diff result
        (p1, p2, v1Andv2, v1Only, v2Only, paramChanged) = self.diff
        p1.ensure_connection_specs()
        p2.ensure_connection_specs()
        p_both = Pipeline()
        # the abstraction map is the same for both p1 and p2
        p_both.set_abstraction_map(p1.abstraction_map)
        
        scene = self.pipelineView.scene()
        scene.clearItems()

        # FIXME HACK: We will create a dummy object that looks like a
        # controller so that the qgraphicsmoduleitems and the scene
        # are happy. It will simply store the pipeline will all
        # modules and connections of the diff, and know how to copy stuff
        class DummyController(object):
            def __init__(self, pip):
                self.current_pipeline = pip
                self.search = None
            def copy_modules_and_connections(self, module_ids, connection_ids):
                """copy_modules_and_connections(module_ids: [long],
                                             connection_ids: [long]) -> str
                Serializes a list of modules and connections
                """

                pipeline = Pipeline()
                pipeline.set_abstraction_map( \
                    self.current_pipeline.abstraction_map)
                for module_id in module_ids:
                    module = self.current_pipeline.modules[module_id]
                    if module.vtType == AbstractionModule.vtType:
                        abstraction = \
                            pipeline.abstraction_map[module.abstraction_id]
                        pipeline.add_abstraction(abstraction)
                    pipeline.add_module(module)
                for connection_id in connection_ids:
                    connection = self.current_pipeline.connections[connection_id]
                    pipeline.add_connection(connection)
                return core.db.io.serialize(pipeline)
                
        controller = DummyController(p_both)
        scene.controller = controller

        # Find the max version id from v1 and start the adding process
        self.maxId1 = 0
        for m1id in p1.modules.keys():
            if m1id>self.maxId1:
                self.maxId1 = m1id
        shiftId = self.maxId1 + 1

        # First add all shared modules, just use v1 module id
        for (m1id, m2id) in v1Andv2:
            item = scene.addModule(p1.modules[m1id],
                                   CurrentTheme.VISUAL_DIFF_SHARED_BRUSH)
            item.controller = controller
            p_both.add_module(copy.copy(p1.modules[m1id]))
            
        # Then add parameter changed version
        for ((m1id, m2id), matching) in paramChanged:
            m1 = p1.modules[m1id]
            m2 = p2.modules[m2id]
            
            #this is a hack for modules with a dynamic local registry.
            #The problem arises when modules have the same name but different
            #input/output ports. We just make sure that the module we add to
            # the canvas has the ports from both modules, so we don't have
            # addconnection errors.
            if m1.registry:
                m1ports = m1.port_specs.itervalues()
                ports = {}
                for p in m1.port_specs.itervalues():
                    ports[p.name] = p
                for port in m2.port_specs.itervalues():
                    if not ports.has_key(port.name):
                        m1.add_port_to_registry(port)
                    else:
                        if ports[port.name].spec != port.spec:
                            #if we add this port, we will get port overloading.
                            #To avoid this, just cast the current port to be of
                            # Module or Variant type.
                            new_port = ports[port.name]
                            m1.delete_port_from_registry(new_port.id)
                            if new_port.type == 'input':
                                new_port.spec = "(Module)"
                            else:
                                new_port.spec = "(Variant)"
                            m1.add_port_to_registry(new_port)
                            
            item = scene.addModule(p1.modules[m1id],
                                   CurrentTheme.VISUAL_DIFF_PARAMETER_CHANGED_BRUSH)
            item.controller = controller
            p_both.add_module(copy.copy(p1.modules[m1id]))

        # Now add the ones only applicable for v1, still using v1 ids
        for m1id in v1Only:
            item = scene.addModule(p1.modules[m1id],
                                   CurrentTheme.VISUAL_DIFF_FROM_VERSION_BRUSH)
            item.controller = controller
            p_both.add_module(copy.copy(p1.modules[m1id]))

        # Now add the ones for v2 only but must shift the ids away from v1
        for m2id in v2Only:
            p2.modules[m2id].id = m2id + shiftId
            item = scene.addModule(p2.modules[m2id],
                                   CurrentTheme.VISUAL_DIFF_TO_VERSION_BRUSH)
            item.controller = controller
            p_both.add_module(copy.copy(p2.modules[m2id]))

        # Create a mapping between share modules between v1 and v2
        v1Tov2 = {}
        v2Tov1 = {}
        for (m1id, m2id) in v1Andv2:
            v1Tov2[m1id] = m2id
            v2Tov1[m2id] = m1id
        for ((m1id, m2id), matching) in paramChanged:
            v1Tov2[m1id] = m2id
            v2Tov1[m2id] = m1id

        # Next we're going to add connections, only connections of
        # v2Only need to shift their ids
        if p1.connections.keys():
            connectionShift = max(p1.connections.keys())+1
        else:
            connectionShift = 0
        allConnections = copy.copy(p1.connections)
        sharedConnections = []
        v2OnlyConnections = []        
        for (cid2, connection2) in copy.copy(p2.connections.items()):
            if connection2.sourceId in v2Only:
                connection2.sourceId += shiftId
            else:
                connection2.sourceId = v2Tov1[connection2.sourceId]
                
            if connection2.destinationId in v2Only:
                connection2.destinationId += shiftId
            else:
                connection2.destinationId = v2Tov1[connection2.destinationId]

            # Is this connection also shared by p1?
            shared = False
            for (cid1, connection1) in p1.connections.items():
                if (connection1.sourceId==connection2.sourceId and
                    connection1.destinationId==connection2.destinationId and
                    connection1.source.name==connection2.source.name and
                    connection1.destination.name==connection2.destination.name):
                    sharedConnections.append(cid1)
                    shared = True
                    break
            if not shared:
                allConnections[cid2+connectionShift] = connection2
                connection2.id = cid2+connectionShift
                v2OnlyConnections.append(cid2+connectionShift)

        connectionItems = []
        for c in allConnections.values():
            p_both.add_connection(copy.copy(c))
            connectionItems.append(scene.addConnection(c))

        # Color Code connections
        for c in connectionItems:
            if c.id in sharedConnections:
                pass
            elif c.id in v2OnlyConnections:
                pen = QtGui.QPen(CurrentTheme.CONNECTION_PEN)
                pen.setBrush(CurrentTheme.VISUAL_DIFF_TO_VERSION_BRUSH)
                c.connectionPen = pen
            else:
                pen = QtGui.QPen(CurrentTheme.CONNECTION_PEN)
                pen.setBrush(CurrentTheme.VISUAL_DIFF_FROM_VERSION_BRUSH)
                c.connectionPen = pen

       

        scene.updateSceneBoundingRect()
        scene.fitToView(self.pipelineView, True)
コード例 #14
0
def open_workflow(filename):
    from core.vistrail.pipeline import Pipeline
    workflow = db.services.io.open_workflow_from_xml(filename)
    Pipeline.convert(workflow)
    return workflow
コード例 #15
0
def get_workflow(vt, version):
    from core.vistrail.pipeline import Pipeline
    workflow = db.services.vistrail.materializeWorkflow(vt, version)
    Pipeline.convert(workflow)
    return workflow
コード例 #16
0
ファイル: io.py プロジェクト: gzt200361/ThirdParty-2.0.0
def expand_workflow(vt, workflow=None, version=None):
    from core.vistrail.pipeline import Pipeline
    (workflow, module_remap) = \
        db.services.vistrail.expandWorkflow(vt, workflow, version)
    Pipeline.convert(workflow)
    return (workflow, module_remap)