flowcraft/generator/engine.py
def render_pipeline(self):
        """Write pipeline attributes to json

        This function writes the pipeline and their attributes to a json file,
        that is intended to be read by resources/pipeline_graph.html to render
        a graphical output showing the DAG.

        """

        dict_viz = {
            "name": "root",
            "children": []
        }
        last_of_us = {}

        f_tree = self._fork_tree if self._fork_tree else {1: [1]}

        for x, (k, v) in enumerate(f_tree.items()):
            for p in self.processes[1:]:

                if x == 0 and p.lane not in [k] + v:
                    continue

                if x > 0 and p.lane not in v:
                    continue

                if not p.parent_lane:
                    lst = dict_viz["children"]
                else:
                    lst = last_of_us[p.parent_lane]

                tooltip = {
                    "name": "{}_{}".format(p.template, p.pid),
                    "process": {
                        "pid": p.pid,
                        "input": p.input_type,
                        "output": p.output_type if p.output_type else "None",
                        "lane": p.lane,
                    },
                    "children": []
                }

                dir_var = ""
                for k2, v2 in p.directives.items():
                    dir_var += k2
                    for d in v2:
                        try:
                            # Remove quotes from string directives
                            directive = v2[d].replace("'", "").replace('"', '') \
                                if isinstance(v2[d], str) else v2[d]
                            dir_var += "{}: {}".format(d, directive)
                        except KeyError:
                            pass

                if dir_var:
                    tooltip["process"]["directives"] = dir_var
                else:
                    tooltip["process"]["directives"] = "N/A"

                lst.append(tooltip)

                last_of_us[p.lane] = lst[-1]["children"]

        # write to file dict_viz
        self.dag_to_file(dict_viz)

        # Write tree forking information for dotfile
        with open(os.path.join(dirname(self.nf_file),
                               ".forkTree.json"), "w") as fh:
            fh.write(json.dumps(self._fork_tree))

        # send with jinja to html resource
        return self._render_config("pipeline_graph.html", {"data": dict_viz})
def render_pipeline(self):
        dict_viz = {
            "name": "root",
            "children": []
        }
        last_of_us = {}

        f_tree = self._fork_tree if self._fork_tree else {1: [1]}

        for x, (k, v) in enumerate(f_tree.items()):
            for p in self.processes[1:]:

                if x == 0 and p.lane not in [k] + v:
                    continue

                if x > 0 and p.lane not in v:
                    continue

                if not p.parent_lane:
                    lst = dict_viz["children"]
                else:
                    lst = last_of_us[p.parent_lane]

                tooltip = {
                    "name": "{}_{}".format(p.template, p.pid),
                    "process": {
                        "pid": p.pid,
                        "input": p.input_type,
                        "output": p.output_type if p.output_type else "None",
                        "lane": p.lane,
                    },
                    "children": []
                }

                dir_var = ""
                for k2, v2 in p.directives.items():
                    dir_var += k2
                    for d in v2:
                        try:
                            # Remove quotes from string directives
                            directive = v2[d].replace("'", "").replace('"', '') \
                                if isinstance(v2[d], str) else v2[d]
                            dir_var += "{}: {}".format(d, directive)
                        except KeyError:
                            pass

                if dir_var:
                    tooltip["process"]["directives"] = dir_var
                else:
                    tooltip["process"]["directives"] = "N/A"

                lst.append(tooltip)

                last_of_us[p.lane] = lst[-1]["children"]

        # write to file dict_viz
        self.dag_to_file(dict_viz)

        # Write tree forking information for dotfile
        with open(os.path.join(dirname(self.nf_file),
                               ".forkTree.json"), "w") as fh:
            fh.write(json.dumps(self._fork_tree))

        # send with jinja to html resource
        return self._render_config("pipeline_graph.html", {"data": dict_viz})
def render_pipeline ( self ) : dict_viz = { "name" : "root" , "children" : [ ] } last_of_us = { } f_tree = self . _fork_tree if self . _fork_tree else { 1 : [ 1 ] } for x , ( k , v ) in enumerate ( f_tree . items ( ) ) : for p in self . processes [ 1 : ] : if x == 0 and p . lane not in [ k ] + v : continue if x > 0 and p . lane not in v : continue if not p . parent_lane : lst = dict_viz [ "children" ] else : lst = last_of_us [ p . parent_lane ] tooltip = { "name" : "{}_{}" . format ( p . template , p . pid ) , "process" : { "pid" : p . pid , "input" : p . input_type , "output" : p . output_type if p . output_type else "None" , "lane" : p . lane , } , "children" : [ ] } dir_var = "" for k2 , v2 in p . directives . items ( ) : dir_var += k2 for d in v2 : try : # Remove quotes from string directives directive = v2 [ d ] . replace ( "'" , "" ) . replace ( '"' , '' ) if isinstance ( v2 [ d ] , str ) else v2 [ d ] dir_var += "{}: {}" . format ( d , directive ) except KeyError : pass if dir_var : tooltip [ "process" ] [ "directives" ] = dir_var else : tooltip [ "process" ] [ "directives" ] = "N/A" lst . append ( tooltip ) last_of_us [ p . lane ] = lst [ - 1 ] [ "children" ] # write to file dict_viz self . dag_to_file ( dict_viz ) # Write tree forking information for dotfile with open ( os . path . join ( dirname ( self . nf_file ) , ".forkTree.json" ) , "w" ) as fh : fh . write ( json . dumps ( self . _fork_tree ) ) # send with jinja to html resource return self . _render_config ( "pipeline_graph.html" , { "data" : dict_viz } )
Write pipeline attributes to json

        This function writes the pipeline and their attributes to a json file,
        that is intended to be read by resources/pipeline_graph.html to render
        a graphical output showing the DAG.
Write pipeline attributes to json