Skip to content

Commit 186fbc1

Browse files
Adding a vis for pipeline using GraphViz and an example is shown
1 parent 4033454 commit 186fbc1

File tree

4 files changed

+354
-55
lines changed

4 files changed

+354
-55
lines changed

codeflare/pipelines/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import graphviz
2+
import codeflare.pipelines.Datamodel as dm
3+
4+
5+
def pipeline_to_graph(pipeline: dm.Pipeline) -> graphviz.Digraph:
6+
"""
7+
Converts the given pipeline to a networkX graph for visualization.
8+
9+
:param pipeline: Pipeline to convert to networkX graph
10+
:return: A directed graph representing this pipeline
11+
"""
12+
graph = graphviz.Digraph()
13+
pipeline_nodes = pipeline.get_nodes()
14+
for pre_node in pipeline_nodes.values():
15+
post_nodes = pipeline.get_post_nodes(pre_node)
16+
graph.node(pre_node.get_node_name())
17+
for post_node in post_nodes:
18+
graph.node(post_node.get_node_name())
19+
graph.edge(pre_node.get_node_name(), post_node.get_node_name())
20+
return graph

codeflare_pipelines.egg-info/SOURCES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ codeflare/pipelines/Datamodel.py
55
codeflare/pipelines/Exceptions.py
66
codeflare/pipelines/Runtime.py
77
codeflare/pipelines/__init__.py
8+
codeflare/pipelines/utils.py
89
codeflare_pipelines.egg-info/PKG-INFO
910
codeflare_pipelines.egg-info/SOURCES.txt
1011
codeflare_pipelines.egg-info/dependency_links.txt

0 commit comments

Comments
 (0)