-
Notifications
You must be signed in to change notification settings - Fork 3
/
bumpMergeRSS.py
65 lines (50 loc) · 2.04 KB
/
bumpMergeRSS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Used by the T0 team to change the MaxRSS requirements for
Merge tasks in a non-easy way, since we don't have any
APIs to change Merge job requirements
"""
from __future__ import print_function
import pickle
import sys
from WMCore.WMSpec.WMWorkload import WMWorkloadHelper
def check_current_values(workHelper):
# check current values
print('**********************************************************')
for taskPath in workHelper.listAllTaskPathNames():
task = workHelper.getTaskByPath(taskPath)
print("Task: %s has CMSSW: %s" % (task.name(), task.getSwVersion()))
print('**********************************************************')
pkl_file = str(sys.argv[1])
newMaxRSS = str(sys.argv[2])
outputWMWorkloadName = 'WMWorkload'
with open(pkl_file, "r") as configHandle:
worker = pickle.load(configHandle)
# Prints a text version of the original pkl file for verification purposes
with open('originalPKL.txt', 'w') as oldTextPklHandler:
oldTextPklHandler.write(str(worker))
workHelper = WMWorkloadHelper(worker)
print("PKL File:" + str(pkl_file))
for task in workHelper.getAllTasks():
print("Modifying: " + task.getPathName())
print("TASK")
# print (type(task._propMethodMap()['MaxRSS']))
# print (dir(task))
print("BEFORE")
print(task.data.section_("watchdog"))
# task.setMaxRSS(12000000)
task.setMaxRSS(newMaxRSS)
print("AFTER")
print((task.data.section_("watchdog"))) # Pkl the modified object
if task.taskType() == "Merge":
print("Are you sure you want to update this Merge task? I think so...")
# do it the hard way
task._setPerformanceMonitorConfig()
task.monitoring.PerformanceMonitor.maxRSS = int(newMaxRSS)
with open(pkl_file, 'wb') as pf:
pickle.dump(worker, pf)
# Prints a text version of the pkled file for verifitacion purposes
with open(pkl_file, 'r') as newPklHandler:
loadedNewPkl = pickle.load(newPklHandler)
with open('modifiedPKL.txt', 'w') as newTextPklHandler:
newTextPklHandler.write(str(loadedNewPkl))