Skip to content

Commit

Permalink
Set processing version as integer
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Mar 18, 2022
1 parent 4e33708 commit cb12faa
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
13 changes: 10 additions & 3 deletions src/python/WMComponent/DBS3Buffer/DBSBufferBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,17 @@ def setProcessingVer(self, procVer):
Set the block's processing version.
"""
# compatibility statement for old style proc ver (still needed ?)
if procVer.count("-") == 1:
self.data["processing_era"]["processing_version"] = procVer.split("-v")[1]
pver = procVer
if isinstance(pver, str) or isinstance(pver, bytes):
procVer = int(pver)
elif isinstance(pver, int):
procVer = pver
elif pver == None:
procVer = 0
else:
self.data["processing_era"]["processing_version"] = procVer
msg = "Provided procVer=%s of type %s cannot be converted to int" % (procVer, type(procVer))
raise Exception(msg)
self.data["processing_era"]["processing_version"] = procVer

self.data["processing_era"]["create_by"] = "WMAgent"
self.data["processing_era"]["description"] = ""
Expand Down
12 changes: 10 additions & 2 deletions src/python/WMComponent/DBS3Buffer/DBSBufferFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,16 @@ def setProcessingVer(self, ver):
Set the era
"""

self['processingVer'] = ver
if isinstance(ver, str) or isinstance(ver, bytes):
procVer = int(ver)
elif isinstance(ver, int):
procVer = ver
elif ver == None:
procVer = 0
else:
msg = "Provided procVer=%s of type %s cannot be converted to int" % (ver, type(ver))
raise Exception(msg)
self['processingVer'] = procVer
return

def setAcquisitionEra(self, era):
Expand Down
4 changes: 0 additions & 4 deletions src/python/WMComponent/DBS3Buffer/MySQL/FindDASToUpload.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ def makeDAS(self, results):
datasetalgos = []
for result in results:

# compatibility statement for old style proc ver (still needed ?)
if result['procver'].count("-") == 1:
result['procver'] = result['procver'].split("-v")[1]

datasetalgos.append( { 'DatasetPath' : result['datasetpath'],
'AcquisitionEra' : result['acquera'],
'ProcessingVer' : result['procver'] } )
Expand Down
13 changes: 12 additions & 1 deletion src/python/WMCore/WMSpec/WMWorkload.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,14 +949,25 @@ def setProcessingVersion(self, processingVersions):
Change the processing version for all tasks in the spec and then update
all of the output LFNs and datasets to use the new processing version.
:param processingVersions: can be any data-type but it is set from StdBase
which performs the input data sanitization/type already.
"""
stepNameMapping = self.getStepMapping()

for task in self.taskIterator():
task.setProcessingVersion(processingVersions, stepChainMap=stepNameMapping)

self.updateLFNsAndDatasets()
self.data.properties.processingVersion = processingVersions
if isinstance(processingVersions, int):
procVer = processingVersions
elif isinstance(processingVersions, dict) or isinstance(processingVersions, list):
procVer = processingVersions
else:
msg = "Provided procVer=%s of type %s cannot be converted to int" \
% (processingVersions, type(processingVersions))
raise Exception(msg)
self.data.properties.processingVersion = procVer
return

def setProcessingString(self, processingStrings):
Expand Down
2 changes: 1 addition & 1 deletion test/python/WMComponent_t/DBS3Buffer_t/DBSBufferFile_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def testProperties(self):
configContent="MOREGIBBERISH")
testFileA.setDatasetPath("/Cosmics/CRUZET09-PromptReco-v1/RECO")
testFileA.setValidStatus(validStatus="VALID")
testFileA.setProcessingVer(ver="ProcVer")
testFileA.setProcessingVer(ver="123")
testFileA.setAcquisitionEra(era="AcqEra")
testFileA.setGlobalTag(globalTag="GlobalTag")
testFileA.setDatasetParent(datasetParent="Parent")
Expand Down

0 comments on commit cb12faa

Please sign in to comment.