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 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ endJob()

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, relativeConstraints.error, info(), o2olib.O2ORunMgr.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().

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 
Definition: merge.py:1
static const TGPicture * info(bool iBackgroundIsBlack)
#define str(s)

◆ executeJob()

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

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 
static const TGPicture * info(bool iBackgroundIsBlack)
#define str(s)

◆ startJob()

def o2olib.O2ORunMgr.startJob (   self,
  job_name 
)

Definition at line 306 of file o2olib.py.

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().

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 
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: query.py:1
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
#define update(a, b)
#define str(s)

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.