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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 297 of file o2olib.py.

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

Member Function Documentation

◆ endJob()

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

Definition at line 348 of file o2olib.py.

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

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, submitPVValidationJobs.Job.job_name, crabFunctions.CrabController.logger, o2olib.O2OJobMgr.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 360 of file o2olib.py.

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

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

◆ startJob()

def o2olib.O2ORunMgr.startJob (   self,
  job_name 
)

Definition at line 306 of file o2olib.py.

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

References info(), createfilelist.int, crabFunctions.CrabController.logger, o2olib.O2OJobMgr.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 301 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

◆ end

o2olib.O2ORunMgr.end

◆ job_name

o2olib.O2ORunMgr.job_name

Definition at line 298 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.endJob().

◆ logger

o2olib.O2ORunMgr.logger

◆ session

o2olib.O2ORunMgr.session

Definition at line 303 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 315 of file o2olib.py.

info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
relativeConstraints.error
error
Definition: relativeConstraints.py:53
MessageLogger_cfi.warning
warning
Definition: MessageLogger_cfi.py:18
query
Definition: query.py:1
str
#define str(s)
Definition: TestProcessor.cc:53
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
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