Functions
FirstAnaPageMakers Namespace Reference

Functions

def makeDatasetPage (options, name, definitions, config=False, text="", sam_timer=False)
 Make the testing front page. More...
 
def makeConfigPage (options, definition, fhicl)
 FHiCL page. More...
 
def makeExplorerPage (options, name, definitions)
 Explorer page. More...
 

Function Documentation

def FirstAnaPageMakers.makeConfigPage (   options,
  definition,
  fhicl 
)

FHiCL page.

Definition at line 186 of file FirstAnaPageMakers.py.

Referenced by makeDatasetPage().

186 def makeConfigPage(options,definition,fhicl):
187  ########################### Imports
188  import PageMaker as PM
189  ########################### Base HTML
190  fcl_base_html = \
191  """
192  <div class="page-header">
193  <h1><!--NAME_HOOK--> config
194  </h1>
195  </div>
196  """
197  ########################### Insert content
198  page = PM.PageMaker(fcl_base_html, options, name="%s_config.html"%definition)
199  page.addContent("<!--NAVBAR_HOOK-->",
200  '<li><a href="http://nusoft.fnal.gov/nova/production/first_analysis/%s_config.html">%s config</a></li>'%(definition,definition))
201  page.addContent("<!--NAME_HOOK-->",
202  "%s"%definition)
203  page.addContent("<!--BODY_HOOK-->",
204  '<pre class="prettyprint linenums">\n%s</pre>'%fhicl)
205 
206  ########################### Write
207  page.write()
def makeConfigPage(options, definition, fhicl)
FHiCL page.
def FirstAnaPageMakers.makeDatasetPage (   options,
  name,
  definitions,
  config = False,
  text = "",
  sam_timer = False 
)

Make the testing front page.

Definition at line 3 of file FirstAnaPageMakers.py.

References samweb_client.definitions.descDefinitionDict(), caf_analysis.keys, samweb_client.files.listFilesSummary(), makeConfigPage(), and PandAna.Demos.demo1.range.

3 def makeDatasetPage(options, name, definitions, config=False, text="", sam_timer=False):
4  if options.verbose: print "PMS : Making dataset page for: %s"%name
5  ########################### Imports
6  import PageMaker as PM
7  import samweb_client
8  sam = samweb_client.SAMWebClient("nova")
9  from collections import OrderedDict
10  import ViewHTML as html_view
11  import ViewGoogleCharts as google_view
12  import ProductionTestTools as tools
13  from CachedSamDefinitionSummary import cached
14  from time import time
15  import datetime
16  ########################### Base HTML
17  pretty_name = name.replace("_"," ")[:-5]
18  base_html = \
19  """
20  <div class="page-header">
21  <h1>%s</h1>
22  </div>
23  <p>
24  <!--TEXT_HOOK-->
25  </p>
26  <p>
27  The datasets for this sample are:
28  </p>
29  <div class="row">
30  <div class="container">
31  <!--LIST_HOOK-->
32  </div>
33  </div>
34  """%pretty_name
35  ########################### Insert content
36  page = PM.PageMaker(base_html, options, name=name)
37  page.addContent("<!--NAVBAR_HOOK-->",
38  '<li><a href="http://nusoft.fnal.gov/nova/production/first_analysis/%s">%s</a></li>'%(name,pretty_name))
39  page.addContent("<!--TEXT_HOOK-->",text)
40  # list definitions
41  list_html = ""
42  def_descriptions = OrderedDict()
43  def_info = OrderedDict()
44  names = []
45  configs = []
46  legend = ["tier"]
47  n_files = []
48  n_events = []
49  size =[]
50  sum_time = 0
51  n_queries = 0
52  for i_chain,chain in enumerate(definitions.keys()):
53  if options.verbose: print "PMS : Chain: %s"%chain
54  list_html += """
55  <div class="col-md-6">
56  <div class="panel panel-default">
57  <div class="panel-heading">
58  <h3 class="panel-title">%s</h3>
59  </div>
60  <div class="panel-body">
61  """%chain
62  this_n_files = [chain]
63  this_n_events = [chain]
64  this_size = [chain]
65 
66  # pad non-zeroth chains to the size of the preceeding one
67  if i_chain != 0:
68  for j in range(len(n_files[i_chain-1])-1):
69  this_n_files.append(0)
70  this_n_events.append(0)
71  this_size.append(0)
72 
73  for tier in definitions[chain].keys():
74  if options.verbose: print "PMS : Tier: %s"%tier
75  # for the first chain we pad with zeros here as it won't be done in the previous step
76  # if i_chain == 0:
77  # this_n_files.append(0)
78  # this_n_events.append(0)
79  # this_size.append(0)
80 
81  # pick up new tiers
82  if tier not in legend:
83  legend.append(tier)
84  # if this tier is new and we aren't in the first loop then we need to go back and add this to the preceeding tiers
85  for i in range(len(n_files)):
86  n_files[i].append(0)
87  n_events[i].append(0)
88  size[i].append(0)
89  this_n_files.append(0)
90  this_n_events.append(0)
91  this_size.append(0)
92  # print legend,n_files,this_n_files
93 
94  index = legend.index(tier)
95 
96  name = chain.replace(" ","_").replace("-","_")+"_"+tier.replace(" ","_").replace("-","_")
97  list_html +='<strong>%s</strong>: <a href="#" data-toggle="modal" data-target="#%s">%s</a><br>'%(tier,tools.makeAlphanumeric(name),definitions[chain][tier].name)
98 
99  def_descriptions[name] = samweb_client.definitions.descDefinitionDict(sam, definitions[chain][tier].name)
100  definitions[chain][tier].description = def_descriptions[name]
101  if (options.no_cache or (definitions[chain][tier].name not in cached.keys())):
102  s_time = time()
103  try:
104  def_info[definitions[chain][tier].name] = samweb_client.files.listFilesSummary(sam, defname=definitions[chain][tier].name)
105  d_t = time() - s_time
106  def_info[definitions[chain][tier].name]["status"] = html_view.makeSAMQueryStatusBadge("good",time=d_t)
107  except:
108  print "PMS : Query of dataset: %s timed out, filling zeros"%definitions[chain][tier].name
109  d_t = time() - s_time
110  def_info[definitions[chain][tier].name] = cached["empty"]
111  def_info[definitions[chain][tier].name]["status"] = html_view.makeSAMQueryStatusBadge("timed out",time=d_t)
112  if sam_timer:
113  sam_timer.record_time(definitions[chain][tier].name, datetime.datetime.now(), d_t)
114  sum_time += d_t
115  n_queries+=1
116  # in order to aid the caching process we'll print these out for now
117  print '\ncached["%s"] = \ \n %s'%(definitions[chain][tier].name,repr(def_info[definitions[chain][tier].name]))
118  else:
119  print "PMS : - using cached result"
120  def_info[definitions[chain][tier].name] = cached[definitions[chain][tier].name]
121  def_info[definitions[chain][tier].name]["status"] = html_view.makeSAMQueryStatusBadge("cached")
122  names.append((chain,tier))
123  if config:
124  configs.append(tools.getConfigFromDef(definitions[chain][tier].name))
125  makeConfigPage(options, definitions[chain][tier].name, configs[-1])
126 
127  if def_info[definitions[chain][tier].name]["file_count"] > 0:
128  this_n_files[index] = def_info[definitions[chain][tier].name]["file_count"]
129  this_n_events[index] = def_info[definitions[chain][tier].name]["total_event_count"]
130  this_size[index] = def_info[definitions[chain][tier].name]["total_file_size"] / (1024.*1024.*1024.)
131  else:
132  this_n_files[index] = 0
133  this_n_events[index] = 0
134  this_size[index] = 0
135 
136  definitions[chain][tier].addInfo(def_info[definitions[chain][tier].name])
137 
138 
139  n_files.append(this_n_files)
140  n_events.append(this_n_events)
141  size.append(this_size)
142 
143  list_html += """
144  </div>
145  </div>
146  </div>
147  """
148 
149  page.addContent("<!--LIST_HOOK-->",list_html)
150  modal_html = html_view.samDefinitionDescriptionsModal(def_descriptions)
151  page.addContent("<!--BODY_HOOK-->","%s\n<!--BODY_HOOK-->"%modal_html)
152 
153  table_html,totals = html_view.samFileInfoSummaryTable(def_info,names=names,configs=config,status=True)
154  page.addContent("<!--BODY_HOOK-->","%s\n<hr><!--BODY_HOOK-->"%table_html)
155 
156  head_html = ""
157  body_html = ""
158 
159  head_n_files, body_n_files = google_view.stackedColumnChart(name="n_files",legend=legend,results=n_files,
160  title="Number of files per definition", x_title="Chain",y_title="Number of files",
161  checkbox=True)
162  head_html += head_n_files
163  body_html += body_n_files
164 
165  head_n_files, body_n_files = google_view.stackedColumnChart(name="n_events",legend=legend,results=n_events,
166  title="Number of events per definition", x_title="Chain",y_title="Number of events",
167  checkbox=True,)
168  head_html += head_n_files
169  body_html += body_n_files
170 
171  head_n_files, body_n_files = google_view.stackedColumnChart(name="size",legend=legend,results=size,
172  title="Size of definition", x_title="Chain",y_title="Size [GB]",
173  checkbox=True)
174  head_html += head_n_files
175  body_html += body_n_files
176 
177  page.addContent("<!--HEADER_HOOK-->","%s\n<!--HEADER_HOOK-->"%head_html)
178  page.addContent("<!--BODY_HOOK-->","%s\n<!--BODY_HOOK-->"%body_html)
179  ########################### Write
180  page.write()
181  totals.append(sum_time)
182  totals.append(n_queries)
183  return totals
keys
Reco plots.
Definition: caf_analysis.py:46
def listFilesSummary(samweb, dimensions=None, defname=None)
Definition: files.py:80
def descDefinitionDict(samweb, defname)
Definition: definitions.py:28
def makeDatasetPage(options, name, definitions, config=False, text="", sam_timer=False)
Make the testing front page.
def makeConfigPage(options, definition, fhicl)
FHiCL page.
def FirstAnaPageMakers.makeExplorerPage (   options,
  name,
  definitions 
)

Explorer page.

Definition at line 210 of file FirstAnaPageMakers.py.

210 def makeExplorerPage(options,name,definitions):
211  ########################### Imports
212  import PageMaker as PM
213  import ViewHTML as html_view
214  ########################### Base HTML
215  base_html = \
216  """
217  <div class="page-header">
218  <h1>Dataset explorer
219  </h1>
220  </div>
221 
222  <div id="form">
223  <div class="row">
224  <div class="container">
225  <!-- Selections panel -->
226  <div class="col-lg-3">
227  <div class="panel panel-default">
228  <div class="panel-heading">
229  <h3 class="panel-title">Selections</h3>
230  </div>
231  <div class="panel-body">
232 
233  <div class="form-group">
234  <label for="tiers_form" class="col-lg-6">Tier</label>
235  <div class="col-lg-6" id="tiers_form"></div>
236  </div>
237  <br>
238 
239  <div class="form-group">
240  <label for="releases_form" class="col-lg-6">Release</label>
241  <div class="col-lg-6" id="releases_form"></div>
242  </div>
243  <br>
244 
245  <div class="form-group">
246  <label for="detectors_form" class="col-lg-6">Detector</label>
247  <div class="col-lg-6" id="detectors_form"></div>
248  </div>
249  <br>
250 
251  <div class="form-group">
252  <label for="is_mcs_form" class="col-lg-6">Data/MC</label>
253  <div class="col-lg-6" id="is_mcs_form"></div>
254  </div>
255  <br>
256 
257  <div class="form-group">
258  <label for="triggers_form" class="col-lg-6">Trigger</label>
259  <div class="col-lg-6" id="triggers_form"></div>
260  </div>
261  </div>
262  </div>
263  </div>
264 
265  <!-- Information panel -->
266  <div class="col-lg-9">
267  <div class="panel panel-info">
268  <div class="panel-heading">
269  <h3 class="panel-title">Information</h3>
270  </div>
271  <div class="panel-body">
272  <div id="definition_information">
273  <div>Select a definition</div>
274  </div>
275  </div>
276  </div>
277  </div>
278  </div>
279  </div>
280 
281  <div class="row">
282  <div class="container">
283  <div class="col-lg-12">
284  <div class="panel panel-default">
285  <div class="panel-heading">
286  <h3 class="panel-title" id="summary">Definitions </h3>
287  </div>
288  <div class="panel-body">
289  <div id="definition_list"></div>
290  </div>
291  </div>
292  </div>
293  </div>
294  </div>
295  </div>
296  """
297  ########################### Insert content
298  page = PM.PageMaker(base_html, options, name=name)
299 
300  page.addContent("/*STYLE_HOOK*/",".my_links:hover{font-weight:bold;cursor: pointer}; .my_links.active{font-weight:bold}")
301 
302  datasets = html_view.definitionListToExplorerData(definitions)
303  page.addContent("<!--JS_HOOK-->","%s\n<!--JS_HOOK-->"%datasets)
304 
305  page.addContent("<!--JS_HOOK-->",\
306  """
307  <script src="http://nusoft.fnal.gov/nova/production/static/d3.v3.min.js"></script>
308  <script src="http://nusoft.fnal.gov/nova/production/static/d3_explorer.js"></script>
309  <!--JS_HOOK-->
310  """)
311  ########################### Write
312  page.write()
def makeExplorerPage(options, name, definitions)
Explorer page.