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,
"Run Time (us)")[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 (us)".
format(
"Name"))
45 print(
" -----------------------------------------------------")
49 trace.nodes[node_id].
get(
"Name"),
50 trace.nodes[node_id].
get(
"Run Time (us)"),
55 "\nTotal critical path time: ",
56 nx.algorithms.dag.dag_longest_path_length(trace, weight=
"Runtime"),
62 parser = argparse.ArgumentParser(
63 description=
"Determine critical path for a precedence trace generated by the Avalanche Scheduler."
66 "path_to_trace_file", help=
"Path to GRAPHML precedence trace file.", type=str
68 args = parser.parse_args()
73 if __name__ ==
"__main__":