forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeACDC.py
94 lines (77 loc) · 3.11 KB
/
makeACDC.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
"""
Simple creating of acdc's
Use: The workflow name and the initial task name.
It will copy all the original workflow parameters unless specified
"""
import logging
import sys
from optparse import OptionParser
from reqmgr import ReqMgrClient
logging.basicConfig(level=logging.WARNING)
import reqMgrClient as rqMgr
class Config:
def __init__(self, info):
self.requestArgs = info
self.requestNames = []
self.cert = None
self.key = None
self.assignRequests = False
self.changeSplitting = False
self.assignRequest = False
url = 'https://cmsweb.cern.ch'
testbed_url = 'https://cmsweb-testbed.cern.ch'
#url = 'https://alan-cloud1.cern.ch'
configJson = {"createRequest":{}}
config = Config(configJson)
reqMgrClient = ReqMgrClient(url, config)
def makeACDC(url, workflow, task, memory=None):
#original wf info
wf = rqMgr.Workflow(workflow)
#set up acdc stuff
if "ACDC" in wf.info["RequestString"]:
config.requestArgs["createRequest"]["RequestString"] = wf.info["RequestString"]
else:
config.requestArgs["createRequest"]["RequestString"] = "ACDC_"+ wf.info["RequestString"]
config.requestArgs["createRequest"]["PrepID"] = wf.info["PrepID"]
config.requestArgs["createRequest"]["RequestPriority"] = wf.info["RequestPriority"]
config.requestArgs["createRequest"]["OriginalRequestName"] = wf.name
config.requestArgs["createRequest"]["InitialTaskPath"] = "/%s/%s"%(wf.name, task)
config.requestArgs["createRequest"]["ACDCServer"] = "https://cmsweb.cern.ch/couchdb"
config.requestArgs["createRequest"]["ACDCDatabase"] = "acdcserver"
config.requestArgs["createRequest"]["TimePerEvent"] = wf.info["TimePerEvent"]
if memory:
config.requestArgs["createRequest"]["Memory"] = memory
else:
config.requestArgs["createRequest"]["Memory"] = wf.info["Memory"]
config.requestArgs["createRequest"]["SizePerEvent"] = wf.info["SizePerEvent"]
config.requestArgs["createRequest"]["RequestType"] = "Resubmission"
config.requestArgs["createRequest"]["Group"] = wf.info["Group"]
r = reqMgrClient.createRequest(config)
return r
def main():
#Create option parser
usage = "usage: %prog [options] [WORKFLOW] TASK"
parser = OptionParser(usage=usage)
parser.add_option("-f","--file", dest="file", default=None,
help="Text file of a list of workflows")
parser.add_option("-m","--memory", dest="memory", default=None,
help="Memory to override the original request memory")
(options, args) = parser.parse_args()
wfs = None
if len(args) == 2:
wfs = [args[0]]
task = args[1]
#list of files
elif options.file and len(args) == 1:
wfs = [l.strip() for l in open(options.file) if l.strip()]
task = args[0]
else:
parser.error("Provide the Workflow Name and the Task Name")
sys.exit(1)
for wfname in wfs:
r = makeACDC(url, wfname, task, options.memory)
print "Created:"
print r
if __name__ == '__main__':
main()