CMS 3D CMS Logo

Functions

cmssw_exportdb_xml Namespace Reference

Functions

def _getXMLNode
def createNode
def export_xml
def export_xml_ig
def export_xml_memcheck
def exportECRules
def exportRunInfo
def initXML
def write_xml
def xml_delete_children
def xml_export_EdmRecord
def xml_export_EventRssRecord
def xml_export_EventTimeRecord
def xml_export_EventVsizeRecord
def xml_export_IgSummary
def xml_export_Memcheck
def xml_export_ModuleTimeRecord
def xml_export_SequenceRecord
def xml_export_Sequences
def xml_init_Sequences

Function Documentation

def cmssw_exportdb_xml::_getXMLNode (   xml_doc) [private]
opens existing or creates a new XML object 

Definition at line 104 of file cmssw_exportdb_xml.py.

00105                         :
00106         """ opens existing or creates a new XML object """
00107         try:
00108                 node_xml = xml_doc.getElementsByTagName("xml")[0]
00109         except IndexError:
00110                 #doc = minidom.Document()
00111                 node_xml =  createNode(xml_doc, "xml") 
00112         return node_xml
00113         
00114 
00115 

def cmssw_exportdb_xml::createNode (   xml_doc,
  node_name,
  values = {},
  parent = None 
)

Definition at line 4 of file cmssw_exportdb_xml.py.

00004                                             {}, parent = None):
00005         if (parent == None):
00006                 parent = xml_doc
00007         #create node
00008         node = xml_doc.createElement(node_name)
00009         # assign the values
00010         for (key, value) in values.items():
00011                 node.setAttribute(key, str(value))
00012         parent.appendChild(node)
00013 
00014         return node
00015 
00016 
def cmssw_exportdb_xml::export_xml (   release,
  jobID,
  timelog_result,
  xml_doc,
  metadata = None,
  edmSize_result = None,
  parentNode = None 
)
jobID is a dictionary now ! 

Definition at line 125 of file cmssw_exportdb_xml.py.

00126                                                                                                                  :
00127         """ jobID is a dictionary now ! """
00128 
00129         if not parentNode:
00130                 #get the root XML node
00131                 parentNode = _getXMLNode(xml_doc)
00132 
00133         #create jobStats node
00134         values=jobID
00135         values.update({"release": release})
00136         if (metadata):
00137                 values.update(metadata)
00138 
00139         # we create a new XML element having all the statistics data for our candle, step, release
00140         jobStatsNode = createNode(node_name= "jobStats", xml_doc=xml_doc, parent=parentNode, 
00141                 values=values)
00142 
00143         #TODO: load current module data or delete
00144 
00145         (mod_timelog_result, evt_timelog_result, rss_result, vsize_result) = timelog_result
00146 
00147         # modules data
00148         for (mod_name, mod_time_result) in mod_timelog_result.items():
00149                 xml_export_ModuleTimeRecord(mod_time_result, jobStatsNode, xml_doc)
00150 
00151         """ #TODO: actualy we're not supposed to have any of the old statistics
00152         # clean it up if there are old stats of EventTime,RSS,VSIZE
00153         xml_delete_children(jobStatsNode, "EventTime") 
00154         xml_delete_children(jobStatsNode, "EventRSS") 
00155         xml_delete_children(jobStatsNode, "EventVSIZE") 
00156         xml_delete_children(jobStatsNode, "EdmSize") """
00157 
00158         #events data - so far only total time per event
00159         if (evt_timelog_result):
00160                 for evt_time_item in evt_timelog_result:
00161                         xml_export_EventTimeRecord(evt_time_item, jobStatsNode, xml_doc)
00162 
00163         # rss
00164         if (rss_result):
00165                 for evt_time_item in rss_result:
00166                         xml_export_EventRssRecord(evt_time_item, jobStatsNode, xml_doc)
00167 
00168         # vsize
00169         if (vsize_result):
00170                 for evt_time_item in vsize_result:
00171                         xml_export_EventVsizeRecord(evt_time_item, jobStatsNode, xml_doc)
00172         # edmSize
00173         if (edmSize_result):
00174                 for edmItem in edmSize_result:
00175                         xml_export_EdmRecord(edmItem, jobStatsNode, xml_doc)            

def cmssw_exportdb_xml::export_xml_ig (   release,
  jobID,
  igprof_result,
  xml_doc,
  metadata = None,
  parentNode = None 
)
jobID is a dictionary now ! 

Definition at line 176 of file cmssw_exportdb_xml.py.

00177                                                                                              :
00178         """ jobID is a dictionary now ! """
00179 
00180         if not parentNode:
00181                 #get the root XML node
00182                 parentNode = _getXMLNode(xml_doc)
00183 
00184         #create jobStats node
00185         values=jobID
00186         values.update({"release": release})
00187         if (metadata):
00188                 values.update(metadata)
00189 
00190         # we create a new XML element having all the statistics data for our candle, step, release
00191         jobStatsNode = createNode(node_name= "jobStats", xml_doc=xml_doc, parent=parentNode, 
00192                 values=values)
00193 
00194         for igsumm in igprof_result:
00195                 xml_export_IgSummary(igsumm, jobStatsNode, xml_doc)             

def cmssw_exportdb_xml::export_xml_memcheck (   release,
  jobID,
  memcheck_errors,
  xml_doc,
  metadata = None,
  parentNode = None 
)

Definition at line 196 of file cmssw_exportdb_xml.py.

00197                                                                                                      :
00198         if not parentNode:
00199                 parentNode = _getXMLNode(xml_doc)
00200 
00201         values=jobID
00202         values.update({"release": release})
00203         if (metadata):
00204                 values.update(metadata)
00205 
00206         # we create a new XML element having all the statistics data for our candle, step, release
00207         jobStatsNode = createNode(node_name= "jobStats", xml_doc=xml_doc, parent=parentNode, 
00208                 values=values)
00209 
00210         xml_export_Memcheck(memcheck_errors, jobStatsNode, xml_doc)             

def cmssw_exportdb_xml::exportECRules (   xml_doc,
  rules 
)

Definition at line 282 of file cmssw_exportdb_xml.py.

00283                                  :
00284         node_xml = _getXMLNode(xml_doc)
00285         runInfoNode = createNode(node_name= "EventContentRules", xml_doc=xml_doc, parent=node_xml, 
00286                         values=rules)

def cmssw_exportdb_xml::exportRunInfo (   xml_doc,
  run_info,
  release = None,
  print_out = False 
)

Definition at line 211 of file cmssw_exportdb_xml.py.

00212                                                                        :
00213         node_xml = _getXMLNode(xml_doc)
00214         #get the simple string values
00215         str_values = run_info["General"]
00216         
00217         #if we have the forced release name (e.g. icludes some special tags for testing but not official release) 
00218         # so TODO: probably the test_release_based_on string would be the same so we still save the (original) test release based string
00219 
00220         if release:
00221                 str_values["release"] = release
00222         else:
00223                 str_values["release"] = str_values["test_release_based_on"]
00224 
00225         runInfoNode = createNode(node_name= "RunInfo", xml_doc=xml_doc, parent=node_xml, 
00226                         values=str_values)
00227         #create nodes for TestResults:
00228         for (testName, result) in run_info["TestResults"].items():
00229                 #either we have one node or multiple ones (if list)
00230                 if type(result) == types.ListType:
00231                         for result_item in result:
00232                                 result_item.update({"testname": testName})
00233 
00234                                 #We have JOBS so FAR only for TimeSize which we represent as a list
00235                                 jobs = []
00236                                 #we don't want jobs to be dumped as string
00237                                 if result_item.has_key("jobs"):
00238                                         jobs = result_item["jobs"]
00239                                         del result_item["jobs"]
00240 
00241                                 testNode = createNode(node_name="testResult", xml_doc=xml_doc, parent=runInfoNode, values=result_item) 
00242 
00243 
00244                                 for job in jobs:
00245                                          #print job
00246                                          if testName == "TimeSize":
00247                                                  export_xml(xml_doc = xml_doc, parentNode = testNode, **job)
00248                                          elif testName == "IgProf_Mem":
00249                                                  export_xml_ig(xml_doc = xml_doc, parentNode = testNode, **job)
00250                                          elif testName == "IgProf_Perf":
00251                                                  export_xml_ig(xml_doc = xml_doc, parentNode = testNode, **job)
00252                                          elif testName == "Memcheck":
00253                                                  export_xml_memcheck(xml_doc = xml_doc, parentNode = testNode, **job)
00254                 else:
00255                         result.update({"testname": testName})
00256                         createNode(node_name="testResult", xml_doc=xml_doc, parent=runInfoNode, values=result)
00257 
00258         #DO we have some unrecognized JOBS?
00259         if len(run_info['unrecognized_jobs']):
00260                 unrecognizedJobsNode = createNode(node_name="Unrecognized_JOBS", xml_doc=xml_doc, parent=runInfoNode, values={}) 
00261 
00262                 for job in run_info['unrecognized_jobs']:
00263                          #print job
00264                          testName = job["metadata"]["testname"]
00265                          if testName == "TimeSize":
00266                                  export_xml(xml_doc = xml_doc, parentNode = unrecognizedJobsNode, **job)
00267                          elif testName == "IgProf_Mem":
00268                                  export_xml_ig(xml_doc = xml_doc, parentNode = unrecognizedJobsNode, **job)             
00269                          elif testName == "IgProf_Perf":
00270                                  export_xml_ig(xml_doc = xml_doc, parentNode = unrecognizedJobsNode, **job)
00271                          elif testName == "Memcheck":
00272                                  export_xml_memcheck(xml_doc = xml_doc, parentNode = unrecognizedJobsNode, **job)
00273 
00274                 
00275         #cmsSciMark
00276         cmsSciMarkNode = createNode(node_name="cmsSciMarks", xml_doc=xml_doc, parent=runInfoNode, values = {})
00277         for csiMark in run_info["cmsSciMark"]:
00278                 #print csiMark
00279                 createNode(node_name="cmsSciMark", xml_doc=xml_doc, parent=cmsSciMarkNode, values=csiMark)
00280         if print_out:
00281                 print xml_doc.toprettyxml(indent="\t")

def cmssw_exportdb_xml::initXML (   xmldoc)
opens existing or creates a new XML file 
        
  ---- one of the erliest functions - quite nasty looking :)

Definition at line 17 of file cmssw_exportdb_xml.py.

00018                    :
00019         """ opens existing or creates a new XML file 
00020                 
00021           ---- one of the erliest functions - quite nasty looking :)""" 
00022         
00023         try:
00024                 node_xml = xmldoc.getElementsByTagName("xml")[0]
00025         except IndexError:
00026                 #doc = minidom.Document()
00027                 node_xml =  createNode(xmldoc, "xml") 
00028 
00029         return node_xml

def cmssw_exportdb_xml::write_xml (   xml_doc,
  remotedir,
  xmlFileName 
)

Definition at line 287 of file cmssw_exportdb_xml.py.

00288                                              :
00289         xml = xml_doc.toprettyxml(indent="  ")
00290 
00291         # return xml as string (if requested)
00292         if (xmlFileName == ""):
00293                 return xml
00294         #Adding a modification to make sure the file is written in /tmp/$USER_perfsuite_xml dir (to allow any used to harvest any workdir without permission issues.
00295         tmp_dir="/tmp/%s_perfsuite_xml"%os.getenv("USER")
00296         if not os.path.exists(tmp_dir):
00297                 os.system("mkdir %s"%tmp_dir)
00298         xmlFileName=os.path.join(tmp_dir,xmlFileName)
00299         # or save that as file
00300         out = open(xmlFileName, "w")
00301         #print xml locally
00302         out.write(xml)
00303         out.close()
00304         print "Now copying %s to stage directory %s..."%(xmlFileName,remotedir)
00305         
00306         #FIXME: Here we could decide to archive it on CASTOR on a dedicated directory
00307         if ":" in remotedir: #CAVEAT: since we report the timestamp as part of the xml filename we need to be careful..
00308                 (host,dir)=remotedir.split(":")
00309                 #change to the directory to avoid tar replicating /tmp/$USER_perfsuite_xml/ directory structure remotely:
00310                 copy_cmd='cd %s; tar cf - %s|ssh %s "cd %s;tar xf -"'%(tmp_dir,os.path.basename(xmlFileName),host,dir)
00311         else:
00312                 if not os.path.exists(remotedir):
00313                         os.system("mkdir %s"%remotedir)
00314                 #tarpipe_cmd='cd %s;tar cf - %s|(cd %s;tar xf -)'%(tmp_dir,os.path.basename(xmlFileName),remotedir)
00315                 copy_cmd='cp -pR %s/%s %s'%(tmp_dir,os.path.basename(xmlFileName),remotedir) 
00316         try:
00317                 print copy_cmd
00318                 os.system(copy_cmd)
00319                 print "Successfully copied XML report %s to stage directory %s"%(xmlFileName,remotedir)
00320         except Exception,e :
00321                 print "Issues with copying XML report %s to stage directory %s!\n%s"%(xmlFileName,remotedir,str(e))
00322         #os.system("cd -") #just in case...
00323                 
00324         
def cmssw_exportdb_xml::xml_delete_children (   nodes,
  child_name 
)

Definition at line 30 of file cmssw_exportdb_xml.py.

00030                                           : 
00031         for x in nodes.getElementsByTagName(child_name):
00032                 nodes.removeChild(x) 
00033 
00034 
def cmssw_exportdb_xml::xml_export_EdmRecord (   data,
  curr_stat_node,
  xml_doc 
)

Definition at line 64 of file cmssw_exportdb_xml.py.

00065                                                        :
00066         event_node =createNode(xml_doc, "EdmSize", values = data, parent = curr_stat_node)

def cmssw_exportdb_xml::xml_export_EventRssRecord (   evt_time_data,
  curr_stat_node,
  xml_doc 
)

Definition at line 54 of file cmssw_exportdb_xml.py.

00055                                                                      :
00056         #print "a"+str(evt_time_data)
00057         (evt_num, evt_time) = evt_time_data
00058         event_node =createNode(xml_doc, "EventRSS", values = {"evt_num": evt_num, "time": evt_time}, parent = curr_stat_node)

def cmssw_exportdb_xml::xml_export_EventTimeRecord (   evt_time_data,
  curr_stat_node,
  xml_doc 
)

Definition at line 48 of file cmssw_exportdb_xml.py.

00049                                                                       :
00050         #print "a"+str(evt_time_data)
00051         (evt_num, evt_time) = evt_time_data
00052 
00053         event_node =createNode(xml_doc, "EventTime", values = {"evt_num": evt_num, "time": evt_time}, parent = curr_stat_node)

def cmssw_exportdb_xml::xml_export_EventVsizeRecord (   evt_time_data,
  curr_stat_node,
  xml_doc 
)

Definition at line 59 of file cmssw_exportdb_xml.py.

00060                                                                        :
00061         #print "a"+str(evt_time_data)
00062         (evt_num, evt_time) = evt_time_data
00063         event_node =createNode(xml_doc, "EventVSIZE", values = {"evt_num": evt_num, "time": evt_time}, parent = curr_stat_node)

def cmssw_exportdb_xml::xml_export_IgSummary (   data,
  curr_stat_node,
  xml_doc 
)

Definition at line 67 of file cmssw_exportdb_xml.py.

00068                                                        :
00069         event_node =createNode(xml_doc, "IgSummary", values = data, parent = curr_stat_node)

def cmssw_exportdb_xml::xml_export_Memcheck (   data,
  curr_stat_node,
  xml_doc 
)

Definition at line 70 of file cmssw_exportdb_xml.py.

00071                                                       :
00072         event_node =createNode(xml_doc, "Memcheck", values = data, parent = curr_stat_node)     
00073 

def cmssw_exportdb_xml::xml_export_ModuleTimeRecord (   data_dict,
  curr_stat_node,
  xml_doc 
)

Definition at line 35 of file cmssw_exportdb_xml.py.

00036                                                                    :
00037         #print "Dict: "+str(data_dict)
00038         # create a module tag to be used to put the data into
00039         module_node =createNode(xml_doc, "Module", values = data_dict, parent = curr_stat_node)
00040 
00041         # clean it up if there are old stats of ModuleTime, now there shouldn't be any anymore!
00042         #xml_delete_children(module_node, "ModuleTime") 
00043 
00044         # we create a new XML element having the statistics data
00045         moduletime_stat =createNode(xml_doc, "ModuleTime", values = data_dict["stats"], parent = module_node)
00046 
00047         module_node.appendChild(moduletime_stat)

def cmssw_exportdb_xml::xml_export_SequenceRecord (   data,
  curr_seq_node,
  xml_doc 
)

Definition at line 74 of file cmssw_exportdb_xml.py.

00075                                                            :
00076         seq_node =createNode(xml_doc, "Sequence", values = data, parent = curr_seq_node)

def cmssw_exportdb_xml::xml_export_Sequences (   xml_doc,
  sequences,
  release 
)

Definition at line 116 of file cmssw_exportdb_xml.py.

00117                                                      :
00118          currentNode = xml_init_Sequences(xml_doc, release)
00119          xml_delete_children(currentNode, "Sequence") 
00120 
00121          if (sequences):
00122                 for seq in sequences:
00123                         xml_export_SequenceRecord(data=seq, curr_seq_node=currentNode, xml_doc=xml_doc)
00124 

def cmssw_exportdb_xml::xml_init_Sequences (   xml_doc,
  release 
)
opens existing or creates a new XML file 
        returns the (existing or created) unique element for statiscs

Definition at line 77 of file cmssw_exportdb_xml.py.

00078                                         :
00079         #TODO: this was copied from init_XML - it should not be like that - refactor
00080         """ opens existing or creates a new XML file 
00081                 returns the (existing or created) unique element for statiscs"""        
00082         try:
00083                 node_xml = xml_doc.getElementsByTagName("xml")[0]
00084         except IndexError:
00085                 #doc = minidom.Document()
00086                 node_xml =  createNode(xml_doc, "xml") 
00087         
00088         nodes =node_xml.getElementsByTagName("Sequences")
00089 
00090         currentNode = [node for node in nodes           
00091                 if (release ==node.attributes["release"].value)]
00092         #TODO: end of copied
00093 
00094         if (currentNode):
00095                 currentNode = currentNode[0]
00096                 #TODO: this part looks nasty
00097         else:
00098                 values={"release": release}
00099                 # we create a new XML element having all the statistics data for our candle, step, release
00100                 currentNode = createNode(node_name= "Sequences", xml_doc=xml_doc, parent=node_xml, 
00101                         values=values)
00102                 node_xml.appendChild(currentNode)
00103         return currentNode