From c388b965fd89012c541504624ff5a664ad6a0556 Mon Sep 17 00:00:00 2001 From: zilto Date: Mon, 18 Mar 2024 11:30:21 -0400 Subject: [PATCH] made node filled by default --- hamilton/graph.py | 14 ++++++++++++-- tests/test_graph.py | 17 +++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/hamilton/graph.py b/hamilton/graph.py index c6a18e5e2..7153249da 100644 --- a/hamilton/graph.py +++ b/hamilton/graph.py @@ -299,19 +299,20 @@ def _get_node_style(node_type: str) -> Dict[str, str]: if node_type == "config": node_style = dict( shape="note", - style="", + style="filled", fontname=fontname, ) elif node_type == "input": node_style = dict( shape="rectangle", margin="0.15", - style="dashed", + style="filled,dashed", fontname=fontname, ) elif node_type == "materializer": node_style = dict( shape="cylinder", + style="filled", margin="0.15,0.1", fontname=fontname, ) @@ -383,6 +384,7 @@ def _get_legend( label="Legend", rank="same", # makes the legend perpendicular to the main DAG fontname="helvetica", + fillcolor="#ffffff", ), ) @@ -420,6 +422,14 @@ def _get_legend( ranksep="0.4", compound="true", concentrate="true", + style="filled", + # bgcolor="transparent", + ), + node_attr=dict( + fillcolor="#ffffff", + ), + edge_attr=dict( + # color="#ffffff", ), ) # we need to update the graph_attr dict instead of overwriting it diff --git a/tests/test_graph.py b/tests/test_graph.py index 2f1ee18ff..579c3c7d8 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -701,8 +701,8 @@ def test_function_graph_display(tmp_path: pathlib.Path): expected_set = set( [ '\t\tfunction [fillcolor="#b4d8e4" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]\n', - "\t\tgraph [fontname=helvetica label=Legend rank=same]\n", - "\t\tinput [fontname=Helvetica margin=0.15 shape=rectangle style=dashed]\n", + '\t\tgraph [fillcolor="#ffffff" fontname=helvetica label=Legend rank=same]\n', + '\t\tinput [fontname=Helvetica margin=0.15 shape=rectangle style="filled,dashed"]\n', '\t\toutput [fillcolor="#FFC857" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]\n', "\tA -> B\n", "\tA -> C\n", @@ -711,7 +711,8 @@ def test_function_graph_display(tmp_path: pathlib.Path): '\tC [label=<C

int> fillcolor="#b4d8e4" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]\n', "\t_A_inputs -> A\n", # commenting out input node: '\t_A_inputs [label=<
cint
bint
> fontname=Helvetica margin=0.15 shape=rectangle style=dashed]\n', - "\tgraph [compound=true concentrate=true rankdir=LR ranksep=0.4]\n", + "\tgraph [compound=true concentrate=true rankdir=LR ranksep=0.4 style=filled]\n", + '\tnode [fillcolor="#ffffff"]\n', "\tsubgraph cluster__legend {\n", "\t}\n", "// Dependency Graph\n", @@ -726,7 +727,6 @@ def test_function_graph_display(tmp_path: pathlib.Path): render_kwargs={"view": False}, node_modifiers=node_modifiers, ) - dot = dot_file_path.open("r").readlines() dot_set = set(dot) @@ -964,17 +964,18 @@ def test_create_graphviz_graph(): "// Dependency Graph", "", "digraph {", - "\tgraph [compound=true concentrate=true rankdir=LR ranksep=0.4 ratio=1]", + '\tnode [fillcolor="#ffffff"]', + "\tgraph [compound=true concentrate=true rankdir=LR ranksep=0.4 ratio=1 style=filled]", '\tB [label=<B

int> fillcolor="#FFC857" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]', '\tC [label=<C

int> fillcolor="#b4d8e4" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]', '\tA [label=<A

int> fillcolor="#b4d8e4" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]', "\tA -> B", "\tA -> C", - '\t_A_inputs [label=<
bint
bint
> fontname=Helvetica margin=0.15 shape=rectangle style=dashed]', + '\t_A_inputs [label=<
bint
bint
> fontname=Helvetica margin=0.15 shape=rectangle style="filled,dashed"]', "\t_A_inputs -> A", "\tsubgraph cluster__legend {", - "\t\tgraph [fontname=helvetica label=Legend rank=same]", - "\t\tinput [fontname=Helvetica margin=0.15 shape=rectangle style=dashed]", + '\t\tgraph [fillcolor="#ffffff" fontname=helvetica label=Legend rank=same]', + '\t\tinput [fontname=Helvetica margin=0.15 shape=rectangle style="filled,dashed"]', '\t\tfunction [fillcolor="#b4d8e4" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]', '\t\toutput [fillcolor="#FFC857" fontname=Helvetica margin=0.15 shape=rectangle style="rounded,filled"]', "\t}",