CMS 3D CMS Logo

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

Public Member Functions

def __init__ (self, db_connection, session, logger)
 
def endJob (self, status, log)
 
def executeJob (self, args)
 
def startJob (self, job_name)
 

Public Attributes

 conf_dict
 
 end
 
 job_name
 
 logger
 
 session
 
 start
 
 tag_name
 

Detailed Description

Definition at line 323 of file o2olib.py.

Constructor & Destructor Documentation

def o2olib.O2ORunMgr.__init__ (   self,
  db_connection,
  session,
  logger 
)

Definition at line 325 of file o2olib.py.

325  def __init__( self, db_connection, session, logger ):
326  self.job_name = None
327  self.start = None
328  self.end = None
329  self.conf_dict = {}
330  self.conf_dict['db'] = db_connection
331  self.session = session
332  self.logger = logger
333 
def __init__(self, db_connection, session, logger)
Definition: o2olib.py:325

Member Function Documentation

def o2olib.O2ORunMgr.endJob (   self,
  status,
  log 
)

Definition at line 376 of file o2olib.py.

References poly< T >::const_iterator.end, validateAlignments.ValidationJob.end, cond::RunInfo_t.end, validateAlignments.ValidationJobMultiIOV.end, o2olib.O2ORunMgr.end, svgfig.LineAxis.end, o2olib.O2ORunMgr.job_name, validateAlignments.ValidationJob.start, cond::RunInfo_t.start, validateAlignments.ValidationJobMultiIOV.start, o2olib.O2ORunMgr.start, svgfig.LineAxis.start, and str.

Referenced by o2olib.O2ORunMgr.executeJob().

376  def endJob( self, status, log ):
377  self.end = datetime.now()
378  try:
379  run = O2ORun(job_name=self.job_name,start_time=self.start,end_time=self.end,status_code=status,log=log)
380  self.session.merge(run)
381  self.session.commit()
382  self.logger.info( 'Job %s ended.', self.job_name )
383  return 0
384  except sqlalchemy.exc.SQLAlchemyError as dberror:
385  self.logger.error( str(dberror) )
386  return 8
387 
def endJob(self, status, log)
Definition: o2olib.py:376
#define str(s)
def o2olib.O2ORunMgr.executeJob (   self,
  args 
)

Definition at line 388 of file o2olib.py.

References o2olib.O2OJobMgr.conf_dict, o2olib.O2ORunMgr.conf_dict, HcalLutGenerator.endJob(), sistrip::EnsembleCalibrationLA.endJob(), HcalCableMapper.endJob(), SiStripDetVOffHandler.endJob(), EcalStatusAnalyzer.endJob(), PhiSymmetryCalibration_step2.endJob(), PhiSymmetryCalibration_step2_SM.endJob(), CPUSpender.endJob(), EcalTPGParamReaderFromDB.endJob(), RawDataConverter.endJob(), EcalMatacqAnalyzer.endJob(), EcalPerEvtMatacqAnalyzer.endJob(), LSNumberFilter.endJob(), AlcaBeamSpotHarvester.endJob(), EcalIsolatedParticleCandidateProducer.endJob(), SiStripDetVOffTkMapPlotter.endJob(), DTTPAnalyzer.endJob(), EcalPnGraphs.endJob(), DTCalibMuonSelection.endJob(), AlignmentPrescaler.endJob(), EcalDigiDisplay.endJob(), ObjectCounter< C >.endJob(), TkAlCaSkimTreeMerger.endJob(), DTVDriftSegmentCalibration.endJob(), DTVDriftWriter.endJob(), WriteEcalMiscalibConstants.endJob(), WriteEcalMiscalibConstantsMC.endJob(), HcalCalibrator.endJob(), AlcaBeamSpotFromDB.endJob(), SiStripDetVOffPrinter.endJob(), SiStripDetVOffTrendPlotter.endJob(), DTT0Correction.endJob(), CandidateTriggerObjectProducer.endJob(), popcon::PopConAnalyzer< S >.endJob(), SiPixelFedFillerWordEventNumber.endJob(), DTTTrigCorrectionFirst.endJob(), DTMapGenerator.endJob(), AlignmentStats.endJob(), DTTTrigCorrection.endJob(), DTTTrigOffsetCalibration.endJob(), SurveyDataConverter.endJob(), LaserDQM.endJob(), SubdetFEDSelector.endJob(), DTResidualCalibration.endJob(), ShallowTree.endJob(), SurveyDBUploader.endJob(), FilterTrackerOn.endJob(), SiStripLAProfileBooker.endJob(), SiStripRegFEDSelector.endJob(), DTT0CalibrationRMS.endJob(), AlCaElectronsTest.endJob(), FilterOutLowPt.endJob(), MuonAlignmentPreFilter.endJob(), ValidationMisalignedTracker.endJob(), DTTTrigWriter.endJob(), AlignmentProducerAsAnalyzer.endJob(), DTTPDeadWriter.endJob(), EcalPedHists.endJob(), PuppiProducer.endJob(), TkVoltageMapCreator.endJob(), DTNoiseCalibration.endJob(), miscalibExample.endJob(), EcalPedOffset.endJob(), SiPixelStatusHarvester.endJob(), LaserAlignmentT0Producer.endJob(), SimAnalyzerMinbias.endJob(), EcalABAnalyzer.endJob(), EcalPerEvtLaserAnalyzer.endJob(), ECALRegFEDSelector.endJob(), DTTTrigCalibration.endJob(), AlCaDiJetsProducer.endJob(), AlCaGammaJetProducer.endJob(), DTVDriftCalibration.endJob(), EcalTestPulseAnalyzer.endJob(), SiPixelCalibDigiFilter.endJob(), ECALpedestalPCLworker.endJob(), CSCOverlapsBeamSplashCut.endJob(), cms::ProducerAnalyzer.endJob(), Tracker_OldtoNewConverter.endJob(), MuonGeometryDBConverter.endJob(), DTT0Calibration.endJob(), RecAnalyzerHF.endJob(), EcalPulseShapeGrapher.endJob(), DTNoiseComputation.endJob(), PhiSymmetryCalibration.endJob(), MuonAlignmentAnalyzer.endJob(), EcalBxOrbitNumberGrapher.endJob(), ElectronCalibration.endJob(), PrescalerFHN.endJob(), EcalRecHitsFilter.endJob(), EcalLaserAnalyzer2.endJob(), SiPixelDQMRocLevelAnalyzer.endJob(), testChannel.endJob(), EcalLaserAnalyzer.endJob(), JetDeltaRTagInfoValueMapProducer< T, I >.endJob(), HitEff.endJob(), IsolatedParticlesGeneratedJets.endJob(), TrackerGeometryCompare.endJob(), HIPTwoBodyDecayAnalyzer.endJob(), EcalURecHitHists.endJob(), HcalLuttoDB.endJob(), CorrPCCProducer.endJob(), ElectronCalibrationUniv.endJob(), LhcTrackAnalyzer.endJob(), EcalLaserAnalyzerYousi.endJob(), HcalRaddamMuon.endJob(), EcalMipGraphs.endJob(), ApeEstimatorSummary.endJob(), SiPixelErrorsDigisToCalibDigis.endJob(), cms::Analyzer_minbias.endJob(), CosmicSplitterValidation.endJob(), EcalDisplaysByEvent.endJob(), SiPixelErrorEstimation.endJob(), TrackerToMuonPropagator.endJob(), AnalyzerMinbias.endJob(), CSCOverlapsTrackPreparation.endJob(), TrackerTreeGenerator.endJob(), ApeTreeCreateDefault.endJob(), ValidIsoTrkCalib.endJob(), EcalCosmicsHists.endJob(), PrimaryVertexValidation.endJob(), AlignmentMonitorAsAnalyzer.endJob(), EopTreeWriter.endJob(), RecAnalyzerMinbias.endJob(), SiStripGainsPCLWorker.endJob(), CosmicRateAnalyzer.endJob(), LaserAlignment.endJob(), SelectedElectronFEDListProducer< TEle, TCand >.endJob(), IsoTrackCalib.endJob(), analyzer::SiPixelLorentzAngle.endJob(), TrackerOfflineValidationSummary.endJob(), OverlapValidation.endJob(), IsoTrig.endJob(), IsolatedTracksHcalScale.endJob(), IsolatedGenParticles.endJob(), LaserSorter.endJob(), IsolatedTracksCone.endJob(), ApeEstimator.endJob(), SiPixelOfflineCalibAnalysisBase.endJob(), IsolatedTracksNxN.endJob(), GlobalTrackerMuonAlignment.endJob(), AlCaHOCalibProducer.endJob(), TrackerOfflineValidation.endJob(), HOCalibAnalyzer.endJob(), ConditionDBWriter< T >.endJob(), ResidualRefitting.endJob(), o2olib.O2ORunMgr.endJob(), o2olib.O2ORunMgr.startJob(), and str.

388  def executeJob( self, args ):
389  job_name = args.name
390  command = args.executable
391  logFolder = os.getcwd()
392  if logFolderEnvVar in os.environ:
393  logFolder = os.environ[logFolderEnvVar]
394  datelabel = datetime.now().strftime("%y-%m-%d-%H-%M-%S")
395  logFileName = '%s-%s.log' %(job_name,datelabel)
396  logFile = os.path.join(logFolder,logFileName)
397  started = self.startJob( job_name )
398  if started !=0:
399  return started
400  ret = -1
401  try:
402  # replacing %([key])s placeholders...
403  command = command %(self.conf_dict)
404  #replacing {[key]} placeholders
405  command = command.format(**self.conf_dict )
406  except KeyError as exc:
407  self.logger.error( "Unresolved template key %s in the command." %str(exc) )
408  return 3
409  self.logger.info('Command: "%s"', command )
410  try:
411  self.logger.info('Executing command...' )
412  pipe = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
413  out = ''
414  for line in iter(pipe.stdout.readline, ''):
415  if args.verbose>=1:
416  sys.stdout.write(line)
417  sys.stdout.flush()
418  out += line
419  pipe.communicate()
420  self.logger.info( 'Command returned code: %s' %pipe.returncode )
421  ret = pipe.returncode
422  except Exception as e:
423  self.logger.error( str(e) )
424  return 4
425  ended = self.endJob( pipe.returncode, out )
426  if ended != 0:
427  ret = ended
428  with open(logFile,'a') as logF:
429  logF.write(out)
430  return ret
def endJob(self, status, log)
Definition: o2olib.py:376
def executeJob(self, args)
Definition: o2olib.py:388
def startJob(self, job_name)
Definition: o2olib.py:334
#define str(s)
def o2olib.O2ORunMgr.startJob (   self,
  job_name 
)

Definition at line 334 of file o2olib.py.

References createfilelist.int.

Referenced by o2olib.O2ORunMgr.executeJob().

334  def startJob( self, job_name ):
335  self.logger.info('Checking job %s', job_name)
336  exists = None
337  enabled = None
338  try:
339  res = self.session.query(O2OJob.enabled,O2OJob.tag_name).filter_by(name=job_name)
340  for r in res:
341  exists = True
342  enabled = int(r[0])
343  self.tag_name = str(r[1])
344  if exists is None:
345  self.logger.error( 'The job %s is unknown.', job_name )
346  return 2
347  if enabled:
348  res = self.session.query(O2OJobConf.configuration).filter_by(job_name=job_name).order_by(sqlalchemy.desc(O2OJobConf.insertion_time)).first()
349  conf = None
350  for r in res:
351  conf = str(r)
352  if conf is None:
353  self.logger.warning("No configuration found for job '%s'" %job_name )
354  else:
355  try:
356  self.conf_dict.update( json.loads(conf) )
357  self.logger.info('Using configuration: %s ' %conf)
358  except Exception as e:
359  self.logger.error( str(e) )
360  return 6
361  self.job_name = job_name
362  self.start = datetime.now()
363  run = O2ORun(job_name=self.job_name,start_time=self.start,status_code=startStatus)
364  self.session.add(run)
365  self.session.commit()
366  return 0
367  else:
368  self.logger.info( 'The job %s has been disabled.', job_name )
369  return 5
370  except sqlalchemy.exc.SQLAlchemyError as dberror:
371  self.logger.error( str(dberror) )
372  return 7
373  return -1
374 
375 
def startJob(self, job_name)
Definition: o2olib.py:334
#define str(s)

Member Data Documentation

o2olib.O2ORunMgr.conf_dict

Definition at line 329 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

o2olib.O2ORunMgr.end
o2olib.O2ORunMgr.job_name

Definition at line 326 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.endJob().

o2olib.O2ORunMgr.logger

Definition at line 332 of file o2olib.py.

o2olib.O2ORunMgr.session

Definition at line 331 of file o2olib.py.

o2olib.O2ORunMgr.start
o2olib.O2ORunMgr.tag_name

Definition at line 343 of file o2olib.py.