CMS 3D CMS Logo

Functions | Variables

circuitry Namespace Reference

Functions

def plotModuleInputs
def plotSequences

Variables

 _dot
 _seq
 _stack

Function Documentation

def circuitry::plotModuleInputs (   seq,
  filename,
  printOuter = True,
  printLinkNames = True 
)

Definition at line 36 of file circuitry.py.

00037                                                                       :
00038     from sys import stderr, argv
00039     from os import popen
00040     from os.path import basename
00041     from re import sub;
00042     import FWCore.ParameterSet.Config as cms
00043     stderr.write("Writing plot to %s\n" % (filename,))
00044     dot = popen("dot -Tpng > %s" % (filename,), "w")
00045     #dot = open("%s.dot" % (filename,), "w")
00046     dot.write("digraph G { \n rankdir=\"LR\" \n")
00047     deps = {}; alls = {}
00048     modules = []
00049     class visitor(object):
00050         def enter(self,v):
00051             if isinstance(v, (cms.EDProducer, cms.EDFilter, cms.EDAnalyzer)):
00052                 modules.append(v)
00053         def leave(self,v):
00054             pass
00055     def greptags(ps,basename=""):
00056         ret = []
00057         for pn, pv in ps.parameters_().items():
00058             type = pv.configTypeName()
00059             if type == 'InputTag'    : ret.append( (basename+pn, pv.configValue()) )
00060             elif type == 'VInputTag' : ret += [ ("%s%s[%d]"%(basename,pn,i+1),v.configValue()) for i,v in enumerate(pv.value()) ]
00061             elif type == 'PSet'      : ret += greptags(pv, basename+pn+'.')
00062             elif type == 'VPset'     : 
00063                 for r1 in [greptags(pvi, basename+pn+'.') for pvi in pv.value()]: ret += r1
00064         return ret
00065     def escapeParValue(name): return sub(r":.*","", name)
00066     seq.visit(visitor())
00067     for m in modules:
00068         dot.write( "%s [  shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (m.label(),'green',m.label()) + "\n")
00069         tags = greptags(m)
00070         #stderr.write("Tags for %s: %s\n" % (m.label(), tags))
00071         deps[m.label()] = tags;
00072         if not alls.has_key(m.label()): alls[m.label()]=True
00073         for (tn,tv) in tags:
00074             tve = escapeParValue(tv)
00075             if not alls.has_key(tve): alls[tve]=True
00076     names = deps.keys();
00077     if printOuter: names = alls.keys()
00078     done = {}
00079     for n in names:
00080         ne = escapeParValue(n)
00081         if not deps.has_key(ne):
00082             dot.write( "%s [  shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (ne,'yellow',ne) + "\n")
00083         else:
00084             for tn,tv in deps[ne]:
00085                 tve = escapeParValue(tv)
00086                 if printOuter or deps.has_key(tve):
00087                     style = ""
00088                     if printLinkNames: style = " [label=\"%s\" ]" %(tn,)
00089                     dot.write(  "%s -> %s%s\n"%(tve,ne,style))
00090     dot.write("}\n")
00091     dot.close()
00092 
00093 
def circuitry::plotSequences (   seq,
  filename 
)

Definition at line 1 of file circuitry.py.

00002                                :
00003     from sys import stderr, argv
00004     from os import popen
00005     from os.path import basename
00006     from re import sub;
00007     import FWCore.ParameterSet.Config as cms
00008     stderr.write("Writing plot to %s\n" % (filename,))
00009     dot = popen("dot -Tpng > %s" % (filename,), "w")
00010     dot.write("digraph G { \n rankdir=\"LR\" \n")
00011     class visitor(object):
00012         def __init__(self,seq,dot):
00013             self._dot = dot
00014             self._stack = []
00015             self._seq = seq.label()
00016             self._dot.write( "%s [  shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (self._seq,'orange',self._seq) + "\n" )
00017         def seq(self, seq):
00018             self._stack.append(self._seq)
00019             self._seq = seq.label()
00020         def enter(self,v):
00021             if isinstance(v, cms.Sequence):
00022                 self._dot.write( "%s [  shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (v.label(),'orange',v.label()) + "\n" )
00023                 self.dep(v)
00024                 self.seq(v)
00025             if isinstance(v, (cms.EDProducer, cms.EDFilter, cms.EDAnalyzer)):
00026                 self._dot.write( "%s [  shape=rect style=filled fillcolor=%s label=\"%s\" ]" % (v.label(),'green',v.label()) + "\n" ) 
00027                 self.dep(v)
00028         def leave(self,v):
00029             if isinstance(v, cms.Sequence):
00030                 self._seq = self._stack.pop()
00031         def dep(self,v):
00032             self._dot.write("%s -> %s" %(v.label(), self._seq) +"\n")
00033     seq.visit(visitor(seq,dot))
00034     dot.write("}\n")
00035     dot.close()


Variable Documentation

Definition at line 1 of file circuitry.py.

Definition at line 1 of file circuitry.py.

Definition at line 1 of file circuitry.py.