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, cond::RunInfo_t.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, cond::RunInfo_t.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(), SiStripDetVOffHandler.endJob(), HcalCableMapper.endJob(), EcalStatusAnalyzer.endJob(), EcalPerEvtMatacqAnalyzer.endJob(), HcalLutGenerator.endJob(), RawDataConverter.endJob(), EcalTPGParamReaderFromDB.endJob(), EcalMatacqAnalyzer.endJob(), CPUSpender.endJob(), SubdetFEDSelector.endJob(), TkAlCaSkimTreeMerger.endJob(), EcalPnGraphs.endJob(), DTTPAnalyzer.endJob(), SiStripDetVOffPrinter.endJob(), DTMapGenerator.endJob(), EcalDigiDisplay.endJob(), popcon::PopConAnalyzer< S >.endJob(), SiStripRegFEDSelector.endJob(), SurveyDataConverter.endJob(), WriteEcalMiscalibConstants.endJob(), WriteEcalMiscalibConstantsMC.endJob(), AlcaBeamSpotFromDB.endJob(), DTVDriftSegmentCalibration.endJob(), ECALRegFEDSelector.endJob(), DTT0Correction.endJob(), DTTTrigCorrectionFirst.endJob(), DTVDriftWriter.endJob(), SurveyDBUploader.endJob(), DTResidualCalibration.endJob(), FilterOutLowPt.endJob(), DTTTrigCorrection.endJob(), DTTTrigOffsetCalibration.endJob(), DTT0CalibrationRMS.endJob(), LaserDQM.endJob(), TkVoltageMapCreator.endJob(), DTTTrigWriter.endJob(), miscalibExample.endJob(), AlignmentPrescaler.endJob(), EcalPedHists.endJob(), PuppiProducer.endJob(), DTNoiseCalibration.endJob(), SimAnalyzerMinbias.endJob(), SiStripLAProfileBooker.endJob(), AlignmentProducerAsAnalyzer.endJob(), EcalPedOffset.endJob(), DTTPDeadWriter.endJob(), DTVDriftCalibration.endJob(), EcalABAnalyzer.endJob(), DTTTrigCalibration.endJob(), Tracker_OldtoNewConverter.endJob(), ValidationMisalignedTracker.endJob(), RecAnalyzerHF.endJob(), EcalPerEvtLaserAnalyzer.endJob(), DTT0Calibration.endJob(), MuonGeometryDBConverter.endJob(), EcalTestPulseAnalyzer.endJob(), DTNoiseComputation.endJob(), TrackerGeometryCompare.endJob(), LhcTrackAnalyzer.endJob(), EcalPulseShapeGrapher.endJob(), ElectronCalibration.endJob(), JetDeltaRTagInfoValueMapProducer< T, I >.endJob(), EcalRecHitsFilter.endJob(), EcalBxOrbitNumberGrapher.endJob(), cms::ProducerAnalyzer.endJob(), SiPixelDQMRocLevelAnalyzer.endJob(), testChannel.endJob(), HIPTwoBodyDecayAnalyzer.endJob(), edmTracerCompactLogViewer.Phase.endJob, EcalIsolatedParticleCandidateProducer.endJob(), IsolatedParticlesGeneratedJets.endJob(), EcalLaserAnalyzerYousi.endJob(), CorrPCCProducer.endJob(), HitEff.endJob(), HcalCalibrator.endJob(), HcalLuttoDB.endJob(), EcalLaserAnalyzer.endJob(), EcalLaserAnalyzer2.endJob(), PPSStraightTrackAligner.endJob(), EcalURecHitHists.endJob(), StudyCaloGen.endJob(), HcalRaddamMuon.endJob(), JetHTAnalyzer.endJob(), HitResol.endJob(), MuonAlignmentAnalyzer.endJob(), ElectronCalibrationUniv.endJob(), ApeEstimatorSummary.endJob(), EcalMipGraphs.endJob(), AnalyzerMinbias.endJob(), CosmicSplitterValidation.endJob(), SiPixelErrorEstimation.endJob(), HOCalibAnalyzer.endJob(), EopTreeWriter.endJob(), EcalDisplaysByEvent.endJob(), TrackerTreeGenerator.endJob(), NearbyPixelClustersAnalyzer.endJob(), ApeTreeCreateDefault.endJob(), DiMuonVertexValidation.endJob(), CSCOverlapsTrackPreparation.endJob(), SiPixelErrorsDigisToCalibDigis.endJob(), AlignmentMonitorAsAnalyzer.endJob(), RecAnalyzerMinbias.endJob(), DiElectronVertexValidation.endJob(), cms::Analyzer_minbias.endJob(), AlignmentStats.endJob(), PixelBaryCentreAnalyzer.endJob(), LaserAlignment.endJob(), EcalCosmicsHists.endJob(), PrimaryVertexValidation.endJob(), CosmicRateAnalyzer.endJob(), SplitVertexResolution.endJob(), analyzer::SiPixelLorentzAngle.endJob(), IsoTrackCalib.endJob(), OverlapValidation.endJob(), SelectedElectronFEDListProducer< TEle, TCand >.endJob(), TrackerOfflineValidationSummary.endJob(), IsoTrig.endJob(), IsolatedTracksHcalScale.endJob(), EopElecTreeWriter.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.