ATLAS Offline Software
Functions | Variables
python.IOVDbSvcConfig Namespace Reference

Functions

def CondInputLoaderCfg (flags, **kwargs)
 
def IOVDbSvcCfg (flags, **kwargs)
 
def addFolders (flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
 
def addFolderList (flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
 
def addFoldersSplitOnline (flags, detDb, onlineFolders, offlineFolders, className=None, extensible=False, addMCString='_OFL', splitMC=False, tag=None, forceDb=None, modifiers='')
 
def addOverride (flags, folder, tag, db=None)
 
def _extractFolder (folderString)
 
def getSqliteContent (sqliteInput, takeFolders, databaseInstance)
 

Variables

 msg = logging.getLogger('IOVDbSvcCfg')
 
dictionary _dblist
 
 flags = initConfigFlags()
 
 Files
 
def acc = IOVDbSvcCfg(flags)
 

Function Documentation

◆ _extractFolder()

def python.IOVDbSvcConfig._extractFolder (   folderString)
private
Extract the folder name (non-XML text) from a IOVDbSvc.Folders entry

Definition at line 232 of file IOVDbSvcConfig.py.

232 def _extractFolder(folderString):
233  """Extract the folder name (non-XML text) from a IOVDbSvc.Folders entry"""
234  folderName = ''
235  xmlTag = ''
236  ix = 0
237  while ix < len(folderString):
238  if (folderString[ix] == '<' and xmlTag == ''):
239  ix2 = folderString.find('>', ix)
240  if ix2 != -1:
241  xmlTag = folderString[ix + 1 : ix2].strip()
242  ix = ix2 + 1
243  elif folderString[ix:ix+2] == '</' and xmlTag != '':
244  ix2 = folderString.find('>', ix)
245  if ix2 != -1:
246  xmlTag = ''
247  ix = ix2 + 1
248  else:
249  ix2 = folderString.find('<', ix)
250  if ix2 == -1:
251  ix2 = len(folderString)
252  if xmlTag == '':
253  folderName = folderName + folderString[ix : ix2]
254  ix = ix2
255  return folderName.strip()
256 
257 
258 @cache #Fill only once

◆ addFolderList()

def python.IOVDbSvcConfig.addFolderList (   flags,
  listOfFolderInfoTuple,
  extensible = False,
  db = None,
  modifiers = '' 
)
Add access to the given set of folders, in the identified subdetector schema.
FolerInfoTuple consists of (foldername,detDB,classname)

If EXTENSIBLE is set, then if we access an open-ended IOV at the end of the list,
the end time for this range will be set to just past the current event.
Subsequent accesses will update this end time for subsequent events.
This allows the possibility of later adding a new IOV using IOVSvc::setRange.

Definition at line 90 of file IOVDbSvcConfig.py.

90 def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers=''):
91  """Add access to the given set of folders, in the identified subdetector schema.
92  FolerInfoTuple consists of (foldername,detDB,classname)
93 
94  If EXTENSIBLE is set, then if we access an open-ended IOV at the end of the list,
95  the end time for this range will be set to just past the current event.
96  Subsequent accesses will update this end time for subsequent events.
97  This allows the possibility of later adding a new IOV using IOVSvc::setRange."""
98  loadFolders = set()
99  folders = []
100  sqliteFolders=getSqliteContent(flags.IOVDb.SqliteInput,
101  flags.IOVDb.SqliteFolders,
102  flags.IOVDb.DatabaseInstance)
103 
104  for (fs, detDb, className) in listOfFolderInfoTuple:
105  fse= _extractFolder(fs)
106  # Add class-name to CondInputLoader (if reqired)
107  if className is not None:
108  loadFolders.add((className, fse))
109 
110  if fse in sqliteFolders:
111  msg.warning(f'Reading folder {fs} from sqlite, bypassing production database')
112  fs+=sqliteFolders[fse]
113  elif detDb is not None and fs.find('<db>') == -1:
114 
115  if db: # override database name if provided
116  dbName=db
117  else:
118  dbName = flags.IOVDb.DatabaseInstance
119  if detDb in _dblist.keys():
120  fs = f'<db>{_dblist[detDb]}/{dbName}</db> {fs}'
121  elif os.access(detDb, os.R_OK):
122  # Assume slqite file
123  fs = f'<db>sqlite://;schema={detDb};dbname={dbName}</db> {fs}'
124  else:
125  raise ConfigurationError(f'Error, db shorthand {detDb} not known, nor found as sqlite file')
126  # Append database string to folder-name
127 
128  if extensible:
129  fs = fs + '<extensible/>'
130 
131  # Add explicitly given xml-modifiers (like channel-selection)
132  fs += modifiers
133 
134  # Append (modified) folder-name string to IOVDbSvc Folders property
135  folders.append(fs)
136 
137 
138  result = IOVDbSvcCfg(flags)
139  result.getPrimary().Folders+=folders
140  if loadFolders:
141  result.getCondAlgo('CondInputLoader').Load |= loadFolders
142 
143  if flags.IOVDb.CleanerRingSize > 0:
144  #HLT-jobs set IOVDb.CleanerRingSize to 0 to run without the cleaning-service,
145  cleanerSvc = CompFactory.Athena.DelayedConditionsCleanerSvc(RingSize=flags.IOVDb.CleanerRingSize)
146  result.addService(cleanerSvc)
147  result.addService(CompFactory.Athena.ConditionsCleanerSvc(CleanerSvc=cleanerSvc))
148 
149 
150  return result
151 
152 

◆ addFolders()

def python.IOVDbSvcConfig.addFolders (   flags,
  folderStrings,
  detDb = None,
  className = None,
  extensible = False,
  tag = None,
  db = None,
  modifiers = '' 
)

Definition at line 72 of file IOVDbSvcConfig.py.

72 def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers=''):
73  tagString = ''
74  if tag is not None:
75  tagString = '<tag>%s</tag>' % tag
76 
77  # Convenience hack: Allow a single string as parameter:
78  if isinstance(folderStrings, str):
79  return addFolderList(flags, ((folderStrings + tagString, detDb, className),), extensible, db, modifiers)
80 
81  else: # Got a list of folders
82  folderDefinitions = []
83 
84  for folderString in folderStrings:
85  folderDefinitions.append((folderString + tagString, detDb, className))
86 
87  return addFolderList(flags, folderDefinitions, extensible, db, modifiers)
88 
89 

◆ addFoldersSplitOnline()

def python.IOVDbSvcConfig.addFoldersSplitOnline (   flags,
  detDb,
  onlineFolders,
  offlineFolders,
  className = None,
  extensible = False,
  addMCString = '_OFL',
  splitMC = False,
  tag = None,
  forceDb = None,
  modifiers = '' 
)
Add access to given folder, using either online_folder  or offline_folder. For MC, add addMCString as a postfix (default is _OFL)

Definition at line 153 of file IOVDbSvcConfig.py.

153 def addFoldersSplitOnline(flags, detDb, onlineFolders, offlineFolders, className=None, extensible=False, addMCString='_OFL', splitMC=False, tag=None, forceDb=None, modifiers=''):
154  """Add access to given folder, using either online_folder or offline_folder. For MC, add addMCString as a postfix (default is _OFL)"""
155 
156  if flags.Common.isOnline and not flags.Input.isMC:
157  folders = onlineFolders
158  elif splitMC and not flags.Input.isMC:
159  folders = onlineFolders
160  else:
161  # MC, so add addMCString
162  detDb = detDb + addMCString
163  folders = offlineFolders
164 
165  return addFolders(flags, folders, detDb, className, extensible, tag=tag, db=forceDb, modifiers=modifiers)
166 
167 

◆ addOverride()

def python.IOVDbSvcConfig.addOverride (   flags,
  folder,
  tag,
  db = None 
)
Add a tag override for the specified folder

Definition at line 224 of file IOVDbSvcConfig.py.

224 def addOverride(flags, folder, tag, db=None):
225  """Add a tag override for the specified folder"""
226  suffix = ''
227  if db:
228  suffix = f' <db>{db}</db>'
229  return IOVDbSvcCfg(flags, overrideTags=(f'<prefix>{folder}</prefix> <tag>{tag}</tag>{suffix}',))
230 
231 

◆ CondInputLoaderCfg()

def python.IOVDbSvcConfig.CondInputLoaderCfg (   flags,
**  kwargs 
)

Definition at line 12 of file IOVDbSvcConfig.py.

12 def CondInputLoaderCfg(flags, **kwargs):
13  result = ComponentAccumulator()
14  result.addCondAlgo(CompFactory.CondInputLoader(**kwargs))
15  return result
16 
17 
18 @AccumulatorCache

◆ getSqliteContent()

def python.IOVDbSvcConfig.getSqliteContent (   sqliteInput,
  takeFolders,
  databaseInstance 
)

Definition at line 259 of file IOVDbSvcConfig.py.

259 def getSqliteContent(sqliteInput,takeFolders,databaseInstance):
260  if sqliteInput == "": return []
261  sqliteFolders=dict()
262  if isinstance(takeFolders, str):
263  takeFolders=[takeFolders,]
264  dbStr="sqlite://;schema="+ sqliteInput+";dbname="+databaseInstance
265  from PyCool import cool
266  dbSvc = cool.DatabaseSvcFactory.databaseService()
267  db = dbSvc.openDatabase(dbStr)
268  nodelist=db.listAllNodes()
269  for node in nodelist:
270  if db.existsFolder(node):
271  if (len(takeFolders)>0 and str(node) not in takeFolders): continue
272  connStr="<db>"+dbStr+"</db>"
273  f=db.getFolder(node)
274  if f.versioningMode is not cool.FolderVersioning.SINGLE_VERSION:
275  tags=f.listTags()
276  if len(tags)==1:
277  connStr+="<tag>"+tags[0]+"</tag>"
278  sqliteFolders[str(node)]=connStr
279  db.closeDatabase()
280 
281  if len(takeFolders)>0:
282  missedFolders=set(takeFolders)-set(sqliteFolders.keys())
283  if len(missedFolders):
284  msg.error("The following folders were requested via the flag IOVSvc.sqliteFolder but not found in the sqlite file %s",(sqliteInput))
285  for f in missedFolders:
286  msg.error(f)
287 
288  msg.info("The following folders/tags are read from sqlite:")
289  for v in sqliteFolders.items():
290  msg.info("\t"+str(v))
291  return sqliteFolders
292 
293 

◆ IOVDbSvcCfg()

def python.IOVDbSvcConfig.IOVDbSvcCfg (   flags,
**  kwargs 
)

Definition at line 19 of file IOVDbSvcConfig.py.

19 def IOVDbSvcCfg(flags, **kwargs):
20  # Add the conditions loader, must be the first in the sequence
21  result = CondInputLoaderCfg(flags)
22 
23  kwargs.setdefault('OnlineMode', flags.Common.isOnline)
24  kwargs.setdefault('dbConnection', flags.IOVDb.DBConnection)
25  kwargs.setdefault('crestServer', flags.IOVDb.CrestServer)
26  # setup knowledge of dbinstance in IOVDbSvc, for global tag x-check
27  kwargs.setdefault('DBInstance', flags.IOVDb.DatabaseInstance)
28 
29  if 'FRONTIER_SERVER' in os.environ.keys() and os.environ['FRONTIER_SERVER'] != '':
30  kwargs.setdefault('CacheAlign', 3)
31 
32  # Very important cache settings for use of CoralProxy at P1 (ATR-4646)
33  if flags.Common.isOnline and flags.Trigger.Online.isPartition:
34  kwargs['CacheAlign'] = 0
35  kwargs['CacheRun'] = 0
36  kwargs['CacheTime'] = 0
37 
38  kwargs.setdefault('GlobalTag', flags.IOVDb.GlobalTag)
39  if 'Folders' in kwargs:
40  kwargs['Folders'] = ['/TagInfo<metaOnly/>'] + kwargs['Folders']
41  else:
42  kwargs.setdefault('Folders', ['/TagInfo<metaOnly/>'])
43 
44  # Select CREST backend if needed
45  if flags.IOVDb.GlobalTag and flags.IOVDb.GlobalTag.startswith('CREST-'):
46  kwargs.setdefault('Source', 'CREST')
47 
48  result.addService(CompFactory.IOVDbSvc(**kwargs), primary=True)
49 
50  # Set up POOLSvc with appropriate catalogs
51  from AthenaPoolCnvSvc.PoolCommonConfig import PoolSvcCfg, AthenaPoolCnvSvcCfg
52  result.merge(PoolSvcCfg(flags, withCatalogs=True))
53  result.merge(AthenaPoolCnvSvcCfg(flags))
54  result.addService(CompFactory.CondSvc())
55  result.addService(CompFactory.ProxyProviderSvc(ProviderNames=['IOVDbSvc']))
56 
57  if not flags.Input.isMC:
58  result.addService(CompFactory.DBReplicaSvc(COOLSQLiteVetoPattern='/DBRelease/'))
59 
60  # Get TagInfoMgr
61  from EventInfoMgt.TagInfoMgrConfig import TagInfoMgrCfg
62  result.merge(TagInfoMgrCfg(flags))
63 
64  # Set up MetaDataSvc
65  from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg
66  result.merge(MetaDataSvcCfg(flags, ['IOVDbMetaDataTool']))
67 
68  return result
69 
70 
71 # Convenience method to add folders:

Variable Documentation

◆ _dblist

dictionary python.IOVDbSvcConfig._dblist
private

Definition at line 168 of file IOVDbSvcConfig.py.

◆ acc

def python.IOVDbSvcConfig.acc = IOVDbSvcCfg(flags)

Definition at line 301 of file IOVDbSvcConfig.py.

◆ Files

python.IOVDbSvcConfig.Files

Definition at line 298 of file IOVDbSvcConfig.py.

◆ flags

python.IOVDbSvcConfig.flags = initConfigFlags()

Definition at line 297 of file IOVDbSvcConfig.py.

◆ msg

python.IOVDbSvcConfig.msg = logging.getLogger('IOVDbSvcCfg')

Definition at line 10 of file IOVDbSvcConfig.py.

python.IOVDbSvcConfig.CondInputLoaderCfg
def CondInputLoaderCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:12
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.IOVDbSvcConfig.addFolderList
def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:90
python.TagInfoMgrConfig.TagInfoMgrCfg
def TagInfoMgrCfg(flags, tagValuePairs={})
Definition: TagInfoMgrConfig.py:6
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, db=None)
Definition: IOVDbSvcConfig.py:224
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
python.IOVDbSvcConfig.IOVDbSvcCfg
def IOVDbSvcCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:19
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.PoolCommonConfig.PoolSvcCfg
def PoolSvcCfg(flags, withCatalogs=False, **kwargs)
Definition: PoolCommonConfig.py:7
python.PoolCommonConfig.AthenaPoolCnvSvcCfg
def AthenaPoolCnvSvcCfg(flags, **kwargs)
Definition: PoolCommonConfig.py:29
python.IOVDbSvcConfig.addFoldersSplitOnline
def addFoldersSplitOnline(flags, detDb, onlineFolders, offlineFolders, className=None, extensible=False, addMCString='_OFL', splitMC=False, tag=None, forceDb=None, modifiers='')
Definition: IOVDbSvcConfig.py:153
python.IOVDbSvcConfig._extractFolder
def _extractFolder(folderString)
Definition: IOVDbSvcConfig.py:232
python.MetaDataSvcConfig.MetaDataSvcCfg
def MetaDataSvcCfg(flags, toolNames=[], tools=[])
Definition: MetaDataSvcConfig.py:6
str
Definition: BTagTrackIpAccessor.cxx:11
python.IOVDbSvcConfig.getSqliteContent
def getSqliteContent(sqliteInput, takeFolders, databaseInstance)
Definition: IOVDbSvcConfig.py:259