12 """algdata_from_menu uses a graph created from an L1Menu to created
13 an execution oredered sequence of AlgData objects. AlgData have
14 configuration information that is used to configure a GlobalSim
15 L1TopoAlgorithm AlgTool"""
17 from .l1MenuGraph
import l1MenuGraph
21 dot(G,
"menu_graph.dot")
25 for ad
in alg_data_list:
26 algname2sn[ad.name] = ad.sn
28 assert len(algname2sn) == len(alg_data_list)
31 txt_l = [
'%s %d' % (k, v)
for k, v
in algname2sn.items()]
32 txt =
'\n'.
join(txt_l)
34 txt_l = [
'%d %s' % (v, k)
for k, v
in algname2sn.items()]
35 txt +=
'\n'.
join(txt_l)
36 with open(
'algname2sn.txt',
'w')
as fh:
42 roots = [algname2sn[name]
43 for name
in root_names
if name
in algname2sn]
45 logger.error(
"no requested root nodes present in menu")
46 elif len(roots) < len(root_names):
48 'requested ' +
str(len(root_names)) +
' root nodes ' +
49 'found ' +
str(len(roots)) +
' in menu')
57 roots = [i
for i
in range(1, G.V)]
63 topo_m = Topological(G, roots)
65 logger.debug(
'G is a DAG:' +
str(topo_m.isDAG()))
66 order_sn = topo_m.order()
67 logger.debug(
'root nodes:' +
str(roots))
68 logger.debug(
'Topological order [' +
str(len(order_sn)) +
']')
69 logger.debug(
str(order_sn))
71 dot(G,
"G_ordered.dot", order_sn)
75 for ad
in alg_data_list:
76 sn2algData[ad.sn] = ad
78 assert len(sn2algData) == len(alg_data_list)
80 ordered_algs = [
'%d %s %s' % (i,
84 for e
in ordered_algs:
87 ordered_algData = [sn2algData[sn]
for sn
in order_sn]
88 logger.verbose(
'ordered_algData:[' +
str(len(ordered_algData))+
']:')
89 for ad
in ordered_algData:
90 logger.verbose(
str(ad))
92 return ordered_algData