Skip to content

Commit

Permalink
minor leftovers (refact & docs)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed Oct 10, 2019
1 parent 510a9cd commit 7bd3f85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions graphkit/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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=()):
"""
Expand Down Expand Up @@ -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)

Expand Down
11 changes: 6 additions & 5 deletions graphkit/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 7bd3f85

Please sign in to comment.