12 """Determine critical path for a given precedence trace.""" 
   13 from __future__ 
import print_function
 
   15 __author__ = 
"Illya Shapoval" 
   22 warnings.filterwarnings(
 
   23     "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(
"."))) >=
 
   32             (2, 0)), 
"This script requires Networkx version 2.0 or higher" 
   34     trace = nx.read_graphml(path_to_trace_file)
 
   36     for inNode, outNode, edge_attrs 
in trace.in_edges(data=
True):
 
   37         edge_attrs[
'Runtime'] = nx.get_node_attributes(trace,
 
   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(
"  -----------------------------------------------------")
 
   47         print(
"  {:<40}: {}".
format(trace.node[node_id].
get(
'Name'),
 
   48                                     trace.node[node_id].
get(
'Runtime')))
 
   50     print(
"\nTotal critical path time: ",
 
   51           nx.algorithms.dag.dag_longest_path_length(trace, weight=
'Runtime'),
 
   57     parser = argparse.ArgumentParser(
 
   59         "Determine critical path for a precedence trace generated by the Avalanche Scheduler." 
   63         help=
"Path to GRAPHML precedence trace file.",
 
   65     args = parser.parse_args()
 
   70 if __name__ == 
'__main__':