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

◆ __init__()

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 

Member Function Documentation

◆ endJob()

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

Definition at line 375 of file o2olib.py.

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 

References poly< T >::const_iterator.end, validateAlignments.ValidationJob.end, cond::RunInfo_t.end, validateAlignments.ValidationJobMultiIOV.end, o2olib.O2ORunMgr.end, svgfig.LineAxis.end, relativeConstraints.error, info(), o2olib.O2ORunMgr.job_name, crabFunctions.CrabController.logger, o2olib.O2OMgr.logger, o2olib.O2ORunMgr.logger, querying.connection.session, o2olib.O2OJobMgr.session, o2olib.O2ORunMgr.session, validateAlignments.ValidationJob.start, cond::RunInfo_t.start, validateAlignments.ValidationJobMultiIOV.start, o2olib.O2ORunMgr.start, svgfig.LineAxis.start, and str.

Referenced by o2olib.O2ORunMgr.executeJob().

◆ executeJob()

def o2olib.O2ORunMgr.executeJob (   self,
  args 
)

Definition at line 387 of file o2olib.py.

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

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

◆ startJob()

def o2olib.O2ORunMgr.startJob (   self,
  job_name 
)

Definition at line 333 of file o2olib.py.

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 

References info(), createfilelist.int, crabFunctions.CrabController.logger, o2olib.O2OMgr.logger, o2olib.O2ORunMgr.logger, querying.connection.session, o2olib.O2OJobMgr.session, and o2olib.O2ORunMgr.session.

Referenced by o2olib.O2ORunMgr.executeJob().

Member Data Documentation

◆ conf_dict

o2olib.O2ORunMgr.conf_dict

Definition at line 328 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

◆ end

o2olib.O2ORunMgr.end

◆ job_name

o2olib.O2ORunMgr.job_name

Definition at line 325 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.endJob().

◆ logger

o2olib.O2ORunMgr.logger

◆ session

o2olib.O2ORunMgr.session

Definition at line 330 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.endJob(), and o2olib.O2ORunMgr.startJob().

◆ start

o2olib.O2ORunMgr.start

◆ tag_name

o2olib.O2ORunMgr.tag_name

Definition at line 342 of file o2olib.py.

info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
relativeConstraints.error
error
Definition: relativeConstraints.py:53
dqmdumpme.first
first
Definition: dqmdumpme.py:55
MessageLogger_cfi.warning
warning
Definition: MessageLogger_cfi.py:18
query
Definition: query.py:1
str
#define str(s)
Definition: TestProcessor.cc:48
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
createfilelist.int
int
Definition: createfilelist.py:10
merge
Definition: merge.py:1
update
#define update(a, b)
Definition: TrackClassifier.cc:10