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

◆ main()

def SiStripDCSPopCon.main ( )

Definition at line 68 of file SiStripDCSPopCon.py.

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('--sourceDb', required=True, help='Connection string for the source database.')
73  parser.add_argument('--destDb', required=True, help='Destination DB to upload.')
74  parser.add_argument('--inputTag', required=True, help='Tag name to be used in the sqlite file.')
75  parser.add_argument('--condDbRead', default='oracle://cms_orcon_adg/CMS_CONDITIONS', help='Connection string for the DB from which the fast O2O retrives payloads.')
76 
77  parser.add_argument('--no-upload', action="store_true", default=False, help='Do not upload payload. Default: %(default)s.')
78  parser.add_argument('--use-uploader', action="store_true", default=False, help='Use conditionUploader instead of conddb copy. Default: %(default)s.')
79  parser.add_argument('--debug', action="store_true", default=False, help='Switch on debug mode. Default: %(default)s.')
80  args = parser.parse_args()
81 
82  loglevel = logging.INFO
83  if args.debug:
84  loglevel = logging.DEBUG
85  logging.basicConfig(level=loglevel, format='[%(asctime)s] %(levelname)s: %(message)s')
86 
87  args.destTags = args.destTags.strip().split(',')
88 
89  logging.info('Running DCS O2O with %s hour(s) delay on machine [%s]' % (str(args.delay), socket.gethostname()))
90 
91  try:
92  jobdirbase = os.environ[jobDirVar]
93  except KeyError:
94  jobdirbase = '/tmp'
95  logging.warning('%s not set in env, will use %s' % (jobDirVar, jobdirbase))
96 
97 
98  # change to O2O working directory
99  jobdir = os.path.join(jobdirbase, '{delay}hourDelay'.format(delay=args.delay))
100  if not os.path.exists(jobdir):
101  os.makedirs(jobdir)
102  os.chdir(jobdir)
103  logging.info('Running O2O in %s' % jobdir)
104 
105  # run job and upload
106  runjob(args)
107 
108  logging.info('Done!')
109 
110 
111 

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

◆ runjob()

def SiStripDCSPopCon.runjob (   args)

Definition at line 18 of file SiStripDCSPopCon.py.

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} sourceConnection={sourceDb} conddbConnection={conddb} tag={tag}'.format(
36  cfg=cfg, delay=args.delay, destFile='sqlite:///%s' % output_db, sourceDb=args.sourceDb, 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 

References f, submitPVValidationJobs.split(), and str.

Referenced by main().

SiStripDCSPopCon.main
def main()
Definition: SiStripDCSPopCon.py:68
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
str
#define str(s)
Definition: TestProcessor.cc:51
format
SiStripDCSPopCon.runjob
def runjob(args)
Definition: SiStripDCSPopCon.py:18