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 322 of file o2olib.py.

Constructor & Destructor Documentation

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

Definition at line 324 of file o2olib.py.

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

Member Function Documentation

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

Definition at line 375 of file o2olib.py.

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

Referenced by o2olib.O2ORunMgr.executeJob().

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

Definition at line 387 of file o2olib.py.

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

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

Definition at line 333 of file o2olib.py.

References createfilelist.int.

Referenced by o2olib.O2ORunMgr.executeJob().

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

Member Data Documentation

o2olib.O2ORunMgr.conf_dict

Definition at line 328 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

o2olib.O2ORunMgr.end
o2olib.O2ORunMgr.job_name

Definition at line 325 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.endJob().

o2olib.O2ORunMgr.logger

Definition at line 331 of file o2olib.py.

o2olib.O2ORunMgr.session

Definition at line 330 of file o2olib.py.

o2olib.O2ORunMgr.start
o2olib.O2ORunMgr.tag_name

Definition at line 342 of file o2olib.py.