Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-06 09:39:50

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