12 """Determine critical path for a given precedence trace."""
13 from __future__
import print_function
15 __author__ =
"Illya Shapoval"
23 warnings.filterwarnings(
"ignore", message=
'"is" with a literal', category=SyntaxWarning)
29 """Find critical path, print algorithms on it and its length."""
31 assert tuple(
map(int, nx.__version__.split(
"."))) >= (
34 ),
"This script requires Networkx version 2.0 or higher"
36 trace = nx.read_graphml(path_to_trace_file)
38 for inNode, outNode, edge_attrs
in trace.in_edges(data=
True):
39 edge_attrs[
"Runtime"] = nx.get_node_attributes(trace,
"Runtime")[outNode]
41 cpath = nx.algorithms.dag.dag_longest_path(trace, weight=
"Runtime")
43 print(
"Algorithms on the critical path (%i): " % len(cpath))
45 print(
" {:<40} Runtime (ns)".
format(
"Name"))
46 print(
" -----------------------------------------------------")
50 trace.node[node_id].
get(
"Name"), trace.node[node_id].
get(
"Runtime")
55 "\nTotal critical path time: ",
56 nx.algorithms.dag.dag_longest_path_length(trace, weight=
"Runtime"),
63 parser = argparse.ArgumentParser(
64 description=
"Determine critical path for a precedence trace generated by the Avalanche Scheduler."
67 "path_to_trace_file", help=
"Path to GRAPHML precedence trace file.", type=str
69 args = parser.parse_args()
74 if __name__ ==
"__main__":