def writeFJR(self): """ """ fwjr = FwkJobReport() fwjr.addError(self.wrapperExitCode, "WrapperExitCode") if (self.exeExitCode != ""): fwjr.addError(self.exeExitCode, "ExeExitCode") fwjr.write(self.reportFileName) return
def newReport(self, name, attrs): """ _newReport_ Handler method for a new FrameworkJobReport """ self.currentReport = FwkJobReport() name = attrs.get("Name", None) status = attrs.get("Status", None) jobSpec = attrs.get("JobSpecID", None) workSpec = attrs.get("WorkflowSpecID", None) jobType = attrs.get("JobType", None) if name != None: self.currentReport.name = str(name) if status != None: self.currentReport.status = str(status) if jobSpec != None: self.currentReport.jobSpecId = str(jobSpec) if jobType != None: self.currentReport.jobType = str(jobType) if workSpec != None: self.currentReport.workflowSpecId = str(workSpec) return
def processFrameworkJobReport(): """ Runtime tool for processing the Framework Job Report produced by CMsGen executables """ theJobReport = FwkJobReport() # # If everything worked well set the success status # else record a failure and error if jobFailed == 0: theJobReport.status = "Success" theJobReport.exitCode = 0 elif jobFailed == 1: theJobReport.status = "Failed" theJobReport.exitCode = 11111 errDetail = theJobReport.addError(11111, "CmsGenFailure") errDetail['Description'] = "Error retrieving grid file" elif jobFailed == 2: theJobReport.status = "Failed" theJobReport.exitCode = 11112 errDetail = theJobReport.addError(11112, "CmsGenFailure") errDetail['Description'] = "Error producing step 1 events" elif jobFailed == 3: theJobReport.status = "Failed" theJobReport.exitCode = 11113 errDetail = theJobReport.addError(11113, "CmsGenFailure") errDetail['Description'] = "Error producing step 2 events" elif jobFailed == 4: theJobReport.status = "Failed" theJobReport.exitCode = 11114 errDetail = theJobReport.addError(11114, "CmsGenFailure") errDetail[ 'Description'] = "Error computing the number of produced events" elif jobFailed == 5: theJobReport.status = "Failed" theJobReport.exitCode = 11115 errDetail = theJobReport.addError(11115, "CmsGenFailure") errDetail['Description'] = "Error making a link" elif jobFailed == 6: theJobReport.status = "Failed" theJobReport.exitCode = 11116 errDetail = theJobReport.addError(11116, "CmsGenFailure") errDetail['Description'] = "Error preparing the executation" else: theJobReport.status = "Failed" theJobReport.exitCode = 11117 errDetail = theJobReport.addError(11117, "CmsGenFailure") errDetail['Description'] = "General cmsGen Failure" if jobFailed == 0: file = open("nCmsGenEvents.txt", 'r') nEventsLine = file.readline() nEvents = nEventsLine.split('\n') file.close() totalEvents = nEvents[0] outputFileUnw = "" if generator == "alpgen": outputFileUnw = "%s.unw" % outputFile elif generator == "comphep": outputFileUnw = "%s" % outputFile elif generator == "madgraph": outputFileUnw = "%s" % outputFile if not os.path.exists(outputFileUnw): msg = "Output file Not Found: %s" % outputFileUnw raise RuntimeError, msg totalSize = os.stat(outputFileUnw)[6] else: totalEvents = 0 totalSize = 0 newFile = theJobReport.newFile() newFile["LFN"] = "None" if generator == "alpgen": #newFile["PFN"] = "%s/%s" % (os.getcwd(),outputFile) newFile["PFN"] = "%s" % outputFile elif generator == "comphep": newFile["PFN"] = "%s" % outputFile elif generator == "madgraph": newFile["PFN"] = "%s" % outputFile newFile["Size"] = totalSize newFile["TotalEvents"] = totalEvents newFile["ModuleLabel"] = "cmsGen" theJobReport.write(jobReport)
if not os.path.exists(cfgFile): msg = "Cfg File Not Found: %s" % cfgFile raise RuntimeError, msg if generator == "alpgen": jobFailed = alpGen() processFrameworkJobReport() elif generator == "comphep": jobFailed = compHep() processFrameworkJobReport() elif generator == "madgraph": jobFailed = madgraph() processFrameworkJobReport() elif generator == "sherpa": jobFailed = sherpa() # Create a dummy FwkJobReport theJobReport = FwkJobReport() if jobFailed == 0: theJobReport.status = "Success" theJobReport.exitCode = 0 theJobReport.write(jobReport) else: theJobReport.status = "Failed" theJobReport.exitCode = jobFailed errDetail = theJobReport.addError(jobFailed, "CmsGenFailure") errDetail['Description'] = "Failed to set up Sherpa Libs" else: msg = "Generator %s Not Found" % generator raise RuntimeError, msg
def __init__(self): ContentHandler.__init__(self) # // # // State containers used during parsing #// self.currentReport = FwkJobReport() self.currentFile = None self.currentDict = None self.currentInputDict = None self.currentCksum = None self.inTiming = False self.inGenInfo = False self._CharCache = "" # // # // container for results #// self.results = [] # // # // Response methods to start of elements based on element name #// self._StartResponses = { "FrameworkJobReport": self.newReport, "File": self.newFile, "InputFile": self.newInputFile, "Dataset": self.newDataset, "ExitCode": self.exitCode, "State": self.stateHandler, "Branch": self.noResponse, "Branches": self.noResponse, "Input": self.startInput, "Inputs": self.noResponse, "Runs": self.noResponse, "Run": self.noResponse, "SkippedEvent": self.skippedEvent, "SkippedFile": self.skippedFile, "Checksum": self.checksum, "SiteDetail": self.siteDetail, "FrameworkError": self.frameworkError, "TimingService": self.timingService, "StorageStatistics": self.noResponse, "GeneratorInfo": self.generatorInfo, "Data": self.dataHandler, "ReadBranches": self.readBranches, } # // # // Response methods to end of elements based on element name #// self._EndResponses = { "FrameworkJobReport": self.endReport, "File": self.endFile, "Dataset": self.endDataset, "ExitCode": self.noResponse, "State": self.noResponse, "Branch": self.endBranch, "Branches": self.noResponse, "InputFile": self.endInputFile, "Input": self.endInput, "Inputs": self.noResponse, "Runs": self.noResponse, "Run": self.endRun, "SkippedEvent": self.noResponse, "SkippedFile": self.noResponse, "Checksum": self.endChecksum, "SiteDetail": self.noResponse, "FrameworkError": self.endFrameworkError, "TimingService": self.endTimingService, "StorageStatistics": self.storageStatistics, "GeneratorInfo": self.endGeneratorInfo, "Data": self.noResponse, "ReadBranches": self.endReadBranches, }
Instantiate a new ContentHandler and run it over the file producing a list of FwkJobReport instances """ #handler = FwkJobRepHandler() #parser = make_parser() #parser.setContentHandler(handler) #try: # parser.parse(filename) #except SAXParseException, ex: # msg = "Error parsing JobReport File: %s\n" % filename # msg += str(ex) # print msg # return [] #print handler.results[0] #return handler.results try: improvDoc = loadIMProvFile(filename) except Exception, ex: return [] result = [] reportQ = IMProvQuery("FrameworkJobReport") reportInstances = reportQ(improvDoc) for reportInstance in reportInstances: newReport = FwkJobReport() newReport.load(reportInstance) result.append(newReport) return result