37 from sys
import stderr, argv
39 from os.path
import basename
41 import FWCore.ParameterSet.Config
as cms
42 stderr.write(
"Writing plot to %s\n" % (filename,))
43 dot = popen(
"dot -Tpng > %s" % (filename,),
"w")
45 dot.write(
"digraph G { \n rankdir=\"LR\" \n")
50 if isinstance(v, (cms.EDProducer, cms.EDFilter, cms.EDAnalyzer)):
54 def greptags(ps,basename=""):
56 for pn, pv
in ps.parameters_().
items():
57 type = pv.configTypeName()
58 if type ==
'InputTag' : ret.append( (basename+pn, pv.configValue()) )
59 elif type ==
'VInputTag' : ret += [ (
"%s%s[%d]"%(basename,pn,i+1),v.configValue())
for i,v
in enumerate(pv.value()) ]
60 elif type ==
'PSet' : ret += greptags(pv, basename+pn+
'.')
61 elif type ==
'VPset' :
62 for r1
in [greptags(pvi, basename+pn+
'.')
for pvi
in pv.value()]: ret += r1
64 def escapeParValue(name):
return sub(
r":.*",
"", name)
67 dot.write(
"%s [ shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (m.label(),
'green',m.label()) +
"\n")
70 deps[m.label()] = tags;
71 if m.label()
not in alls: alls[m.label()]=
True 73 tve = escapeParValue(tv)
74 if tve
not in alls: alls[tve]=
True 76 if printOuter: names = alls.keys()
79 ne = escapeParValue(n)
81 dot.write(
"%s [ shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (ne,
'yellow',ne) +
"\n")
83 for tn,tv
in deps[ne]:
84 tve = escapeParValue(tv)
85 if printOuter
or tve
in deps:
87 if printLinkNames: style =
" [label=\"%s\" ]" %(tn,)
88 dot.write(
"%s -> %s%s\n"%(tve,ne,style))
93 def plotModuleInputs(seq, filename, printOuter=True, printLinkNames=True)