CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
DOTExport.DotProducer Class Reference
Inheritance diagram for DOTExport.DotProducer:

Public Member Functions

def __call__ (self)
 
def __init__ (self, data, options, shapes)
 
def connectPaths (self)
 
def connectTags (self)
 
def getTopLevel (self)
 
def makePath (self, path, endpath=False)
 
def nodeLabel (self, obj)
 
def nodeURL (self, obj)
 
def produceLegend (self)
 
def produceNodes (self)
 
def producePaths (self)
 
def produceServices (self)
 
def produceSource (self)
 
def recurseChildren (self, obj)
 
def seqRecurseChildren (self, obj)
 

Public Attributes

 data
 
 endstarts
 
 nodes
 
 options
 
 pathends
 
 pathstarts
 
 shapes
 
 toplevel
 

Detailed Description

Definition at line 20 of file DOTExport.py.

Constructor & Destructor Documentation

def DOTExport.DotProducer.__init__ (   self,
  data,
  options,
  shapes 
)

Definition at line 21 of file DOTExport.py.

21  def __init__(self,data,options,shapes):
22  self.data = data
23  self.options = options
24  self.shapes = shapes
25  self.nodes={}
26  #lists of starts, ends of paths for path-endpath and source-path connections
27  self.pathstarts=[]
28  self.pathends=[]
29  self.endstarts=[]
30  self.toplevel = self.getTopLevel()
31 
def getTopLevel(self)
Definition: DOTExport.py:32
def __init__(self, data, options, shapes)
Definition: DOTExport.py:21

Member Function Documentation

def DOTExport.DotProducer.__call__ (   self)

Definition at line 242 of file DOTExport.py.

References DOTExport.DotProducer.connectPaths(), DOTExport.DotProducer.connectTags(), join(), DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, DOTExport.DotProducer.produceLegend(), DOTExport.DotProducer.produceNodes(), DOTExport.DotProducer.producePaths(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.produceSource().

242  def __call__(self):
243  blocks=[]
244  if self.options['legend']:
245  blocks += [self.produceLegend()]
246  blocks += [self.producePaths()]
247  if self.options['seqconnect']:
248  blocks += [self.connectPaths()]
249  if self.options['tagconnect']:
250  blocks += [self.connectTags()]
251  if self.options['source']:
252  blocks += [self.produceSource()]
253  if self.options['es'] or self.options['services']:
254  blocks += [self.produceServices()]
255  blocks += [self.produceNodes()]
256  if self.data.process():
257  return 'digraph configbrowse {\nsubgraph clusterProcess {\nlabel="%s\\n%s"\nfontsize=%s\nfontname="%s"\n%s\n}\n}\n' % (self.data.process().name_(),self.data._filename,self.options['font_size'],self.options['font_name'],'\n'.join(blocks))
258  else:
259  return 'digraph configbrowse {\nsubgraph clusterCFF {\nlabel="%s"\nfontsize=%s\nfontname="%s"\n%s\n}\n}\n' % (self.data._filename,self.options['font_size'],self.options['font_name'],'\n'.join(blocks))
260 
261 
262 
def produceSource(self)
Definition: DOTExport.py:183
def produceLegend(self)
Definition: DOTExport.py:236
def producePaths(self)
Definition: DOTExport.py:147
def connectPaths(self)
Definition: DOTExport.py:161
def produceNodes(self)
Definition: DOTExport.py:226
def produceServices(self)
Definition: DOTExport.py:196
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def connectTags(self)
Definition: DOTExport.py:168
def DOTExport.DotProducer.connectPaths (   self)

Definition at line 161 of file DOTExport.py.

References DOTExport.DotProducer.endstarts, and DOTExport.DotProducer.pathends.

Referenced by DOTExport.DotProducer.__call__().

161  def connectPaths(self):
162  result=''
163  for p in self.pathends:
164  for p2 in self.endstarts:
165  result+="%s->%s\n" % (p,p2)
166  return result
167 
def connectPaths(self)
Definition: DOTExport.py:161
def DOTExport.DotProducer.connectTags (   self)

Definition at line 168 of file DOTExport.py.

References DOTExport.DotProducer.nodes, DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, and DOTExport.DotProducer.options.

Referenced by DOTExport.DotProducer.__call__().

168  def connectTags(self):
169  #if we are connecting by tag, add labelled tag joining lines
170  #this doesn't have to be exclusive with sequence connection, by stylistically probably should be
171  result=''
172  allobjects = [self.nodes[n]['obj'] for n in self.nodes if self.nodes[n]['inpath']]
173  self.data.readConnections(allobjects)
174  connections = self.data.connections()
175  for objects,names in connections.items():
176  if self.options['taglabel']:
177  result += '%s->%s[label="%s",color="%s",fontcolor="%s",fontsize=%s,fontname="%s"]\n' % (objects[0],objects[1],names[1],self.options['color_inputtag'],self.options['color_inputtag'],self.options['font_size'],self.options['font_name'])
178  else:
179  result += '%s->%s[color="%s"]\n' % (objects[0],objects[1],self.options['color_inputtag'])
180  return result
181 
182 
def connectTags(self)
Definition: DOTExport.py:168
def DOTExport.DotProducer.getTopLevel (   self)

Definition at line 32 of file DOTExport.py.

References DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, and DOTExport.DotProducer.options.

32  def getTopLevel(self):
33 
34  #build a dictionary of available top-level objects
35  all_toplevel={}
36  if self.data.process():
37  for tlo in self.data.children(self.data.topLevelObjects()[0]):
38  children = self.data.children(tlo)
39  if children:
40  all_toplevel[tlo._label]=children
41  else:
42  #case if we have only an anonymous (non-process) file
43  #pick up (modules, sequences, paths)
44  for tlo in self.data.topLevelObjects():
45  if self.data.type(tlo)=='Sequence':
46  if 'sequences' in all_toplevel:
47  all_toplevel['sequences']+=[tlo]
48  else:
49  all_toplevel['sequences']=[tlo]
50  if self.data.type(tlo)=='Path':
51  if 'paths' in all_toplevel:
52  all_toplevel['paths']+=[tlo]
53  else:
54  all_toplevel['paths']=[tlo]
55  if self.data.type(tlo) in ('EDAnalyzer','EDFilter','EDProducer','OutputModule'):
56  self.nodes[self.data.label(tlo)]={'obj':tlo,'n_label':self.nodeLabel(tlo),'n_shape':self.shapes.get(self.data.type(tlo),'plaintext'),'inpath':True}
57  if self.options['services'] and self.data.type(tlo)=='Service':
58  self.nodes[self.data.label(tlo)]={'obj':tlo,'n_label':self.nodeLabel(tlo),'n_shape':self.shapes.get(self.data.type(tlo),'plaintext'),'inpath':False}
59  if self.options['es'] and self.data.type(tlo) in ('ESSource','ESProducer'):
60  self.nodes[self.data.label(tlo)]={'obj':tlo,'n_label':self.nodeLabel(tlo),'n_shape':self.shapes.get(self.data.type(tlo),'plaintext'),'inpath':False}
61  return all_toplevel
62 
def getTopLevel(self)
Definition: DOTExport.py:32
def nodeLabel(self, obj)
Definition: DOTExport.py:89
def DOTExport.DotProducer.makePath (   self,
  path,
  endpath = False 
)

Definition at line 105 of file DOTExport.py.

References join(), DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, DOTExport.DotProducer.recurseChildren(), and DOTExport.DotProducer.seqRecurseChildren().

Referenced by DOTExport.DotProducer.producePaths().

105  def makePath(self,path,endpath=False):
106  children = self.recurseChildren(path)
107  pathlabel = self.data.label(path)
108  if self.options['file']:
109  pathlabel += '\\n%s:%s'%(self.data.pypackage(path),self.data.lineNumber(path))
110  if endpath:
111  pathresult = 'subgraph cluster%s {\nlabel="%s"\ncolor="%s"\nfontcolor="%s"\nfontname="%s"\nfontsize=%s\n' % (self.data.label(path),pathlabel,self.options['color_endpath'],self.options['color_endpath'],self.options['font_name'],self.options['font_size'])
112  else:
113  pathresult = 'subgraph cluster%s {\nlabel="%s"\ncolor="%s"\nfontcolor="%s"\nfontname="%s"\nfontsize=%s\n' % (self.data.label(path),pathlabel,self.options['color_path'],self.options['color_path'],self.options['font_name'],self.options['font_size'])
114  if self.options['seqconnect']:
115  if endpath:
116  self.endstarts.append('endstart_%s'%self.data.label(path))
117  self.nodes['endstart_%s'%self.data.label(path)]={'obj':path,'n_label':'Start %s'%self.data.label(path),'n_color':'grey','n_shape':'plaintext','inpath':False}
118  else:
119  self.pathstarts.append('start_%s'%self.data.label(path))
120  self.pathends.append('end_%s'%self.data.label(path))
121  self.nodes['start_%s'%self.data.label(path)]={'obj':path,'n_label':'Start %s'%self.data.label(path),'n_color':'grey','n_shape':'plaintext','inpath':False}
122  self.nodes['end_%s'%self.data.label(path)]={'obj':path,'n_label':'End %s'%self.data.label(path),'n_color':'grey','n_shape':'plaintext','inpath':False}
123  labels=[]
124  for c in children:
125  #this is also done in seqRecurseChildren, so will be duplicated
126  #unncessary, but relatively cheap and saves more cff/cfg conditionals
127  self.nodes[self.data.label(c)]={'obj':c,'n_label':self.nodeLabel(c),'n_shape':self.shapes.get(self.data.type(c),'plaintext'),'inpath':True}
128  labels.append(self.data.label(c))
129  if self.options['seqconnect']:
130  pathresult += '->'.join(labels)+'\n'
131  else:
132  if not self.options['seq']:
133  pathresult += '\n'.join(labels)+'\n'
134  if self.options['seq']:
135  if self.data.children(path):
136  for path_child in self.data.children(path):
137  pathresult += self.seqRecurseChildren(path_child)
138  pathresult += '}\n'
139  if len(labels)>0 and self.options['seqconnect']:
140  if endpath:
141  pathresult += 'endstart_%s->%s\n' % (self.data.label(path),labels[0])
142  else:
143  pathresult += 'start_%s->%s\n%s->end_%s\n' % (self.data.label(path),labels[0],labels[-1],self.data.label(path))
144 
145  return pathresult
146 
def makePath(self, path, endpath=False)
Definition: DOTExport.py:105
def recurseChildren(self, obj)
Definition: DOTExport.py:78
def seqRecurseChildren(self, obj)
Definition: DOTExport.py:63
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def nodeLabel(self, obj)
Definition: DOTExport.py:89
def DOTExport.DotProducer.nodeLabel (   self,
  obj 
)

Definition at line 89 of file DOTExport.py.

References DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, and DOTExport.DotProducer.options.

Referenced by DOTExport.DotProducer.getTopLevel(), DOTExport.DotProducer.makePath(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.seqRecurseChildren().

89  def nodeLabel(self,obj):
90  result = self.data.label(obj)
91  if self.options['class']:
92  result += '\\n%s'%self.data.classname(obj)
93  if self.options['file']:
94  result += '\\n%s:%s'%(self.data.pypackage(obj),self.data.lineNumber(obj))
95  return result
96 
97  #generate an appropriate URL by replacing placeholders in baseurl
def nodeLabel(self, obj)
Definition: DOTExport.py:89
def DOTExport.DotProducer.nodeURL (   self,
  obj 
)

Definition at line 98 of file DOTExport.py.

References DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, and python.rootplot.root2matplotlib.replace().

Referenced by DOTExport.DotProducer.produceNodes().

98  def nodeURL(self,obj):
99  classname = self.data.classname(obj)
100  pypath = self.data.pypath(obj)
101  pyline = self.data.lineNumber(obj)
102  url = self.options['urlbase'].replace('$classname',classname).replace('$pypath',pypath).replace('$pyline',pyline)
103  return url
104 
def replace(string, replacements)
def nodeURL(self, obj)
Definition: DOTExport.py:98
def DOTExport.DotProducer.produceLegend (   self)
Return a legend subgraph using current shape and colour preferences.

Definition at line 236 of file DOTExport.py.

References DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, DOTExport.DotProducer.shapes, cms::DDParsingContext.shapes, and EcalLaserAnalyzer2.shapes.

Referenced by DOTExport.DotProducer.__call__().

236  def produceLegend(self):
237  """
238  Return a legend subgraph using current shape and colour preferences.
239  """
240  return 'subgraph clusterLegend {\nlabel="legend"\ncolor=red\nSource->Producer->Filter->Analyzer\nService->ESSource[style=invis]\nESSource->ESProducer[style=invis]\nProducer->Filter[color="%s",label="InputTag",fontcolor="%s"]\nProducer[shape=%s]\nFilter[shape=%s]\nAnalyzer[shape=%s]\nESSource[shape=%s]\nESProducer[shape=%s]\nSource[shape=%s]\nService[shape=%s]\nsubgraph clusterLegendSequence {\nlabel="Sequence"\ncolor="%s"\nfontcolor="%s"\nProducer\nFilter\n}\n}\n' % (self.options['color_inputtag'],self.options['color_inputtag'],self.shapes['EDProducer'],self.shapes['EDFilter'],self.shapes['EDAnalyzer'],self.shapes['ESSource'],self.shapes['ESProducer'],self.shapes['Source'],self.shapes['Service'],self.options['color_sequence'],self.options['color_sequence'])
241 
def produceLegend(self)
Definition: DOTExport.py:236
def DOTExport.DotProducer.produceNodes (   self)

Definition at line 226 of file DOTExport.py.

References mps_monitormerge.items, join(), DOTExport.DotProducer.nodes, DOTExport.DotProducer.nodeURL(), DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, and DOTExport.DotProducer.options.

Referenced by DOTExport.DotProducer.__call__().

226  def produceNodes(self):
227  result=''
228  for n in self.nodes:
229  self.nodes[n]['n_fontname']=self.options['font_name']
230  self.nodes[n]['n_fontsize']=self.options['font_size']
231  if self.options['url']:
232  self.nodes[n]['n_URL']=self.nodeURL(self.nodes[n]['obj'])
233  result += "%s[%s]\n" % (n,','.join(['%s="%s"' % (k[2:],v) for k,v in self.nodes[n].items() if k[0:2]=='n_']))
234  return result
235 
def nodeURL(self, obj)
Definition: DOTExport.py:98
def produceNodes(self)
Definition: DOTExport.py:226
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def DOTExport.DotProducer.producePaths (   self)

Definition at line 147 of file DOTExport.py.

References DOTExport.DotProducer.makePath(), Json::Path.makePath(), DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, DOTExport.DotProducer.seqRecurseChildren(), and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

147  def producePaths(self):
148  result=''
149  if 'paths' in self.toplevel:
150  for path in self.toplevel['paths']:
151  result += self.makePath(path)
152  if self.options['endpath']:
153  if 'endpaths' in self.toplevel:
154  for path in self.toplevel['endpaths']:
155  result += self.makePath(path,True)
156  if 'sequences' in self.toplevel:
157  for seq in self.toplevel['sequences']:
158  result += self.seqRecurseChildren(seq)
159  return result
160 
def makePath(self, path, endpath=False)
Definition: DOTExport.py:105
def producePaths(self)
Definition: DOTExport.py:147
def seqRecurseChildren(self, obj)
Definition: DOTExport.py:63
def DOTExport.DotProducer.produceServices (   self)

Definition at line 196 of file DOTExport.py.

References SiStripPI.max, DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, DOTExport.DotProducer.recurseChildren(), DOTExport.DotProducer.shapes, cms::DDParsingContext.shapes, EcalLaserAnalyzer2.shapes, and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

196  def produceServices(self):
197  # add service, eventsetup nodes
198  # this will usually result in thousands and isn't that interesting
199  servicenodes=[]
200  result=''
201  if self.options['es']:
202  if 'essources' in self.toplevel:
203  for e in self.toplevel['essources']:
204  servicenodes.append(self.data.label(e))
205  self.nodes[self.data.label(e)]={'obj':e,'n_label':self.nodeLabel(e), 'n_shape':self.shapes['ESSource'],'inpath':False}
206  if 'esproducers' in self.toplevel:
207  for e in self.toplevel['esproducers']:
208  servicenodes.append(self.data.label(e))
209  self.nodes[self.data.label(e)]={'obj':e,'n_label':self.nodeLabel(e), 'n_shape':self.shapes['ESProducer'],'inpath':False}
210  if self.options['services']:
211  if 'services' in self.toplevel:
212  for s in self.toplevel['services']:
213  self.servicenodes.append(self.data.label(s))
214  self.nodes[self.data.label(s)]={'obj':s,'n_label':self.nodeLabel(e), 'n_shape':self.shapes['Service'],'inpath':False}
215  #find the maximum path and endpath lengths for servicenode layout
216  maxpath=max([len(recurseChildren(path) for path in self.toplevel.get('paths',(0,)))])
217  maxendpath=max([len(recurseChildren(path) for path in self.toplevel.get('endpaths',(0,)))])
218 
219  #add invisible links between service nodes where necessary to ensure they only fill to the same height as the longest path+endpath
220  #this constraint should only apply for link view
221  for i,s in enumerate(servicenodes[:-1]):
222  if not i%(maxpath+maxendpath)==(maxpath+maxendpath)-1:
223  result+='%s->%s[style=invis]\n' % (s,servicenodes[i+1])
224  return result
225 
def recurseChildren(self, obj)
Definition: DOTExport.py:78
def produceServices(self)
Definition: DOTExport.py:196
def nodeLabel(self, obj)
Definition: DOTExport.py:89
def DOTExport.DotProducer.produceSource (   self)

Definition at line 183 of file DOTExport.py.

References DOTExport.DotProducer.nodes, DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, DOTExport.DotProducer.pathstarts, DOTExport.DotProducer.shapes, cms::DDParsingContext.shapes, EcalLaserAnalyzer2.shapes, and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

183  def produceSource(self):
184  #add the source
185  #if we are connecting sequences, connect it to all the path starts
186  #if we are connecting sequences and have a schedule, connect it to path #0
187  result=''
188  if 'source' in self.toplevel:
189  for s in self.toplevel['source']:
190  self.nodes['source']={'obj':s,'n_label':self.data.classname(s),'n_shape':self.shapes['Source']}
191  if self.options['seqconnect']:
192  for p in self.pathstarts:
193  result += 'source->%s\n' % (p)
194  return result
195 
def produceSource(self)
Definition: DOTExport.py:183
def DOTExport.DotProducer.recurseChildren (   self,
  obj 
)

Definition at line 78 of file DOTExport.py.

References DOTExport.DotProducer.recurseChildren().

Referenced by DOTExport.DotProducer.makePath(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.recurseChildren().

78  def recurseChildren(self,obj):
79  result=[]
80  children=self.data.children(obj)
81  if children:
82  for c in children:
83  result += self.recurseChildren(c)
84  else:
85  result.append(obj)
86  return result
87 
def recurseChildren(self, obj)
Definition: DOTExport.py:78
def DOTExport.DotProducer.seqRecurseChildren (   self,
  obj 
)

Definition at line 63 of file DOTExport.py.

References DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DOTExport.DotProducer.options, and DOTExport.DotProducer.seqRecurseChildren().

Referenced by DOTExport.DotProducer.makePath(), DOTExport.DotProducer.producePaths(), and DOTExport.DotProducer.seqRecurseChildren().

63  def seqRecurseChildren(self,obj):
64  children = self.data.children(obj)
65  if children:
66  seqlabel = self.data.label(obj)
67  if self.options['file']:
68  seqlabel += '\\n%s:%s' % (self.data.pypackage(obj),self.data.lineNumber(obj))
69  result='subgraph clusterSeq%s {\nlabel="Sequence %s"\ncolor="%s"\nfontcolor="%s"\nfontname="%s"\nfontsize=%s\n' % (self.data.label(obj),seqlabel,self.options['color_sequence'],self.options['color_sequence'],self.options['font_name'],self.options['font_size'])
70  for c in children:
71  result += self.seqRecurseChildren(c)
72  result+='}\n'
73  return result
74  else:
75  self.nodes[self.data.label(obj)]={'obj':obj,'n_label':self.nodeLabel(obj),'n_shape':self.shapes.get(self.data.type(obj),'plaintext'),'inpath':True}
76  return '%s\n'%self.data.label(obj)
77 
def seqRecurseChildren(self, obj)
Definition: DOTExport.py:63
def nodeLabel(self, obj)
Definition: DOTExport.py:89

Member Data Documentation

DOTExport.DotProducer.data
DOTExport.DotProducer.endstarts

Definition at line 29 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectPaths().

DOTExport.DotProducer.nodes
DOTExport.DotProducer.options
DOTExport.DotProducer.pathends

Definition at line 28 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectPaths().

DOTExport.DotProducer.pathstarts

Definition at line 27 of file DOTExport.py.

Referenced by DOTExport.DotProducer.produceSource().

DOTExport.DotProducer.shapes
DOTExport.DotProducer.toplevel