12 """Determine critical path for a given precedence trace."""
14 __author__ =
"Illya Shapoval"
22 warnings.filterwarnings(
"ignore", message=
'"is" with a literal', category=SyntaxWarning)
28 """Find critical path, print algorithms on it and its length."""
30 assert tuple(
map(int, nx.__version__.split(
"."))) >= (
33 ),
"This script requires Networkx version 2.0 or higher"
35 trace = nx.read_graphml(path_to_trace_file)
37 for inNode, outNode, edge_attrs
in trace.in_edges(data=
True):
38 edge_attrs[
"Runtime"] = nx.get_node_attributes(trace,
"Runtime")[outNode]
40 cpath = nx.algorithms.dag.dag_longest_path(trace, weight=
"Runtime")
42 print(
"Algorithms on the critical path (%i): " % len(cpath))
44 print(
" {:<40} Runtime (ns)".
format(
"Name"))
45 print(
" -----------------------------------------------------")
49 trace.node[node_id].
get(
"Name"), trace.node[node_id].
get(
"Runtime")
54 "\nTotal critical path time: ",
55 nx.algorithms.dag.dag_longest_path_length(trace, weight=
"Runtime"),
61 parser = argparse.ArgumentParser(
62 description=
"Determine critical path for a precedence trace generated by the Avalanche Scheduler."
65 "path_to_trace_file", help=
"Path to GRAPHML precedence trace file.", type=str
67 args = parser.parse_args()
72 if __name__ ==
"__main__":