23f7a6de9a581d18a1fb87582f50b6efb72e7683,elfi/executor.py,Executor,get_execution_order,#Any#Any#,84
Before Change
for output_node in G.graph["outputs"]:
if dep_graph.has_node(output_node):
nodes.update([output_node])
nodes.update(nx.ancestors(dep_graph, output_node))
return [n for n in order if n in nodes]
After Change
// Get the cache dict if it exists
cache = G.graph.get("_executor_cache", {})
output_nodes = G.graph["outputs"]
// Filter those output nodes who have an operation to run
needed = tuple(sorted(node for node in output_nodes if "operation" in G.node[node]))
if needed not in cache:
// Resolve the nodes that need to be executed in the graph
nodes_to_execute = set(needed)
if "sort_order" not in cache:
cache["sort_order"] = nx_constant_topological_sort(G)
sort_order = cache["sort_order"]
// Resolve the dependencies of needed
dep_graph = nx.DiGraph(G.edges())
for node in sort_order:
attr = G.node[node]
if attr.keys() >= {"operation", "output"}:
raise ValueError("Generative graph has both op and output present")
// Remove those nodes from the dependency graph whose outputs are present
if "output" in attr:
dep_graph.remove_node(node)
elif "operation" not in attr:
raise ValueError("Generative graph has no op or output present")
// Add the dependencies of the needed nodes
for needed_node in needed:
nodes_to_execute.update(nx.ancestors(dep_graph, needed_node))
// Turn in to a sorted list and cache
cache[needed] = [n for n in sort_order if n in nodes_to_execute]
return cache[needed]
@staticmethod
def _run(fn, node, G):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances Project Name: elfi-dev/elfi
Commit Name: 23f7a6de9a581d18a1fb87582f50b6efb72e7683
Time: 2017-09-08
Author: jarno.lintusaari@aalto.fi
File Name: elfi/executor.py
Class Name: Executor
Method Name: get_execution_order
Project Name: jazzband/django-debug-toolbar
Commit Name: c20e83fc946c8898d40b0210f71286575891ae94
Time: 2011-09-15
Author: brandon@konkle.us
File Name: debug_toolbar/panels/__init__.py
Class Name: DebugPanel
Method Name: record_stats
Project Name: pantsbuild/pants
Commit Name: aa23024157360be890e9c50368ff54ca05ef7218
Time: 2019-05-18
Author: stuhood@gmail.com
File Name: src/python/pants/goal/context.py
Class Name: Context
Method Name: targets