CMS 3D CMS Logo

o2o_db_cfgmap.py
Go to the documentation of this file.
1 '''
2 Update the config-to-payload map table for the fast DAQ O2O.
3 
4 @author: hqu
5 '''
6 
7 from CondTools.SiStrip.o2o_db_manager import make_dbtype, DbManager
8 import os
9 import logging
10 import sqlalchemy
11 
12 
14  __tablename__ = 'STRIP_CONFIG_TO_PAYLOAD_MAP'
15  config_hash = sqlalchemy.Column(sqlalchemy.String(2000), primary_key=True)
16  payload_hash = sqlalchemy.Column(sqlalchemy.String(2000), nullable=False)
17  payload_type = sqlalchemy.Column(sqlalchemy.String(2000), nullable=False)
18  config_string = sqlalchemy.Column(sqlalchemy.String(2000), nullable=False)
19  insertion_time = sqlalchemy.Column(sqlalchemy.TIMESTAMP, nullable=False)
20 
21 
22 class DbManagerDAQ(DbManager):
23  def __init__(self, db, authPath=None):
24  DbManager.__init__(self, db, authPath)
25  self.ConfigToPayloadMap = make_dbtype(ConfigToPayloadMapDef, self.schema)
26  if self.schema:
27  self.ConfigToPayloadMapSqlite = make_dbtype(ConfigToPayloadMapDef, schema=None)
28  else:
30 
31  def update_hashmap(self, input_path):
32  if not os.path.exists(input_path):
33  logging.info('No config-to-payload map file at %s. Skipping.' % input_path)
34  return
35  session = self.connect('sqlite:///%s' % input_path)
36  entry = session.query(self.ConfigToPayloadMapSqlite).first()
37  if entry:
38  self.check_table(ConfigToPayloadMapDef, self.ConfigToPayloadMap)
39  destSession = self.connect()
40  cfgmap = self.ConfigToPayloadMap(config_hash=entry.config_hash,
41  payload_hash=entry.payload_hash,
42  payload_type=entry.payload_type,
43  config_string=entry.config_string,
44  insertion_time=entry.insertion_time)
45  destSession.add(cfgmap)
46  destSession.commit()
47  logging.info('Updated config-to-payload map for %s' % cfgmap.payload_type)
48  logging.info('... config_hash = %s, payload_hash = %s' % (cfgmap.config_hash, cfgmap.payload_hash))
49  else:
50  raise RuntimeError('No entry found in config-to-payload map file %s' % input_path)
conddblib.make_dbtype
def make_dbtype(backendName, schemaName, baseType)
Definition: conddblib.py:182
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
o2o_db_cfgmap.DbManagerDAQ.ConfigToPayloadMapSqlite
ConfigToPayloadMapSqlite
Definition: o2o_db_cfgmap.py:27
o2o_db_cfgmap.DbManagerDAQ.__init__
def __init__(self, db, authPath=None)
Definition: o2o_db_cfgmap.py:23
dqmdumpme.first
first
Definition: dqmdumpme.py:55
o2o_db_cfgmap.DbManagerDAQ.update_hashmap
def update_hashmap(self, input_path)
Definition: o2o_db_cfgmap.py:31
o2o_db_cfgmap.DbManagerDAQ
Definition: o2o_db_cfgmap.py:22
o2o_db_cfgmap.ConfigToPayloadMapDef
Definition: o2o_db_cfgmap.py:13
o2o_db_cfgmap.DbManagerDAQ.ConfigToPayloadMap
ConfigToPayloadMap
Definition: o2o_db_cfgmap.py:25