CMS 3D CMS Logo

Functions
SiStripDCSPopCon Namespace Reference

Functions

def main ()
 
def runjob (args)
 

Detailed Description

Script that runs SiStrip DCS O2O.
@author: Huilin Qu

Function Documentation

def SiStripDCSPopCon.main ( )

Definition at line 68 of file SiStripDCSPopCon.py.

References runjob(), split, and harvestTrackValidationPlots.str.

68 def main():
69  parser = argparse.ArgumentParser(description='Run a single O2O job for SiStrip DCS and upload the payloads to condition database.')
70  parser.add_argument('--delay', required=True, help='Time delay (in hours) for the O2O. The O2O then queries the PVSS DB from last IOV until (current hour - delay), ignoring minutes and seconds.')
71  parser.add_argument('--destTags', required=True, help='Destination tag name(s) for upload. Use comma to separate multiple values.')
72  parser.add_argument('--destDb', required=True, help='Destination DB to upload.')
73  parser.add_argument('--inputTag', required=True, help='Tag name to be used in the sqlite file.')
74  parser.add_argument('--condDbRead', default='oracle://cms_orcon_adg/CMS_CONDITIONS', help='Connection string for the DB from which the fast O2O retrives payloads.')
75 
76  parser.add_argument('--no-upload', action="store_true", default=False, help='Do not upload payload. Default: %(default)s.')
77  parser.add_argument('--use-uploader', action="store_true", default=False, help='Use conditionUploader instead of conddb copy. Default: %(default)s.')
78  parser.add_argument('--debug', action="store_true", default=False, help='Switch on debug mode. Default: %(default)s.')
79  args = parser.parse_args()
80 
81  loglevel = logging.INFO
82  if args.debug:
83  loglevel = logging.DEBUG
84  logging.basicConfig(level=loglevel, format='[%(asctime)s] %(levelname)s: %(message)s')
85 
86  args.destTags = args.destTags.strip().split(',')
87 
88  logging.info('Running DCS O2O with %s hour(s) delay on machine [%s]' % (str(args.delay), socket.gethostname()))
89 
90  try:
91  jobdirbase = os.environ[jobDirVar]
92  except KeyError:
93  jobdirbase = '/tmp'
94  logging.warning('%s not set in env, will use %s' % (jobDirVar, jobdirbase))
95 
96 
97  # change to O2O working directory
98  jobdir = os.path.join(jobdirbase, '{delay}hourDelay'.format(delay=args.delay))
99  if not os.path.exists(jobdir):
100  os.makedirs(jobdir)
101  os.chdir(jobdir)
102  logging.info('Running O2O in %s' % jobdir)
103 
104  # run job and upload
105  runjob(args)
106 
107  logging.info('Done!')
108 
109 
110 
double split
Definition: MVATrainer.cc:139
def SiStripDCSPopCon.runjob (   args)

Definition at line 18 of file SiStripDCSPopCon.py.

References f, split, and harvestTrackValidationPlots.str.

Referenced by main().

18 def runjob(args):
19  if args.debug:
20  logging.debug(str(args))
21 
22  # find cfg file
23  for basedir in os.environ['CMSSW_SEARCH_PATH'].split(':'):
24  cfg = os.path.join(basedir, cfg_file)
25  if os.path.exists(cfg):
26  logging.info('Use config file %s' % cfg)
27  break
28 
29  output_db = 'SiStripDetVOff_{delay}.db'.format(delay=args.delay)
30  if os.path.exists(output_db):
31  logging.info('Output sqlite file %s already exists! Deleting...' % output_db)
32  os.remove(output_db)
33 
34  # run cmssw job: raise error if failed
35  command = 'cmsRun {cfg} delay={delay} destinationConnection={destFile} conddbConnection={conddb} tag={tag}'.format(
36  cfg=cfg, delay=args.delay, destFile='sqlite:///%s' % output_db, conddb=args.condDbRead, tag=args.inputTag)
37  pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
38  atexit.register(partial(helper.kill_subproc_noexcept, pipe))
39  out = pipe.communicate()[0]
40  logging.info('\n%s\n' % out)
41  logging.info('@@@CMSSW job return code = %d@@@' % pipe.returncode)
42  if pipe.returncode != 0:
43  raise RuntimeError('O2O job FAILED!')
44 
45  # upload: raise error if failed
46  if args.no_upload:
47  logging.info('Will not run uploading as requested!')
48  return
49 
50  if not helper.exists_iov(output_db, args.inputTag):
51  logging.info('No IOV exists in the SQLite file. Will skip upload!')
52  return
53 
54  if args.use_uploader:
55  f = helper.upload_payload
56  else:
57  f = helper.copy_payload
58  f(dbFile=output_db, inputTag=args.inputTag, destTags=args.destTags, destDb=args.destDb, since=None,
59  userText='SiStripDCS {delay} hour delay'.format(delay=args.delay))
60 
61  # clean up
62  try:
63  os.remove(output_db)
64  os.remove(output_db.replace('.db', '.txt'))
65  except OSError:
66  pass
67 
double f[11][100]
double split
Definition: MVATrainer.cc:139