-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem_summary.py
More file actions
executable file
·60 lines (51 loc) · 1.76 KB
/
problem_summary.py
File metadata and controls
executable file
·60 lines (51 loc) · 1.76 KB
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
#!/usr/bin/env python
#
# This script is a convenience for printing the count of each
# problem type in a given workflow. Run like this:
#
# ./problem_summary.py recon_2018-01_ver02_batch04
#
#
import os
import sys
import subprocess
if len(sys.argv) < 2:
print('\nUsage:\n problem_summary.py workflow\n\n')
print('workflow is the swif2 workflow. See a list with swif2 list\n')
sys.exit(0)
workflow = sys.argv[1]
# Get list of problem jobs
lines = subprocess.Popen(['swif2', 'status', '-workflow', workflow], stdout=subprocess.PIPE).communicate()[0]
#print(lines)
for line in lines.split('\n'):
toks = line.split()
if len(toks)<3: continue
key = toks[0]
vals = toks[2:]
if key == 'jobs' : Njobs = vals[0]
if key == 'dispatched' : Ndispatched = vals[0]
if key == 'succeeded' : Nsucceeded = vals[0]
if key == 'problems' : Nproblems = vals[0]
if key == 'problem_types' : problems = vals[0].split(',')
# Find count of each problem type
Nprobs = {}
lines = subprocess.Popen(['swif2', 'status', '-workflow', workflow, '-problems'], stdout=subprocess.PIPE).communicate()[0]
for line in lines.split('\n'):
for problem in problems:
if problem in line:
if not problem in Nprobs.keys(): Nprobs[problem] = 0
Nprobs[problem] += 1
# Print the summary
print('=======================================================')
print(' workflow: ' + workflow)
print(' Njobs: ' + str(Njobs))
print('Ndispatched: ' + str(Ndispatched))
print(' Nproblems: ' + str(Nproblems))
for problem,cnt in Nprobs.items():
print(' %4d - %s' % (cnt, problem))
print('=======================================================')
print('')
print('Retry command:\n')
cmd = ['swif2', 'retry-jobs', '-workflow', workflow, '-problems'] + problems
print( ' '.join(cmd) )
print('')