Skip to content

Commit

Permalink
Merge pull request #10348 from mapellidario/19-10143-py2py3
Browse files Browse the repository at this point in the history
[py2py3] Migration at level scr/python/A/B/C - slice 19
  • Loading branch information
amaltaro authored Mar 15, 2021
2 parents 40c6b8d + 5c7ce72 commit 6da1b13
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""
from __future__ import division

from future.utils import viewitems

__all__ = []

import logging
Expand Down Expand Up @@ -155,7 +157,7 @@ def resetAgentSpeedDrainConfig(self):
if self.agentConfig.get("SpeedDrainMode"):
self.agentConfig['SpeedDrainMode'] = False
speedDrainConfig = self.agentConfig.get("SpeedDrainConfig")
for key, v in speedDrainConfig.items():
for key, v in viewitems(speedDrainConfig):
if key in self.validSpeedDrainConfigKeys and v['Enabled']:
speedDrainConfig[key]['Enabled'] = False

Expand All @@ -179,7 +181,7 @@ def checkSpeedDrainThresholds(self):
return []

# loop through the speed drain configuration and make a list of what thresholds have been hit
for k, v in speedDrainConfig.items():
for k, v in viewitems(speedDrainConfig):
# make sure keys in the speed drain config are valid
if k in self.validSpeedDrainConfigKeys and isinstance(v['Threshold'], int) and isinstance(v['Enabled'], bool):
# we always want to apply the condor priority change if the threshold is hit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Perform cleanup actions
"""
from __future__ import division

__all__ = []

import logging
Expand Down Expand Up @@ -201,8 +203,8 @@ def checkSlotsChanges(self, infoRC, infoSSB):
for site in set(infoRC).intersection(set(infoSSB)):
if self.tier0Mode and site.startswith('T1_'):
# T1 cores utilization for Tier0
infoSSB[site]['slotsCPU'] *= self.t1SitesCores / 100
infoSSB[site]['slotsIO'] *= self.t1SitesCores / 100
infoSSB[site]['slotsCPU'] *= self.t1SitesCores // 100
infoSSB[site]['slotsIO'] *= self.t1SitesCores // 100
else:
# round very small sites to the bare minimum
infoSSB[site]['slotsCPU'] = max(infoSSB[site]['slotsCPU'], self.minCPUSlots)
Expand Down
10 changes: 6 additions & 4 deletions src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
add them, and then add the files. This is why everything is
so convoluted.
"""
from builtins import range
from future.utils import viewvalues
from future import standard_library
standard_library.install_aliases()

Expand Down Expand Up @@ -445,7 +447,7 @@ def loadFiles(self):
fileDict = sortListByKey(loadedFiles, 'locations')

# Now add each file
for location in fileDict.keys():
for location in fileDict:

files = fileDict.get(location)

Expand Down Expand Up @@ -492,7 +494,7 @@ def checkBlockCompletion(self):
Mark Open blocks as Pending if they have timed out or their workflows have completed
"""
completedWorkflows = self.dbsUtil.getCompletedWorkflows()
for block in self.blockCache.values():
for block in viewvalues(self.blockCache):
if block.status == "Open":
if (block.getTime() > block.getMaxBlockTime()) or any(
key in completedWorkflows for key in block.workflows):
Expand Down Expand Up @@ -539,7 +541,7 @@ def getBlock(self, newFile, location, skipOpenCheck=False):
"""
datasetpath = newFile["datasetPath"]

for block in self.blockCache.values():
for block in viewvalues(self.blockCache):
if datasetpath == block.getDatasetPath() and location == block.getLocation():
if not self.isBlockOpen(newFile=newFile, block=block) and not skipOpenCheck:
# Block isn't open anymore. Mark it as pending so that it gets uploaded.
Expand Down Expand Up @@ -587,7 +589,7 @@ def inputBlocks(self):
createInDBS = []
createInDBSBuffer = []
updateInDBSBuffer = []
for block in self.blockCache.values():
for block in viewvalues(self.blockCache):
if block.getName() in self.queuedBlocks:
# Block is already being dealt with by another process. We'll
# ignore it here.
Expand Down
2 changes: 2 additions & 0 deletions src/python/WMComponent/JobArchiver/JobArchiverPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
The actual jobArchiver algorithm
"""
from __future__ import division

import logging
import os
import os.path
Expand Down
14 changes: 8 additions & 6 deletions src/python/WMComponent/JobSubmitter/JobSubmitterPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Submit jobs for execution.
"""
from __future__ import print_function, division
from builtins import range
from future.utils import viewitems

import logging
import os.path
Expand Down Expand Up @@ -206,7 +208,7 @@ def addJobsToPackage(self, loadedJob):
jobPackage[loadedJob["id"]] = loadedJob.getDataStructsJob()
batchDir = jobPackage['directory']

if len(jobPackage.keys()) == self.packageSize:
if len(jobPackage) == self.packageSize:
if not os.path.exists(batchDir):
os.makedirs(batchDir)

Expand All @@ -222,7 +224,7 @@ def flushJobPackages(self):
Write any jobs packages to disk that haven't been written out already.
"""
workflowNames = self.jobsToPackage.keys()
workflowNames = list(self.jobsToPackage)
for workflowName in workflowNames:
jobPackage = self.jobsToPackage[workflowName]["package"]
batchDir = jobPackage['directory']
Expand Down Expand Up @@ -452,7 +454,7 @@ def failJobDrain(self, timeNow, possibleLocations):
def removeAbortedForceCompletedWorkflowFromCache(self):
abortedAndForceCompleteRequests = self.abortedAndForceCompleteWorkflowCache.getData()
jobIDsToPurge = set()
for jobID, jobInfo in self.jobDataCache.iteritems():
for jobID, jobInfo in viewitems(self.jobDataCache):
if (jobInfo['request_name'] in abortedAndForceCompleteRequests) and \
(jobInfo['task_type'] not in ['LogCollect', "Cleanup"]):
jobIDsToPurge.add(jobID)
Expand Down Expand Up @@ -529,7 +531,7 @@ def getThresholds(self):

rcThresholds = self.resourceControl.listThresholdsForSubmit()

for siteName in rcThresholds.keys():
for siteName in rcThresholds:
# Add threshold if we don't have it already
state = rcThresholds[siteName]["state"]

Expand Down Expand Up @@ -736,7 +738,7 @@ def submitJobs(self, jobsToSubmit):
logging.debug("There are no packages to submit.")
return

for package in jobsToSubmit.keys():
for package in jobsToSubmit:
jobs = jobsToSubmit.get(package, [])
for job in jobs:
job['location'], job['plugin'], job['site_cms_name'] = self.getSiteInfo(job['custom']['location'])
Expand Down Expand Up @@ -774,7 +776,7 @@ def getSiteInfo(self, jobSite):
This is how you get the name of a CE and the plugin for a job
"""

if jobSite not in self.locationDict.keys():
if jobSite not in self.locationDict:
siteInfo = self.locationAction.execute(siteName=jobSite)
self.locationDict[jobSite] = siteInfo[0]
return (self.locationDict[jobSite].get('ce_name'),
Expand Down
5 changes: 3 additions & 2 deletions src/python/WMCore/WMRuntime/TaskSpace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

from builtins import object
import os
import sys
import inspect
Expand All @@ -31,7 +32,7 @@ def wrapper(self):
return x(self)
return wrapper

class TaskSpace:
class TaskSpace(object):
"""
_TaskSpace_
Expand Down Expand Up @@ -118,7 +119,7 @@ def stepSpace(self, stepName):
"""
modName = "WMTaskSpace.%s" % stepName
if modName in sys.modules.keys():
if modName in sys.modules:
space = sys.modules[modName]
else:
try:
Expand Down

0 comments on commit 6da1b13

Please sign in to comment.