Skip to content

Commit

Permalink
Merge pull request #12925 from hroskes/empty-validation-80X
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed Jan 15, 2016
2 parents 7c8b7a9 + 1fa54a0 commit 031c07c
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def __createSnippet( self, jsonPath = None, begin = None, end = None,
theLumiList.removeRuns( runsToRemove )
splitLumiList = list( self.__chunks(
theLumiList.getCMSSWString().split(','), 255 ) )
if not (splitLumiList and splitLumiList[0] and splitLumiList[0][0]):
splitLumiList = None
else:
with open(jsonPath) as f:
jsoncontents = f.read()
Expand All @@ -193,25 +195,32 @@ def __createSnippet( self, jsonPath = None, begin = None, end = None,
if firstRun or lastRun:
self.__firstusedrun = -1
self.__lastusedrun = -1
jsoncontents = re.sub("\d+:(\d+|max)-\d+:(\d+|max)", self.getForceRunRangeFunction(firstRun, lastRun), jsoncontents)
jsoncontents = re.sub(r"\d+:(\d+|max)(-\d+:(\d+|max))?", self.getForceRunRangeFunction(firstRun, lastRun), jsoncontents)
jsoncontents = (jsoncontents.replace("'',\n","").replace("''\n","")
.replace('"",\n','').replace('""\n',''))
self.__firstusedrun = max(self.__firstusedrun, int(self.__findInJson(runlist[0],"run_number")))
self.__lastusedrun = min(self.__lastusedrun, int(self.__findInJson(runlist[-1],"run_number")))
if self.__lastusedrun < self.__firstusedrun:
jsoncontents = None
else:
self.__firstusedrun = int(self.__findInJson(runlist[0],"run_number"))
self.__lastusedrun = int(self.__findInJson(runlist[-1],"run_number"))
lumiSecExtend = jsoncontents
splitLumiList = [[""]]

if splitLumiList and splitLumiList[0]:
if splitLumiList[0][0]:
lumiSecStr = [ "',\n'".join( lumis ) \
for lumis in splitLumiList ]
lumiSecStr = [ "lumiSecs.extend( [\n'" + lumis + "'\n] )" \
for lumis in lumiSecStr ]
lumiSecExtend = "\n".join( lumiSecStr )
runlist = self.__getRunList()
self.__firstusedrun = max(int(splitLumiList[0][0].split(":")[0]), int(self.__findInJson(runlist[0],"run_number")))
self.__lastusedrun = min(int(splitLumiList[-1][-1].split(":")[0]), int(self.__findInJson(runlist[-1],"run_number")))
splitLumiList = None
else:
raise AllInOneError("%s is not a valid json file!" % jsonPath)

if splitLumiList and splitLumiList[0] and splitLumiList[0][0]:
lumiSecStr = [ "',\n'".join( lumis ) \
for lumis in splitLumiList ]
lumiSecStr = [ "lumiSecs.extend( [\n'" + lumis + "'\n] )" \
for lumis in lumiSecStr ]
lumiSecExtend = "\n".join( lumiSecStr )
runlist = self.__getRunList()
self.__firstusedrun = max(int(splitLumiList[0][0].split(":")[0]), int(self.__findInJson(runlist[0],"run_number")))
self.__lastusedrun = min(int(splitLumiList[-1][-1].split(":")[0]), int(self.__findInJson(runlist[-1],"run_number")))
elif lumiSecExtend:
pass
else:
msg = "You are trying to run a validation without any runs! Check that:"
if firstRun or lastRun:
Expand Down Expand Up @@ -302,8 +311,12 @@ def forcerunrange(self, firstRun, lastRun, s):
s = s.group()
run1 = s.split("-")[0].split(":")[0]
lum1 = s.split("-")[0].split(":")[1]
run2 = s.split("-")[1].split(":")[0]
lum2 = s.split("-")[1].split(":")[1]
try:
run2 = s.split("-")[1].split(":")[0]
lum2 = s.split("-")[1].split(":")[1]
except IndexError:
run2 = run1
lum2 = lum1
if int(run2) < firstRun or int(run1) > lastRun:
return ""
if int(run1) < firstRun or firstRun < 0:
Expand Down

0 comments on commit 031c07c

Please sign in to comment.