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 18 of file DOTExport.py.

Constructor & Destructor Documentation

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

Definition at line 19 of file DOTExport.py.

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

Member Function Documentation

def DOTExport.DotProducer.__call__ (   self)

Definition at line 240 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().

240  def __call__(self):
241  blocks=[]
242  if self.options['legend']:
243  blocks += [self.produceLegend()]
244  blocks += [self.producePaths()]
245  if self.options['seqconnect']:
246  blocks += [self.connectPaths()]
247  if self.options['tagconnect']:
248  blocks += [self.connectTags()]
249  if self.options['source']:
250  blocks += [self.produceSource()]
251  if self.options['es'] or self.options['services']:
252  blocks += [self.produceServices()]
253  blocks += [self.produceNodes()]
254  if self.data.process():
255  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))
256  else:
257  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))
258 
259 
260 
def produceSource(self)
Definition: DOTExport.py:181
def produceLegend(self)
Definition: DOTExport.py:234
def producePaths(self)
Definition: DOTExport.py:145
def connectPaths(self)
Definition: DOTExport.py:159
def produceNodes(self)
Definition: DOTExport.py:224
def produceServices(self)
Definition: DOTExport.py:194
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def connectTags(self)
Definition: DOTExport.py:166
def DOTExport.DotProducer.connectPaths (   self)

Definition at line 159 of file DOTExport.py.

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

Referenced by DOTExport.DotProducer.__call__().

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

Definition at line 166 of file DOTExport.py.

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

Referenced by DOTExport.DotProducer.__call__().

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

Definition at line 30 of file DOTExport.py.

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

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

Definition at line 103 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().

103  def makePath(self,path,endpath=False):
104  children = self.recurseChildren(path)
105  pathlabel = self.data.label(path)
106  if self.options['file']:
107  pathlabel += '\\n%s:%s'%(self.data.pypackage(path),self.data.lineNumber(path))
108  if endpath:
109  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'])
110  else:
111  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'])
112  if self.options['seqconnect']:
113  if endpath:
114  self.endstarts.append('endstart_%s'%self.data.label(path))
115  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}
116  else:
117  self.pathstarts.append('start_%s'%self.data.label(path))
118  self.pathends.append('end_%s'%self.data.label(path))
119  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}
120  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}
121  labels=[]
122  for c in children:
123  #this is also done in seqRecurseChildren, so will be duplicated
124  #unncessary, but relatively cheap and saves more cff/cfg conditionals
125  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}
126  labels.append(self.data.label(c))
127  if self.options['seqconnect']:
128  pathresult += '->'.join(labels)+'\n'
129  else:
130  if not self.options['seq']:
131  pathresult += '\n'.join(labels)+'\n'
132  if self.options['seq']:
133  if self.data.children(path):
134  for path_child in self.data.children(path):
135  pathresult += self.seqRecurseChildren(path_child)
136  pathresult += '}\n'
137  if len(labels)>0 and self.options['seqconnect']:
138  if endpath:
139  pathresult += 'endstart_%s->%s\n' % (self.data.label(path),labels[0])
140  else:
141  pathresult += 'start_%s->%s\n%s->end_%s\n' % (self.data.label(path),labels[0],labels[-1],self.data.label(path))
142 
143  return pathresult
144 
def makePath(self, path, endpath=False)
Definition: DOTExport.py:103
def recurseChildren(self, obj)
Definition: DOTExport.py:76
def seqRecurseChildren(self, obj)
Definition: DOTExport.py:61
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def nodeLabel(self, obj)
Definition: DOTExport.py:87
def DOTExport.DotProducer.nodeLabel (   self,
  obj 
)

Definition at line 87 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().

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

Definition at line 96 of file DOTExport.py.

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

Referenced by DOTExport.DotProducer.produceNodes().

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

Definition at line 234 of file DOTExport.py.

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

Referenced by DOTExport.DotProducer.__call__().

234  def produceLegend(self):
235  """
236  Return a legend subgraph using current shape and colour preferences.
237  """
238  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'])
239 
def produceLegend(self)
Definition: DOTExport.py:234
def DOTExport.DotProducer.produceNodes (   self)

Definition at line 224 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__().

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

Definition at line 145 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__().

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

Definition at line 194 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, EcalLaserAnalyzer2.shapes, and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

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

Definition at line 181 of file DOTExport.py.

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

Referenced by DOTExport.DotProducer.__call__().

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

Definition at line 76 of file DOTExport.py.

References DOTExport.DotProducer.recurseChildren().

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

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

Definition at line 61 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().

61  def seqRecurseChildren(self,obj):
62  children = self.data.children(obj)
63  if children:
64  seqlabel = self.data.label(obj)
65  if self.options['file']:
66  seqlabel += '\\n%s:%s' % (self.data.pypackage(obj),self.data.lineNumber(obj))
67  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'])
68  for c in children:
69  result += self.seqRecurseChildren(c)
70  result+='}\n'
71  return result
72  else:
73  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}
74  return '%s\n'%self.data.label(obj)
75 
def seqRecurseChildren(self, obj)
Definition: DOTExport.py:61
def nodeLabel(self, obj)
Definition: DOTExport.py:87

Member Data Documentation

DOTExport.DotProducer.data
DOTExport.DotProducer.endstarts

Definition at line 27 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectPaths().

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

Definition at line 26 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectPaths().

DOTExport.DotProducer.pathstarts

Definition at line 25 of file DOTExport.py.

Referenced by DOTExport.DotProducer.produceSource().

DOTExport.DotProducer.shapes
DOTExport.DotProducer.toplevel