File indexing completed on 2024-11-25 02:29:20
0001
0002
0003 import cx_Oracle
0004 import datetime
0005 import calendar
0006 import sys
0007 import logging
0008 import CondCore.Utilities.conddb_serialization_metadata as sm
0009 import CondCore.Utilities.credentials as auth
0010 import CondCore.Utilities.conddb_time as conddb_time
0011 import os
0012
0013 prod_db_service = ('cms_orcon_prod',{'w':'cms_orcon_prod/cms_cond_general_w','r':'cms_orcon_prod/cms_cond_general_r'})
0014 adg_db_service = ('cms_orcon_adg',{'r':'cms_orcon_adg/cms_cond_general_r'})
0015 dev_db_service = ('cms_orcoff_prep',{'w':'cms_orcoff_prep/cms_cond_general_w','r':'cms_orcoff_prep/cms_cond_general_r'})
0016 schema_name = 'CMS_CONDITIONS'
0017
0018 fmt_str = "[%(asctime)s] %(levelname)s: %(message)s"
0019 logLevel = logging.INFO
0020 logFormatter = logging.Formatter(fmt_str)
0021
0022 def print_table( headers, table ):
0023 ws = []
0024 for h in headers:
0025 ws.append(len(h))
0026 for row in table:
0027 ind = 0
0028 for c in row:
0029 c = str(c)
0030 if ind<len(ws):
0031 if len(c)> ws[ind]:
0032 ws[ind] = len(c)
0033 ind += 1
0034
0035 def printf( row ):
0036 line = ''
0037 ind = 0
0038 for w in ws:
0039 fmt = '{:<%s}' %w
0040 if ind<len(ws):
0041 line += (fmt.format( row[ind] )+' ')
0042 ind += 1
0043 print(line)
0044 printf( headers )
0045 hsep = ''
0046 for w in ws:
0047 fmt = '{:-<%s}' %w
0048 hsep += (fmt.format('')+' ')
0049 print(hsep)
0050 for row in table:
0051 printf( row )
0052
0053 class version_db(object):
0054 def __init__(self, db ):
0055 self.db = db
0056 self.cmssw_boost_map = {}
0057 self.boost_run_map = []
0058
0059 def fetch_cmssw_boost_map( self ):
0060 cursor = self.db.cursor()
0061 cursor.execute('SELECT BOOST_VERSION, CMSSW_VERSION FROM CMSSW_BOOST_MAP');
0062 rows = cursor.fetchall()
0063 self.cmssw_boost_map = {}
0064 for r in rows:
0065 self.cmssw_boost_map[r[1]]=r[0]
0066 return self.cmssw_boost_map
0067
0068 def fetch_boost_run_map( self ):
0069 cursor = self.db.cursor()
0070 cursor.execute('SELECT RUN_NUMBER, RUN_START_TIME, BOOST_VERSION, INSERTION_TIME FROM BOOST_RUN_MAP ORDER BY RUN_NUMBER, INSERTION_TIME')
0071 rows = cursor.fetchall()
0072 self.boost_run_map = []
0073 for r in rows:
0074 self.boost_run_map.append( (r[0],r[1],r[2],str(r[3])) )
0075 return self.boost_run_map
0076
0077 def insert_boost_run_range( self, run, boost_version, min_ts ):
0078 cursor = self.db.cursor()
0079 cursor.execute('SELECT MIN(RUN_NUMBER) FROM RUN_INFO WHERE RUN_NUMBER >= :RUN',(run,))
0080 res = cursor.fetchone()
0081 if res is not None and res[0] is not None:
0082 min_run = res[0]
0083 cursor.execute('SELECT START_TIME FROM RUN_INFO WHERE RUN_NUMBER=:RUN',(min_run,))
0084 min_run_time = cursor.fetchone()[0]
0085 min_run_ts = calendar.timegm( min_run_time.utctimetuple() ) << 32
0086 else:
0087 min_run = run
0088 min_run_ts = conddb_time.string_to_timestamp(min_ts)
0089 now = datetime.datetime.utcnow()
0090 cursor.execute('INSERT INTO BOOST_RUN_MAP ( RUN_NUMBER, RUN_START_TIME, BOOST_VERSION, INSERTION_TIME ) VALUES (:RUN, :RUN_START_T, :BOOST, :TIME)',(run,min_run_ts,boost_version,now) )
0091
0092 def insert_cmssw_boost( self, cmssw_version,boost_version ):
0093 cursor = self.db.cursor()
0094 cursor.execute('INSERT INTO CMSSW_BOOST_MAP ( CMSSW_VERSION, BOOST_VERSION ) VALUES ( :CMSSW_VERSION, :BOOST_VERSION )',(cmssw_version,boost_version))
0095
0096 def lookup_boost_in_cmssw( self, cmssw_version ):
0097 cmssw_v = sm.check_cmssw_version( cmssw_version )
0098 the_arch = None
0099 releaseRoot = None
0100 if sm.is_release_cycle( cmssw_v ):
0101 cmssw_v = sm.strip_cmssw_version( cmssw_v )
0102 archs = sm.get_production_arch( cmssw_v )
0103 for arch in archs:
0104 path = sm.get_release_root( cmssw_v, arch )
0105 if os.path.exists(os.path.join(path,cmssw_v)):
0106 releaseRoot = path
0107 the_arch = arch
0108 break
0109 if releaseRoot is None:
0110 for arch in archs:
0111 the_arch = arch
0112 releaseRoot = sm.get_release_root( cmssw_v, arch )
0113 for r in sorted (os.listdir( releaseRoot )):
0114 if r.startswith(cmssw_v):
0115 cmssw_v = r
0116 logging.debug('Boost version will be verified in release %s' %cmssw_v)
0117
0118 if cmssw_v in self.cmssw_boost_map.keys():
0119 return self.cmssw_boost_map[cmssw_v]
0120
0121 if releaseRoot is None:
0122 archs = sm.get_production_arch( cmssw_v )
0123 for arch in archs:
0124 path = sm.get_release_root( cmssw_v, arch )
0125 if os.path.exists(os.path.join(path,cmssw_v)):
0126 releaseRoot = path
0127 the_arch = arch
0128 break
0129 logging.debug('Release path: %s' %releaseRoot)
0130 boost_version = sm.get_cmssw_boost( the_arch, '%s/%s' %(releaseRoot,cmssw_v) )
0131 if not boost_version is None:
0132 self.cmssw_boost_map[cmssw_v] = boost_version
0133 self.insert_cmssw_boost( cmssw_v,boost_version )
0134 return boost_version
0135
0136 def populate_for_gts( self ):
0137 cursor = self.db.cursor()
0138 cursor.execute('SELECT DISTINCT(RELEASE) FROM GLOBAL_TAG')
0139 rows = cursor.fetchall()
0140 for r in rows:
0141 self.lookup_boost_in_cmssw( r[0] )
0142
0143 class conddb_tool(object):
0144 def __init__( self ):
0145 self.db = None
0146 self.version_db = None
0147 self.args = None
0148 self.logger = logging.getLogger()
0149 self.logger.setLevel(logLevel)
0150 consoleHandler = logging.StreamHandler(sys.stdout)
0151 consoleHandler.setFormatter(logFormatter)
0152 self.logger.addHandler(consoleHandler)
0153 self.iovs = None
0154 self.versionIovs = None
0155
0156 def connect( self ):
0157 if self.args.db is None:
0158 self.args.db = 'pro'
0159 if self.args.db == 'dev' or self.args.db == 'oradev' :
0160 db_service = dev_db_service
0161 elif self.args.db == 'orapro':
0162 db_service = adg_db_service
0163 elif self.args.db != 'onlineorapro' or self.args.db != 'pro':
0164 db_service = prod_db_service
0165 else:
0166 raise Exception("Database '%s' is not known." %args.db )
0167 if self.args.accessType not in db_service[1].keys():
0168 raise Exception('The specified database connection %s does not support the requested action.' %db_service[0])
0169 service = db_service[1][self.args.accessType]
0170 creds = auth.get_credentials( service, self.args.auth )
0171 if creds is None:
0172 raise Exception("Could not find credentials for service %s" %service)
0173 (username, account, pwd) = creds
0174 connStr = '%s/%s@%s' %(username,pwd,db_service[0])
0175 self.db = cx_Oracle.connect(connStr)
0176 logging.info('Connected to %s as user %s' %(db_service[0],username))
0177 self.db.current_schema = schema_name
0178
0179 def process_tag_boost_version( self, t, timetype, tagBoostVersion, minIov, timeCut, validate ):
0180 if self.iovs is None:
0181 self.iovs = []
0182 cursor = self.db.cursor()
0183 stmt = 'SELECT IOV.SINCE SINCE, IOV.INSERTION_TIME INSERTION_TIME, P.STREAMER_INFO STREAMER_INFO FROM TAG, IOV, PAYLOAD P WHERE TAG.NAME = IOV.TAG_NAME AND P.HASH = IOV.PAYLOAD_HASH AND TAG.NAME = :TAG_NAME'
0184 params = (t,)
0185 if timeCut and tagBoostVersion is not None and not validate:
0186 whereClauseOnSince = ' AND IOV.INSERTION_TIME>:TIME_CUT'
0187 stmt = stmt + whereClauseOnSince
0188 params = params + (timeCut,)
0189 stmt = stmt + ' ORDER BY SINCE'
0190 logging.debug('Executing: "%s"' %stmt)
0191 cursor.execute(stmt,params)
0192 for r in cursor:
0193 streamer_info = str(r[2].read())
0194 self.iovs.append((r[0],r[1],streamer_info))
0195 niovs = 0
0196 self.versionIovs = []
0197 lastBoost = None
0198 update = False
0199 if tagBoostVersion is not None:
0200 update = True
0201 for iov in self.iovs:
0202 if validate and timeCut is not None and timeCut < iov[1]:
0203 continue
0204 niovs += 1
0205 iovBoostVersion, tagBoostVersion = sm.update_tag_boost_version( tagBoostVersion, minIov, iov[2], iov[0], timetype, self.version_db.boost_run_map )
0206 if minIov is None or iov[0]<minIov:
0207 minIov = iov[0]
0208 logging.debug('iov: %s - inserted on %s - streamer: %s' %(iov[0],iov[1],iov[2]))
0209 logging.debug('current tag boost version: %s minIov: %s' %(tagBoostVersion,minIov))
0210 if lastBoost is None or lastBoost!=iovBoostVersion:
0211 self.versionIovs.append((iov[0],iovBoostVersion))
0212 lastBoost = iovBoostVersion
0213
0214 if tagBoostVersion is None:
0215 if niovs == 0:
0216 logging.warning( 'No iovs found. boost version cannot be determined.')
0217 return None, None
0218 else:
0219 logging.error('Could not determine the tag boost version.' )
0220 return None, None
0221 else:
0222 if niovs == 0:
0223 logging.info('Tag boost version has not changed.')
0224 else:
0225 msg = 'Found tag boost version %s ( min iov: %s ) combining payloads from %s iovs' %(tagBoostVersion,minIov,niovs)
0226 if timeCut is not None:
0227 if update:
0228 msg += ' (iov insertion time>%s)' %str(timeCut)
0229 else:
0230 msg += ' (iov insertion time<%s)' %str(timeCut)
0231 logging.info( msg )
0232 return tagBoostVersion, minIov
0233
0234 def validate_boost_version( self, t, timetype, tagBoostVersion ):
0235 cursor = self.db.cursor()
0236 cursor.execute('SELECT GT.NAME, GT.RELEASE, GT.SNAPSHOT_TIME FROM GLOBAL_TAG GT, GLOBAL_TAG_MAP GTM WHERE GT.NAME = GTM.GLOBAL_TAG_NAME AND GTM.TAG_NAME = :TAG_NAME',(t,))
0237 rows = cursor.fetchall()
0238 invalid_gts = []
0239 ngt = 0
0240 gts = []
0241 for r in rows:
0242 gts.append((r[0],r[1],r[2]))
0243 if len(gts)>0:
0244 logging.info('validating %s gts.' %len(gts))
0245 boost_snapshot_map = {}
0246 for gt in gts:
0247 ngt += 1
0248 logging.debug('Validating for GT %s (release %s)' %(gt[0],gt[1]))
0249 gtCMSSWVersion = sm.check_cmssw_version( gt[1] )
0250 gtBoostVersion = self.version_db.lookup_boost_in_cmssw( gtCMSSWVersion )
0251 if sm.cmp_boost_version( gtBoostVersion, tagBoostVersion )<0:
0252 logging.warning( 'The boost version computed from all the iovs in the tag (%s) is incompatible with the gt [%s] %s (consuming ver: %s, snapshot: %s)' %(tagBoostVersion,ngt,gt[0],gtBoostVersion,str(gt[2])))
0253 if str(gt[2]) not in boost_snapshot_map.keys():
0254 tagSnapshotBoostVersion = None
0255 minIov = None
0256 tagSnapshotBoostVersion, minIov = self.process_tag_boost_version(t, timetype, tagSnapshotBoostVersion, minIov, gt[2])
0257 if tagSnapshotBoostVersion is not None:
0258 boost_snapshot_map[str(gt[2])] = tagSnapshotBoostVersion
0259 else:
0260 continue
0261 else:
0262 tagSnapshotBoostVersion = boost_snapshot_map[str(gt[2])]
0263 if sm.cmp_boost_version( gtBoostVersion, tagSnapshotBoostVersion )<0:
0264 logging.error('The snapshot from tag used by gt %s (consuming ver: %s) has an incompatible combined boost version %s' %(gt[0],gtBoostVersion,tagSnapshotBoostVersion))
0265 invalid_gts.append( ( gt[0], gtBoostVersion ) )
0266 if len(invalid_gts)==0:
0267 if ngt>0:
0268 logging.info('boost version for the tag validated in %s referencing Gts' %(ngt))
0269 else:
0270 logging.info('No GT referencing this tag found.')
0271 else:
0272 logging.error( 'boost version for the tag is invalid.')
0273 return invalid_gts
0274
0275 def update_tag_boost_version_in_db( self, t, tagBoostVersion, minIov, update ):
0276 cursor = self.db.cursor()
0277 now = datetime.datetime.utcnow()
0278 if update:
0279 cursor.execute('UPDATE TAG_METADATA SET MIN_SERIALIZATION_V=:BOOST_V, MIN_SINCE=:MIN_IOV, MODIFICATION_TIME=:NOW WHERE TAG_NAME = :NAME',( tagBoostVersion,minIov,now,t))
0280 else:
0281 cursor.execute('INSERT INTO TAG_METADATA ( TAG_NAME, MIN_SERIALIZATION_V, MIN_SINCE, MODIFICATION_TIME ) VALUES ( :NAME, :BOOST_V, :MIN_IOV, :NOW )',(t, tagBoostVersion,minIov,now))
0282 logging.info('Minimum boost version for the tag updated.')
0283
0284 def update_tags( self ):
0285 cursor = self.db.cursor()
0286 self.version_db = version_db( self.db )
0287 self.version_db.fetch_cmssw_boost_map()
0288 self.version_db.fetch_boost_run_map()
0289 tags = {}
0290 wpars = ()
0291 if self.args.name is not None:
0292 stmt0 = 'SELECT NAME FROM TAG WHERE NAME = :TAG_NAME'
0293 wpars = (self.args.name,)
0294 cursor.execute(stmt0,wpars);
0295 rows = cursor.fetchall()
0296 found = False
0297 for r in rows:
0298 found = True
0299 break
0300 if not found:
0301 raise Exception('Tag %s does not exists in the database.' %self.args.name )
0302 tags[self.args.name] = None
0303 stmt1 = 'SELECT MIN_SERIALIZATION_V, MIN_SINCE, CAST(MODIFICATION_TIME AS TIMESTAMP(0)) FROM TAG_METADATA WHERE TAG_NAME = :NAME'
0304 cursor.execute(stmt1,wpars);
0305 rows = cursor.fetchall()
0306 for r in rows:
0307 tags[self.args.name] = (r[0],r[1],r[2])
0308 else:
0309 stmt0 = 'SELECT NAME FROM TAG WHERE NAME NOT IN ( SELECT TAG_NAME FROM TAG_METADATA) ORDER BY NAME'
0310 nmax = 100
0311 if self.args.max is not None:
0312 nmax = self.args.max
0313 if self.args.all:
0314 nmax = -1
0315 if nmax >=0:
0316 stmt0 = 'SELECT NAME FROM (SELECT NAME FROM TAG WHERE NAME NOT IN ( SELECT TAG_NAME FROM TAG_METADATA ) ORDER BY NAME) WHERE ROWNUM<= :MAXR'
0317 wpars = (nmax,)
0318 cursor.execute(stmt0,wpars);
0319 rows = cursor.fetchall()
0320 for r in rows:
0321 tags[r[0]] = None
0322 stmt1 = 'SELECT T.NAME NAME, TM.MIN_SERIALIZATION_V MIN_SERIALIZATION_V, TM.MIN_SINCE MIN_SINCE, CAST(TM.MODIFICATION_TIME AS TIMESTAMP(0)) MODIFICATION_TIME FROM TAG T, TAG_METADATA TM WHERE T.NAME=TM.TAG_NAME AND CAST(TM.MODIFICATION_TIME AS TIMESTAMP(0)) < (SELECT MAX(INSERTION_TIME) FROM IOV WHERE IOV.TAG_NAME=TM.TAG_NAME) ORDER BY NAME'
0323 nmax = nmax-len(tags)
0324 if nmax >=0:
0325 stmt1 = 'SELECT NAME, MIN_SERIALIZATION_V, MIN_SINCE, MODIFICATION_TIME FROM (SELECT T.NAME NAME, TM.MIN_SERIALIZATION_V MIN_SERIALIZATION_V, TM.MIN_SINCE MIN_SINCE, CAST(TM.MODIFICATION_TIME AS TIMESTAMP(0)) MODIFICATION_TIME FROM TAG T, TAG_METADATA TM WHERE T.NAME=TM.TAG_NAME AND CAST(TM.MODIFICATION_TIME AS TIMESTAMP(0)) < (SELECT MAX(INSERTION_TIME) FROM IOV WHERE IOV.TAG_NAME=TM.TAG_NAME) ORDER BY NAME) WHERE ROWNUM<= :MAXR'
0326 wpars = (nmax,)
0327 cursor.execute(stmt1,wpars);
0328 rows = cursor.fetchall()
0329 i = 0
0330 for r in rows:
0331 i += 1
0332 if nmax >=0 and i>nmax:
0333 break
0334 tags[r[0]] = (r[1],r[2],r[3])
0335 logging.info( 'Processing boost version for %s tags' %len(tags))
0336 count = 0
0337 for t in sorted(tags.keys()):
0338 count += 1
0339 try:
0340 update = False
0341 cursor.execute('SELECT TIME_TYPE FROM TAG WHERE NAME= :TAG_NAME',(t,))
0342 timetype = cursor.fetchone()[0]
0343 self.iovs = None
0344 logging.info('************************************************************************')
0345 logging.info('Tag [%s] %s - timetype: %s' %(count,t,timetype))
0346 tagBoostVersion = None
0347 minIov = None
0348 timeCut = None
0349 if tags[t] is not None:
0350 update = True
0351 tagBoostVersion = tags[t][0]
0352 minIov = tags[t][1]
0353 timeCut = tags[t][2]
0354 tagBoostVersion, minIov = self.process_tag_boost_version( t, timetype, tagBoostVersion, minIov, timeCut, self.args.validate )
0355 if tagBoostVersion is None:
0356 continue
0357 logging.debug('boost versions in the %s iovs: %s' %(len(self.iovs),str(self.versionIovs)))
0358 if self.args.validate:
0359 invalid_gts = self.validate_boost_version( t, timetype, tagBoostVersion )
0360 if len(invalid_gts)>0:
0361 with open('invalid_tags_in_gts.txt','a') as error_file:
0362 for gt in invalid_gts:
0363 error_file.write('Tag %s (boost %s) is invalid for GT %s ( boost %s) \n' %(t,tagBoostVersion,gt[0],gt[1]))
0364 if len(self.iovs):
0365 if self.iovs[0][0]<minIov:
0366 minIov = self.iovs[0]
0367 self.update_tag_boost_version_in_db( t, tagBoostVersion, minIov, update )
0368 self.db.commit()
0369 except Exception as e:
0370 logging.error(str(e))
0371
0372 def insert_boost_run( self ):
0373 cursor = self.db.cursor()
0374 self.version_db = version_db( self.db )
0375 if self.args.min_ts is None:
0376 raise Exception("Run %s has not been found in the database - please provide an explicit TimeType value with the min_ts parameter ." %self.args.since )
0377 self.version_db.insert_boost_run_range( self.args.since, self.args.label, self.args.min_ts )
0378 self.db.commit()
0379 logging.info('boost version %s inserted with since %s' %(self.args.label,self.args.since))
0380
0381 def list_boost_run( self ):
0382 cursor = self.db.cursor()
0383 self.version_db = version_db( self.db )
0384 self.version_db.fetch_boost_run_map()
0385 headers = ['Run','Run start time','Boost Version','Insertion time']
0386 print_table( headers, self.version_db.boost_run_map )
0387
0388 def show_tag_boost_version( self ):
0389 cursor = self.db.cursor()
0390 tag = self.args.tag_name
0391 cursor.execute('SELECT TIME_TYPE FROM TAG WHERE NAME= :TAG_NAME',(tag,))
0392 rows = cursor.fetchall()
0393 timeType = None
0394 t_modificationTime = None
0395 for r in rows:
0396 timeType = r[0]
0397 if timeType is None:
0398 raise Exception("Tag %s does not exist in the database." %tag)
0399 cursor.execute('SELECT MAX(INSERTION_TIME) FROM IOV WHERE TAG_NAME= :TAG_NAME',(tag,))
0400 rows = cursor.fetchall()
0401 for r in rows:
0402 t_modificationTime = r[0]
0403 if t_modificationTime is None:
0404 raise Exception("Tag %s does not have any iov stored." %tag)
0405 logging.info('Tag %s - timetype: %s' %(tag,timeType))
0406 cursor.execute('SELECT MIN_SERIALIZATION_V, MIN_SINCE, MODIFICATION_TIME FROM TAG_METADATA WHERE TAG_NAME= :TAG_NAME',(tag,))
0407 rows = cursor.fetchall()
0408 tagBoostVersion = None
0409 minIov = None
0410 v_modificationTime = None
0411 for r in rows:
0412 tagBoostVersion = r[0]
0413 minIov = r[1]
0414 v_modificationTime = r[2]
0415 if v_modificationTime is not None:
0416 if t_modificationTime > v_modificationTime:
0417 logging.warning('The minimum boost version stored is out of date.')
0418 else:
0419 logging.info('The minimum boost version stored is up to date.')
0420 mt = '-'
0421 if v_modificationTime is not None:
0422 mt = str(v_modificationTime)
0423 r_tagBoostVersion = None
0424 if self.args.rebuild or self.args.full:
0425 self.version_db = version_db( self.db )
0426 self.version_db.fetch_boost_run_map()
0427 timeCut = None
0428 logging.info('Calculating minimum boost version for the available iovs...')
0429 r_tagBoostVersion, r_minIov = self.process_tag_boost_version( tag, timeType, tagBoostVersion, minIov, timeCut )
0430 print('# Currently stored: %s (min iov:%s)' %(tagBoostVersion,minIov))
0431 print('# Last update: %s' %mt)
0432 print('# Last update on the iovs: %s' %str(t_modificationTime))
0433 if self.args.rebuild or self.args.full:
0434 print('# Based on the %s available IOVs: %s (min iov:%s)' %(len(self.iovs),r_tagBoostVersion,r_minIov))
0435 if self.args.full:
0436 headers = ['Run','Boost Version']
0437 print_table( headers, self.versionIovs )
0438
0439 import optparse
0440 import argparse
0441
0442 def main():
0443 tool = conddb_tool()
0444 parser = argparse.ArgumentParser(description='CMS conddb command-line tool for serialiation metadata. For general help (manual page), use the help subcommand.')
0445 parser.add_argument('--db', type=str, help='The target database: pro ( for prod ) or dev ( for prep ). default=pro')
0446 parser.add_argument("--auth","-a", type=str, help="The path of the authentication file")
0447 parser.add_argument('--verbose', '-v', action='count', help='The verbosity level')
0448 parser_subparsers = parser.add_subparsers(title='Available subcommands')
0449 parser_update_tags = parser_subparsers.add_parser('update_tags', description='Update the existing tag headers with the boost version')
0450 parser_update_tags.add_argument('--name', '-n', type=str, help='Name of the specific tag to process (default=None - in this case all of the tags will be processed.')
0451 parser_update_tags.add_argument('--max', '-m', type=int, help='the maximum number of tags processed',default=100)
0452 parser_update_tags.add_argument('--all',action='store_true', help='process all of the tags with boost_version = None')
0453 parser_update_tags.add_argument('--validate',action='store_true', help='validate the tag/boost version under processing')
0454 parser_update_tags.set_defaults(func=tool.update_tags,accessType='w')
0455 parser_insert_boost_version = parser_subparsers.add_parser('insert', description='Insert a new boost version range in the run map')
0456 parser_insert_boost_version.add_argument('--label', '-l',type=str, help='The boost version label',required=True)
0457 parser_insert_boost_version.add_argument('--since', '-s',type=int, help='The since validity (run number)',required=True)
0458 parser_insert_boost_version.add_argument('--min_ts', '-t',type=str, help='The since validity (Time timetype)', required=False)
0459 parser_insert_boost_version.set_defaults(func=tool.insert_boost_run,accessType='w')
0460 parser_list_boost_versions = parser_subparsers.add_parser('list', description='list the boost versions in the run map')
0461 parser_list_boost_versions.set_defaults(func=tool.list_boost_run,accessType='r')
0462 parser_show_version = parser_subparsers.add_parser('show_tag', description='Display the minimum boost version for the specified tag (the value stored, by default)')
0463 parser_show_version.add_argument('tag_name',help='The name of the tag')
0464 parser_show_version.add_argument('--rebuild','-r',action='store_true',default=False,help='Re-calculate the minimum boost versio ')
0465 parser_show_version.add_argument('--full',action='store_true',default=False,help='Recalulate the minimum boost version, listing the versions in the iov sequence')
0466 parser_show_version.set_defaults(func=tool.show_tag_boost_version,accessType='r')
0467 args = parser.parse_args()
0468 tool.args = args
0469 if args.verbose is not None and args.verbose >=1:
0470 tool.logger.setLevel(logging.DEBUG)
0471 tool.connect()
0472 return args.func()
0473 else:
0474 try:
0475 tool.connect()
0476 sys.exit( args.func())
0477 except Exception as e:
0478 logging.error(e)
0479 sys.exit(1)
0480
0481 if __name__ == '__main__':
0482 main()