diff --git a/graphkit/network.py b/graphkit/network.py index e4957d59..f81632e9 100644 --- a/graphkit/network.py +++ b/graphkit/network.py @@ -293,6 +293,8 @@ def _collect_unsatisfied_operations(self, dag, inputs): # Prune operations that ended up providing no output. unsatisfied.append(node) else: + # It's ok not to dig into edge-data("optional") here, + # we care about all needs, including broken ones. real_needs = set(n for n in node.needs if not isinstance(n, optional)) if real_needs.issubset(op_satisfaction[node]): @@ -334,7 +336,7 @@ def _prune_graph(self, outputs, inputs): dag = self.graph # Ignore input names that aren't in the graph. - graph_inputs = iset(dag.nodes) & inputs # preserve order + graph_inputs = set(dag.nodes) & set(inputs) # unordered, iterated, but ok # Scream if some requested outputs aren't in the graph. unknown_outputs = iset(outputs) - dag.nodes @@ -373,7 +375,7 @@ def _prune_graph(self, outputs, inputs): # Clone it so that it is picklable. pruned_dag = dag.subgraph(broken_dag.nodes - unsatisfied).copy() - return pruned_dag, tuple(broken_edges) + return pruned_dag, broken_edges def compile(self, inputs=(), outputs=()): """ @@ -644,6 +646,7 @@ def _execute_thread_pool_barrier_method(self, inputs, solution, overwrites, if len(upnext) == 0: break + ## TODO: accept pool from caller done_iterator = pool.imap_unordered( (lambda op: (op, self._call_operation(op, solution))), upnext) diff --git a/graphkit/plot.py b/graphkit/plot.py index 19b1cdeb..b41ea99f 100644 --- a/graphkit/plot.py +++ b/graphkit/plot.py @@ -251,7 +251,7 @@ def get_node_name(a): # kw["tooltip"] = str(solution.get(nx_node)) # not working :-() node = pydot.Node(name=nx_node, shape=shape, **kw) else: # Operation - kw = {} + kw = {"fontname": "italic"} if steps and nx_node in steps: kw["penwdth"] = steps_thickness @@ -337,6 +337,7 @@ def render_pydot(dot, filename=None, show=False): See :meth:`Plotter.plot()` for sample code. """ + # TODO: research https://plot.ly/~empet/14007.embed # Save plot # if filename: @@ -381,10 +382,10 @@ def legend(filename=None, show=None): subgraph cluster_legend { label="Graphkit Legend"; - operation [shape=oval]; - graphop [shape=egg label="graph operation"]; - insteps [penwidth=3 label="execution step"]; - executed [style=filled fillcolor=wheat]; + operation [shape=oval fontname=italic]; + graphop [shape=egg label="graph operation" fontname=italic]; + insteps [penwidth=3 label="execution step" fontname=italic]; + executed [style=filled fillcolor=wheat fontname=italic]; operation -> graphop -> insteps -> executed [style=invis]; data [shape=rect];