Esempio n. 1
0
    def __plot__(self, nodename: str, shape: str, rankdir=None):
        """
        Acceptable to leave here
        :param rankdir: The visual direction of the DAG
        """
        # Prep globals, passed through arguments

        self.xp_state.eg.serialize()

        self.xp_state.nodes = {}
        self.xp_state.edges = []

        dot = Digraph()
        # diagram = {"dot": dot, "counter": 0, "sha": {}}

        if not util.isOrphan(self):
            # self.parent.__plotWalk__(diagram)
            vg = viz.VizGraph()
            self.parent.__plotWalk__(vg)
            # vg.bft()
            vg.to_graphViz()
            Source.from_file('output.gv').view()
        else:
            node_diagram_id = '0'

            dot.node(node_diagram_id, nodename, shape=shape)
            self.xp_state.nodes[nodename] = node_diagram_id
            dot.format = 'png'
            if rankdir == 'LR':
                dot.attr(rankdir='LR')
            dot.render('driver.gv', view=True)

        self.xp_state.eg.clean()
Esempio n. 2
0
    def __plotWalk__(self, graph: VizGraph) -> List[VizNode]:
        # TODO: Code artifacts should be shared in Diagram.
        to_list = []

        for child in self.out_artifacts:
            node = graph.newNode(child.name, child.get_shape(), [])
            self.xp_state.nodes[child.getLocation()] = node
            to_list.append(node)

        this = graph.newNode(self.funcName, 'ellipse', [i for i in to_list])
        self.xp_state.nodes[self.funcName] = this

        # scriptNode = graph.newNode(self.filenameWithFunc, 'box', [this,])
        # graph.regis_orphan(scriptNode)

        if self.in_artifacts:
            for artifact in self.in_artifacts:
                if artifact.getLocation() in self.xp_state.nodes:
                    from_node = self.xp_state.nodes[artifact.getLocation()]
                    if artifact.getLocation() in [
                            art.getLocation() for art in self.in_artifacts
                    ]:  #TODO: CLEAN UP
                        if this not in from_node.next:
                            from_node.next.append(this)
                else:
                    if not util.isOrphan(artifact):
                        from_nodes: List[
                            VizNode] = artifact.parent.__plotWalk__(graph)
                        for from_node in from_nodes:
                            interim = [art.name for art in self.in_artifacts]
                            if from_node.name in interim:
                                if this not in from_node.next:
                                    from_node.next.append(this)
                    else:
                        if type(artifact).__name__ == "Literal":
                            node = graph.newNode(artifact.name,
                                                 artifact.get_shape(), [
                                                     this,
                                                 ], util.plating([artifact]))
                        else:
                            node = graph.newNode(artifact.name,
                                                 artifact.get_shape(), [
                                                     this,
                                                 ])
                        graph.regis_orphan(node)
                        self.xp_state.nodes[artifact.getLocation()] = node
        return to_list