Skip to content

Commit

Permalink
Merge pull request cms-sw#35440 from ggovi/condcore-utilities-fix-o2o…
Browse files Browse the repository at this point in the history
…test-121X

O2O test setup modified to work across boost version changes
  • Loading branch information
cmsbuild authored Sep 28, 2021
2 parents e5ec124 + dee5cb8 commit d9b5bfd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CondCore/Utilities/interface/Payload2XMLModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ namespace py = pybind11;
.def(py::init<>()) \
.def("write", &Payload2xml<CLASS_NAME>::write);

#include <boost/version.hpp>
namespace cond {
inline std::string boost_version_label() {
std::stringstream ss;
ss << BOOST_VERSION / 100000 << ".";
ss << BOOST_VERSION / 100 % 1000 << ".";
ss << BOOST_VERSION % 100;
return ss.str();
}
} // namespace cond

namespace { // Avoid cluttering the global namespace.

template <typename PayloadType>
Expand Down
1 change: 1 addition & 0 deletions CondCore/Utilities/plugins/Module_2XML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "CondCore/Utilities/src/CondFormats.h"

PAYLOAD_2XML_MODULE(pluginUtilities_payload2xml) {
m.def("boost_version_label", &cond::boost_version_label, "Get boost version for this release");
PAYLOAD_2XML_CLASS(AlCaRecoTriggerBits);
PAYLOAD_2XML_CLASS(AlignPCLThresholds);
PAYLOAD_2XML_CLASS(AlignmentErrors);
Expand Down
4 changes: 4 additions & 0 deletions CondCore/Utilities/python/cond2xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def localLibName( payloadType ):
ptype = payloadType.replace('::','_')
return "%s_%spayload2xml" %(sanitize(ptype),prefix)

def boost_version_for_this_release():
import pluginUtilities_payload2xml as mod2XML
return mod2XML.boost_version_label()

class CondXmlProcessor(object):

def __init__(self, condDBIn):
Expand Down
31 changes: 28 additions & 3 deletions CondCore/Utilities/scripts/conddb
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,24 @@ def _get_last_frozen_since( session, tagName, fcsr=None ):
logging.debug('Last frozen since in destination tag is %s' %res)
return res

def _get_maxtime_for_boost_version( session, timeType, boost_version):
BoostRunMap = session.get_dbtype(conddb.BoostRunMap)
q = session.query(BoostRunMap).order_by(BoostRunMap.boost_version.asc())
time = (maxSince,maxSince,maxSince)
for r in q:
r= _rawdict(r)
if boost_version < r['boost_version']:
tlumi = r['run_number']<<32|0x1
time = (r['run_number'],tlumi,r['run_start_time'])
break
if timeType=='Run':
return time[0]
elif timeType=='Lumi':
return time[1]
elif timeType=='Time':
return time[2]
return None

class run_to_timestamp( object ):
def __init__( self, session ):
self.session = session
Expand Down Expand Up @@ -1833,18 +1851,25 @@ def _copy_tag(args, copyTime, session1, session2, first, second, fromIOV=None, t

logging.debug('%s iov(s) to copy with %s payload(s)' %(len(iovs),len(hashes)))
else:
maxTime = _get_maxtime_for_boost_version( session1, tag['time_type'], cond2xml.boost_version_for_this_release())
query = query.order_by(IOV1.since.desc(), IOV1.insertion_time.desc())
lastIov = None
targetIovSince = None
targetIovPayload = None
for iov in query:
iov = _rawdict(iov)
since = iov['since']
if lastIov is None:
lastIov = since
else:
if lastIov != since:
iovs[since] = iov['payload_hash']
hashes.add( iov['payload_hash'] )
break
if targetIovSince is None:
targetIovSince = since
if since < maxTime:
targetIovPayload = iov['payload_hash']
break
iovs[targetIovSince]=targetIovPayload
hashes.add(targetIovPayload)
logfun = logging.info
if len(iovs)==0:
logfun = logging.warning
Expand Down

0 comments on commit d9b5bfd

Please sign in to comment.