forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-relval-jobs.py
executable file
·50 lines (50 loc) · 1.47 KB
/
gen-relval-jobs.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
#!/usr/bin/env python
import sys
import json
from os import environ
from os.path import exists
from RelValArgs import GetMatrixOptions
from runPyRelValThread import PyRelValsThread, splitWorkflows
from cmsutils import doCmd
print "Diving workflows"
workdir = sys.argv[1]
RelValtimes = sys.argv[2]
print RelValtimes
try:
max_wf=int(sys.argv[3])
except:
max_wf=100
relval_args = GetMatrixOptions(environ["CMSSW_VERSION"], environ["SCRAM_ARCH"])
matrix = PyRelValsThread(1,environ["CMSSW_BASE"])
workflows = matrix.getWorkFlows(relval_args)
if exists(RelValtimes):
owf = []
max_tm=0
with open(RelValtimes) as json_file:
try: json_data = json.load(json_file)
except:
print "Error reading RelVal Times"
json_data={"avg": []}
for tm_str in sorted(json_data["avg"],key=int, reverse=True):
tm=int(tm_str)
if tm > max_tm : max_tm=tm
for wf in json_data["avg"][tm_str]:
if wf in workflows: owf.append([wf,tm])
uwf = []
owfs = [ x[0] for x in owf ]
for wf in workflows:
if not wf in owfs: uwf.append([wf,max_tm])
workflows = uwf + owf
if workflows:
workflows = splitWorkflows(workflows, max_wf)
print workflows
total = len(workflows)
try:
for i in range(1, total+1):
wf=",".join(workflows[i-1])
jobid = str(i)+"of"+str(total)
jobfile = workdir+"/ib-run-relval-"+jobid
doCmd("echo WORKFLOWS="+wf+" >"+jobfile)
doCmd("echo JOBID="+jobid+" >>"+jobfile)
except Exception as e:
print "Error " , e