Skip to content

Commit c1bb18f

Browse files
committed
FIX(PLOT) Dict Sols were crashing
1 parent d504c26 commit c1bb18f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

graphtik/plot.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def make_op_prune_comment(plot_args: PlotArgs):
403403
plottable = plot_args.plottable
404404

405405
comments = ()
406-
if sol is not None and op in sol.plan.comments:
406+
if hasattr(sol, "plan") and op in sol.plan.comments:
407407
comments = sol.plan.comments
408408
elif op in getattr(plottable, "comments", ()):
409409
comments = plottable.comments
@@ -1437,7 +1437,7 @@ def _make_node(self, plot_args: PlotArgs) -> pydot.Node:
14371437
#
14381438
is_pruned = (
14391439
hasattr(plottable, "dag") and nx_node not in plottable.dag.nodes
1440-
) or (solution is not None and nx_node not in solution.dag.nodes)
1440+
) or (hasattr(solution, "dag") and nx_node not in solution.dag.nodes)
14411441
if is_pruned:
14421442
graph.nodes[nx_node]["_pruned"] = True # Signal to edge-plotting.
14431443
styles.add("kw_data_pruned")
@@ -1453,7 +1453,7 @@ def _make_node(self, plot_args: PlotArgs) -> pydot.Node:
14531453
if nx_node in solution:
14541454
styles.add("kw_data_in_solution")
14551455

1456-
if nx_node in solution.overwrites:
1456+
if nx_node in getattr(solution, "overwrites", ()):
14571457
styles.add("kw_data_overwritten")
14581458

14591459
elif nx_node in steps:
@@ -1500,11 +1500,11 @@ def _make_node(self, plot_args: PlotArgs) -> pydot.Node:
15001500
label_styles.add("kw_op_prune_comment")
15011501

15021502
if solution:
1503-
if solution.is_failed(nx_node):
1503+
if hasattr(solution, "is_failed") and solution.is_failed(nx_node):
15041504
label_styles.add("kw_op_failed")
1505-
elif nx_node in solution.executed:
1505+
elif nx_node in getattr(solution, "executed", ()):
15061506
label_styles.add("kw_op_executed")
1507-
elif nx_node in solution.canceled:
1507+
elif nx_node in getattr(solution, "canceled", ()):
15081508
label_styles.add("kw_op_canceled")
15091509

15101510
label_styles.stack_user_style(node_attrs)
@@ -1618,7 +1618,8 @@ def _make_edge(self, plot_args: PlotArgs) -> pydot.Edge:
16181618
if graph.nodes[src].get("_pruned") or graph.nodes[dst].get("_pruned"):
16191619
styles.add("kw_edge_pruned")
16201620
if (
1621-
solution is not None
1621+
hasattr(solution, "dag")
1622+
and hasattr(solution, "plan")
16221623
and (src, dst) not in solution.dag.edges
16231624
and (src, dst) in solution.plan.dag.edges
16241625
):

0 commit comments

Comments
 (0)