Skip to content

Commit

Permalink
Update logging messages and their level
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaresToine committed Mar 29, 2024
1 parent 8b852b3 commit e78f7b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
31 changes: 15 additions & 16 deletions src/python/WMComponent/RetryManager/Modifier/MemoryModifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"""
_MemoryModifier_
config.RetryManager.modifiers = {50660: 'MemoryModifier'}
config.RetryManager.section_('MemoryModifier')
config.RetryManager.MemoryModifier.section_('default')
config.RetryManager.MemoryModifier.default.maxMemory = 2000 # Memory/cpu in MB
config.RetryManager.MemoryModifier.default.settings = {'requiresModify': False, 'addMemoryPerCore': 200, 'maxMemoryPerCore': 2000}
config.RetryManager.MemoryModifier.section_('Processing')
config.RetryManager.MemoryModifier.Processing.settings = {'requiresModify': True, 'addMemoryPerCore': 200, 'maxMemoryPerCore': 2500}
config.RetryManager.MemoryModifier.section_('merge')
config.RetryManager.MemoryModifier.merge.maxMemory = 3000 # Memory/cpu in MB
config.RetryManager.MemoryModifier.merge.settings = {'requiresModify': True, 'multiplyMemoryPerCore': 1.2, 'maxMemoryPerCore': 3000}
"""

import pickle
Expand Down Expand Up @@ -40,7 +43,7 @@ def changeJobPkl(self, pklFile, jobPKL, newMemory):
Modifies the pklFile job.pkl by changing the estimatedMemoryUsage to a new_memory value
"""
logging.info('MemoryModifier.changeJobPkl: Modifying {} job memory. Previous value: {}. New value: {}'.format(jobPKL['jobType'], jobPKL['estimatedMemoryUsage'], newMemory))
logging.info('MemoryModifier modifying %s job pkl file. Previous value: %d. New value: %d', jobPKL['jobType'], jobPKL['estimatedMemoryUsage'], newMemory)
jobPKL['estimatedMemoryUsage'] = newMemory
self.savePKL(pklFile, jobPKL)

Expand All @@ -50,18 +53,16 @@ def checkNewJobPkl(pklFile):
print (data['estimatedMemoryUsage'])

def getNewMemory(self, jobPKL, settings):
maxMemPerCore = settings['maxMemory']
maxMemPerCore = settings['maxMemoryPerCore']
currentMem = jobPKL['estimatedMemoryUsage']
currentMemPerCore = currentMem/jobPKL['numberOfCores']

if 'multiplyMemory' in settings:
newMemPerCore = currentMemPerCore * settings['multiplyMemory']
elif 'addMemory' in settings:
newMemPerCore = currentMemPerCore + settings['addMemory']
if 'multiplyMemoryPerCore' in settings:
newMemPerCore = currentMemPerCore * settings['multiplyMemoryPerCore']
elif 'addMemoryPerCore' in settings:
newMemPerCore = currentMemPerCore + settings['addMemoryPerCore']
else:
newMemPerCore = currentMemPerCore
logging.info('No increment values were given in the MemoryModifier parameter')
logging.info('No memory modification performed')

if newMemPerCore > maxMemPerCore:
newMemPerCore = maxMemPerCore
Expand All @@ -86,19 +87,17 @@ def modifyJob(self, job):
try:
settings = self.getModifierParam(job['jobType'], 'settings')
except:
logging.exception('Error while getting the MemoryModifier settings parameter. Not modifying memory')
logging.debug('MemoryModifier did not get settings parameter for job type %s. Not modifying memory', job['jobType'])
return

if not 'requiresModify' in settings:
logging.info('requiresModify not specified')
logging.info('Not performing any modifications')
logging.debug('MemoryModifer for job type %s does not specify requiresModify. Not modifying memory',job['jobType'])
return

elif not settings['requiresModify']:
logging.info('requiresModify set to False')
logging.info('Not performing any modifications')
logging.debug('MemoryModifyer for job type %s has requiresModify set to False. Not modifying memory', job['jobType'])
return

else:
logging.info('Modifying memory for job %d', job['id'])
logging.info('MemoryModifier modifying memory for job %d of job type %s', job['id'], job['jobType'])
self.changeMemory(job, settings)
8 changes: 4 additions & 4 deletions src/python/WMComponent/RetryManager/RetryManagerPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,18 @@ def selectJobModifier(self, jobList):
if len(jobList) == 0:
return result

for job in jobList:
exitCode = self.getJobExitCode(job) #Can and should this be setup differently? Something similar to such function may exist already
for job in jobList:
try:
exitCode = self.getJobExitCode(job)
if exitCode in self.typeModifierAssoc:
modifierName = self.typeModifierAssoc[exitCode]
modifier = self.modifiers[modifierName]
modifier.modifyJob(job=job)

logging.debug('job %d of job type %s was modified with the %s. Job %d now proceeds to retry', job['id'], job['jobType'], modifierName, job['id'])
result.append(job)

except Exception as ex:
msg = "Exception while checking the failure type for job %i\n" % job['id']
msg = "Exception while checking the exit code for job %i\n" % job['id']
msg += str(ex)
logging.error(msg)
logging.debug("Job: %s\n", job)
Expand Down

0 comments on commit e78f7b3

Please sign in to comment.