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

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
#define str(s)
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
#define str(s)

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.