CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
conddb_serialization_metadata Namespace Reference

Functions

def boost_version_to_int
 
def check_cmssw_version
 
def cmp_boost_version
 
def cmp_cmssw_version
 
def cmssw_version_to_int
 
def do_update_tag_boost_version
 
def get_boost_version_from_streamer_info
 
def get_cmssw_boost
 
def get_production_arch
 
def get_release_root
 
def is_release_cycle
 
def lookup_boost_for_run
 
def strip_boost_version
 
def strip_cmssw_version
 
def update_tag_boost_version
 

Variables

string __author__ = 'Giacomo Govi'
 
dictionary archs
 
string cmsPath = '/cvmfs/cms.cern.ch'
 

Function Documentation

def conddb_serialization_metadata.boost_version_to_int (   boost_version)

Definition at line 65 of file conddb_serialization_metadata.py.

References strip_boost_version().

Referenced by cmp_boost_version().

65 
66 def boost_version_to_int( boost_version ):
67  bver = strip_boost_version( boost_version )
68  dgs = bver.split('.')
69  tmpl = '%d%02d%02d'
70  pars = [0,0,0]
71  ind = 0
72  for d in dgs:
73  if ind <=2:
74  pars[ind] = int(d)
75  ind += 1
76  return int(tmpl %(pars[0],pars[1],pars[2]))
def conddb_serialization_metadata.check_cmssw_version (   cmssw_version)

Definition at line 10 of file conddb_serialization_metadata.py.

10 
11 def check_cmssw_version( cmssw_version ):
12  if cmssw_version.find('CMSSW_')==-1:
13  raise Exception("CMSSW version '%s' has not been found in the expected format" %cmssw_version)
14  ver = cmssw_version
15  p = re.compile('(CMSSW_.*_X)(_.*)?$')
16  m = p.match(ver)
17  if not m is None:
18  gs = m.groups()
19  if gs[1] != None:
20  raise Exception("IB version can't be processed.")
21  return ver
def conddb_serialization_metadata.cmp_boost_version (   ver1,
  ver2 
)

Definition at line 77 of file conddb_serialization_metadata.py.

References boost_version_to_int().

Referenced by do_update_tag_boost_version().

77 
78 def cmp_boost_version( ver1, ver2 ):
79  intVer1 = boost_version_to_int(ver1)
80  intVer2 = boost_version_to_int(ver2)
81  if intVer1<intVer2:
82  return -1
83  elif intVer1>intVer2:
84  return 1
85  else:
86  return 0
def conddb_serialization_metadata.cmp_cmssw_version (   ver1,
  ver2 
)

Definition at line 45 of file conddb_serialization_metadata.py.

References cmssw_version_to_int().

45 
46 def cmp_cmssw_version( ver1, ver2 ):
47  intVer1 = cmssw_version_to_int(ver1)
48  intVer2 = cmssw_version_to_int(ver2)
49  if intVer1<intVer2:
50  return -1
51  elif intVer1>intVer2:
52  return 1
53  else:
54  return 0
def conddb_serialization_metadata.cmssw_version_to_int (   cmssw_version)

Definition at line 35 of file conddb_serialization_metadata.py.

Referenced by cmp_cmssw_version(), and get_production_arch().

35 
36 def cmssw_version_to_int( cmssw_version ):
37  ver = cmssw_version.split('CMSSW_')[1]
38  ip = 0
39  f = ver.find('_patch')
40  if not f == -1:
41  ip = int(ver[f+6:])
42  ver = ver[0:f]
43  dgs = ver.split('_')
44  return int('%d%02d%02d%02d' %(int(dgs[0]),int(dgs[1]),int(dgs[2]),ip))
def conddb_serialization_metadata.do_update_tag_boost_version (   tagBoostVersion,
  minIov,
  iovBoostVersion,
  iov,
  timetype,
  boost_run_map 
)

Definition at line 158 of file conddb_serialization_metadata.py.

References cmp_boost_version(), and lookup_boost_for_run().

Referenced by update_tag_boost_version().

159 def do_update_tag_boost_version( tagBoostVersion, minIov, iovBoostVersion, iov, timetype, boost_run_map ):
160  # for hash timetype we need to take the greatest version of the set
161  if timetype == 'Hash':
162  if tagBoostVersion is None or cmp_boost_version(tagBoostVersion,iovBoostVersion)<0:
163  tagBoostVersion = iovBoostVersion
164  # for run, lumi and time we lookup in the boost_run_map to find the reference
165  else:
166  if tagBoostVersion is None:
167  tagBoostVersion = iovBoostVersion
168  else:
169  iovRefBoost = lookup_boost_for_run( iov, timetype, boost_run_map )
170  # the case when the iov does not follow the standard run history
171  if cmp_boost_version( iovRefBoost, iovBoostVersion )<0:
172  if cmp_boost_version( tagBoostVersion, iovBoostVersion )<0:
173  tagBoostVersion = iovBoostVersion
174  # iov in agreement witjh the standard run history
175  else:
176  tagRefBoost = lookup_boost_for_run( minIov, timetype, boost_run_map )
177  # also the current tag follows the standard run history
178  if cmp_boost_version( tagRefBoost, tagBoostVersion )>=0:
179  # in this case the min boost version should decrease to
180  if cmp_boost_version( tagBoostVersion, iovRefBoost )>0:
181  tagBoostVersion = iovRefBoost
182  return tagBoostVersion
def conddb_serialization_metadata.get_boost_version_from_streamer_info (   s_info)

Definition at line 144 of file conddb_serialization_metadata.py.

References str, and strip_boost_version().

Referenced by update_tag_boost_version().

146  streamer_info = s_info.decode()
147  streamer_info = streamer_info.replace('\x00','')
148  iovBoostVersion = None
149  if streamer_info == '0':
150  iovBoostVersion = '1.51.0'
151  else:
152  try:
153  iovBoostVersion = str(json.loads(streamer_info)['tech_version'])
154  iovBoostVersion = strip_boost_version(iovBoostVersion)
155  except ValueError as e:
156  raise Exception("Could not parse streamer info [%s]: %s" %(streamer_info,str(e)))
157  return iovBoostVersion
#define str(s)
def conddb_serialization_metadata.get_cmssw_boost (   arch,
  releaseDir 
)

Definition at line 112 of file conddb_serialization_metadata.py.

References digitizers_cfi.strip, and strip_boost_version().

113 def get_cmssw_boost( arch, releaseDir ):
114  cmd = 'source %s/cmsset_default.sh; export SCRAM_ARCH=%s; cd %s/src ; eval `scram runtime -sh`; scram tool info boost; ' %(cmsPath,arch,releaseDir)
115  pipe = subprocess.Popen( cmd, shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
116  out = pipe.communicate()[0]
117  cfgLines = out.split('\n')
118  boost_version = None
119  for line in cfgLines:
120  if line.startswith('Version'):
121  boost_version = line.split('Version :')[1].strip()
122  break
123  if not boost_version is None:
124  boost_version = strip_boost_version(boost_version)
125  return boost_version
def conddb_serialization_metadata.get_production_arch (   version)

Definition at line 93 of file conddb_serialization_metadata.py.

References cmssw_version_to_int().

93 
94 def get_production_arch( version ):
95  nv = cmssw_version_to_int( version )
96  rbound = None
97  for r in sorted(archs.keys()):
98  if r <= nv:
99  rbound = r
100  else:
101  break
102  if not rbound is None:
103  return archs[rbound]
104  return None
def conddb_serialization_metadata.get_release_root (   cmssw_version,
  arch 
)

Definition at line 105 of file conddb_serialization_metadata.py.

106 def get_release_root( cmssw_version, arch ):
107  cmssw_folder = 'cmssw'
108  if cmssw_version.find('_patch') != -1:
109  cmssw_folder= 'cmssw-patch'
110  ret = '%s/%s/cms/%s' %(cmsPath,arch,cmssw_folder)
111  return ret
def conddb_serialization_metadata.is_release_cycle (   cmssw_version)

Definition at line 22 of file conddb_serialization_metadata.py.

22 
23 def is_release_cycle( cmssw_version ):
24  ind = cmssw_version.find('_X')
25  return not ind == -1
def conddb_serialization_metadata.lookup_boost_for_run (   iov,
  timeType,
  boost_run_map 
)

Definition at line 126 of file conddb_serialization_metadata.py.

References SiStripPI.max.

Referenced by do_update_tag_boost_version().

127 def lookup_boost_for_run( iov, timeType, boost_run_map ):
128  if timeType == 'Lumi':
129  iov = iov >> 32
130  timeType = 'Run'
131  if iov == 0:
132  iov=1
133  entry = None
134  try:
135  if timeType == 'Time':
136  entry = max([x for x in boost_run_map if x[1]<=iov])
137  elif timeType == 'Run':
138  entry = max([x for x in boost_run_map if x[0]<=iov])
139  else:
140  raise Exception('TimeType %s cannot be processed' %timeType)
141  except Exception as e:
142  raise e
143  return entry[2]
def conddb_serialization_metadata.strip_boost_version (   boost_version)

Definition at line 55 of file conddb_serialization_metadata.py.

Referenced by boost_version_to_int(), get_boost_version_from_streamer_info(), and get_cmssw_boost().

55 
56 def strip_boost_version( boost_version ):
57  bver = boost_version
58  f = bver.find('_')
59  if not f==-1:
60  bver = boost_version.replace('_','.')
61  f = bver.find('-')
62  if not f==-1:
63  bver = bver[0:f]
64  return bver
def conddb_serialization_metadata.strip_cmssw_version (   cmssw_version)

Definition at line 26 of file conddb_serialization_metadata.py.

26 
27 def strip_cmssw_version( cmssw_version ):
28  ver = cmssw_version
29  if not cmssw_version.find('_X') == -1:
30  ver = ver.replace('X','0')
31  ind = ver.find('_pre')
32  if not ind == -1:
33  ver = ver[0:ind]
34  return ver
def conddb_serialization_metadata.update_tag_boost_version (   tagBoostVersion,
  minIov,
  streamer_info,
  iov,
  timetype,
  boost_run_map 
)

Definition at line 183 of file conddb_serialization_metadata.py.

References do_update_tag_boost_version(), and get_boost_version_from_streamer_info().

184 def update_tag_boost_version( tagBoostVersion, minIov, streamer_info, iov, timetype, boost_run_map ):
185  iovBoostVersion = get_boost_version_from_streamer_info( streamer_info )
186  return iovBoostVersion, do_update_tag_boost_version( tagBoostVersion, minIov, iovBoostVersion, iov, timetype, boost_run_map )
187 
188 

Variable Documentation

string conddb_serialization_metadata.__author__ = 'Giacomo Govi'

Definition at line 1 of file conddb_serialization_metadata.py.

dictionary conddb_serialization_metadata.archs
Initial value:
1 = { 3070000 : ['slc5_amd64_gcc434'], 5010100 : ['slc5_amd64_gcc462'], 6000000 : ['slc6_amd64_gcc472'],
2  7000000 : ['slc6_amd64_gcc481'], 7020000 : ['slc6_amd64_gcc491'], 7060000 : ['slc6_amd64_gcc493'],
3  8000000 : ['slc6_amd64_gcc493','slc6_amd64_gcc530'], 9030000 : ['slc6_amd64_gcc630']}

Definition at line 87 of file conddb_serialization_metadata.py.

string conddb_serialization_metadata.cmsPath = '/cvmfs/cms.cern.ch'

Definition at line 91 of file conddb_serialization_metadata.py.