CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
o2olib.O2ORunMgr Class Reference
Inheritance diagram for o2olib.O2ORunMgr:

Public Member Functions

def __init__
 
def endJob
 
def executeJob
 
def startJob
 

Public Attributes

 conf_dict
 
 end
 
 job_name
 
 logger
 
 session
 
 start
 
 tag_name
 

Detailed Description

Definition at line 295 of file o2olib.py.

Constructor & Destructor Documentation

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

Definition at line 297 of file o2olib.py.

298  def __init__( self, db_connection, session, logger ):
299  self.job_name = None
300  self.start = None
301  self.end = None
302  self.conf_dict = {}
303  self.conf_dict['db'] = db_connection
304  self.session = session
305  self.logger = logger

Member Function Documentation

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

Definition at line 348 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.O2OJobConf.job_name, o2olib.O2ORun.job_name, 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().

349  def endJob( self, status, log ):
350  self.end = datetime.utcnow()
351  try:
352  run = O2ORun(job_name=self.job_name,start_time=self.start,end_time=self.end,status_code=status,log=log)
353  self.session.merge(run)
354  self.session.commit()
355  self.logger.info( 'Job %s ended.', self.job_name )
356  return 0
357  except sqlalchemy.exc.SQLAlchemyError as dberror:
358  self.logger.error( str(dberror) )
359  return 8
#define str(s)
def o2olib.O2ORunMgr.executeJob (   self,
  args 
)

Definition at line 360 of file o2olib.py.

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

361  def executeJob( self, args ):
362  job_name = args.name
363  command = args.executable
364  logFolder = os.getcwd()
365  if logFolderEnvVar in os.environ:
366  logFolder = os.environ[logFolderEnvVar]
367  datelabel = datetime.utcnow().strftime("%y-%m-%d-%H-%M-%S")
368  logFileName = '%s-%s.log' %(job_name,datelabel)
369  logFile = os.path.join(logFolder,logFileName)
370  started = self.startJob( job_name )
371  if started !=0:
372  return started
373  ret = -1
374  try:
375  # replacing %([key])s placeholders...
376  command = command %(self.conf_dict)
377  #replacing {[key]} placeholders
378  command = command.format(**self.conf_dict )
379  except KeyError as exc:
380  self.logger.error( "Unresolved template key %s in the command." %str(exc) )
381  return 3
382  self.logger.info('Command: "%s"', command )
383  out = ''
384  try:
385  self.logger.info('Executing command...' )
386  pipe = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
387  for line in pipe.stdout:
388  if args.verbose is not None and args.verbose>=1:
389  sys.stdout.write(line.decode())
390  sys.stdout.flush()
391  out += line.decode()
392  pipe.communicate()
393  self.logger.info( 'Command returned code: %s' %pipe.returncode )
394  ret = pipe.returncode
395  except Exception as e:
396  self.logger.error( str(e) )
397  return 4
398  ended = self.endJob( pipe.returncode, out )
399  if ended != 0:
400  ret = ended
401  with open(logFile,'a') as logF:
402  logF.write(out)
403  return ret
#define str(s)
def o2olib.O2ORunMgr.startJob (   self,
  job_name 
)

Definition at line 306 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

307  def startJob( self, job_name ):
308  self.logger.info('Checking job %s', job_name)
309  exists = None
310  enabled = None
311  try:
312  res = self.session.query(O2OJob.enabled,O2OJob.tag_name).filter_by(name=job_name)
313  for r in res:
314  exists = True
315  enabled = int(r[0])
316  self.tag_name = str(r[1])
317  if exists is None:
318  self.logger.error( 'The job %s is unknown.', job_name )
319  return 2
320  if enabled:
321  res = self.session.query(O2OJobConf.configuration).filter_by(job_name=job_name).order_by(sqlalchemy.desc(O2OJobConf.insertion_time)).first()
322  conf = None
323  for r in res:
324  conf = str(r)
325  if conf is None:
326  self.logger.warning("No configuration found for job '%s'" %job_name )
327  else:
328  try:
329  self.conf_dict.update( json.loads(conf) )
330  self.logger.info('Using configuration: %s ' %conf)
331  except Exception as e:
332  self.logger.error( str(e) )
333  return 6
334  self.job_name = job_name
335  self.start = datetime.utcnow()
336  run = O2ORun(job_name=self.job_name,start_time=self.start,status_code=startStatus)
337  self.session.add(run)
338  self.session.commit()
339  return 0
340  else:
341  self.logger.info( 'The job %s has been disabled.', job_name )
342  return 5
343  except sqlalchemy.exc.SQLAlchemyError as dberror:
344  self.logger.error( str(dberror) )
345  return 7
346  return -1
347 
#define str(s)

Member Data Documentation

o2olib.O2ORunMgr.conf_dict

Definition at line 301 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

o2olib.O2ORunMgr.end

Definition at line 300 of file o2olib.py.

Referenced by OrderedSet.OrderedSet.__iter__(), OrderedSet.OrderedSet.__reversed__(), OrderedSet.OrderedSet.add(), Types.LuminosityBlockRange.cppID(), Types.EventRange.cppID(), o2olib.O2ORunMgr.endJob(), and OrderedSet.OrderedSet.pop().

o2olib.O2ORunMgr.job_name

Definition at line 298 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.endJob().

o2olib.O2ORunMgr.logger

Definition at line 304 of file o2olib.py.

o2olib.O2ORunMgr.session

Definition at line 303 of file o2olib.py.

o2olib.O2ORunMgr.start

Definition at line 299 of file o2olib.py.

Referenced by progressbar.ProgressBar.__next__(), Types.LuminosityBlockRange.cppID(), Types.EventRange.cppID(), and o2olib.O2ORunMgr.endJob().

o2olib.O2ORunMgr.tag_name

Definition at line 315 of file o2olib.py.