forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recoverRereco.py
55 lines (42 loc) · 1.62 KB
/
recoverRereco.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
import os
import sys
import subprocess
import json
import argparse
from utils import workflowInfo
def getAMsFromQuery(query):
""" Get assistance-manuals from a query """
string = """curl -X POST -H "Content-Type: application/json" -d '{{"query": "{query}"}}' tni-test.cern.ch/search/search""".format(query=query)
result = json.loads(os.popen(string).read())
return result
def main():
parser = argparse.ArgumentParser(description='Famous Submitter')
parser.add_argument("-t", "--test", action="store_true", help="Doesn't submit recoveries")
options = parser.parse_args()
url = 'cmsweb.cern.ch'
query = 'exitCode = -2 AND status = assistance-manual-recovered'
result = getAMsFromQuery(query)
wfs = list(result.keys())
stuckReRecoWfs = []
successRecoveries, failedRecoveries = [], []
for wf in wfs:
wfi = workflowInfo(url, wf)
reqType = wfi.request['RequestType']
# this only works on rereco
if reqType.lower() != 'rereco': continue
stuckReRecoWfs.append(wf)
cmd = 'python recovery.py --assign "--site original --xrootd --lumisperjob 1" --w {} --go'.format(wf)
if options.test:
print(cmd)
else:
print(cmd)
output = subprocess.check_output(cmd, shell=True).decode(sys.stdout.encoding).strip()
if "0 submitted" in output.lower():
failedRecoveries.append(wf)
else:
successRecoveries.append(wf)
break
print("successRecoveries", successRecoveries)
print("failedRecoveries", failedRecoveries)
if __name__ == "__main__":
main()