forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duplicateEvents.py
executable file
·55 lines (47 loc) · 1.54 KB
/
duplicateEvents.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
#!/usr/bin/env python
"""
Validates if a given workflow has duplicate events in its output
datasets. That is if a lumi is present in more than one file.
"""
import json
import urllib2,urllib, httplib, sys, re, os
import dbs3Client, reqMgrClient
def testEventCountWorkflow(url, workflow, verbose=False):
"""
Shows where the workflow hs duplicate events
"""
inputEvents = 0
datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
duplicate = False
print 'workflow:',workflow
#check e
for dataset in datasets:
print 'dataset :', dataset
#if dbs3Client.duplicateLumi(dataset, verbose):
if dbs3Client.duplicateRunLumi(dataset, verbose):
duplicate = True
#fast check, one dataset duplicated
if not verbose:
print 'Has duplicated lumis'
return True
if not duplicate:
print "No duplicate found"
return duplicate
def main():
args=sys.argv[1:]
if not len(args)==2:
print "usage input_file output_file"
url = 'cmsweb.cern.ch'
#read the file
input_file = args[0]
#strip carriage return, spaces and empty lines
workflows = [wf.strip() for wf in open(input_file).readlines() if wf.strip()]
output_file = open(args[1],'w')
for workflow in workflows:
if testEventCountWorkflow(url, workflow):
#save which workflows had duplicate lumis
output_file.write(workflow+'\n')
output_file.close()
sys.exit(0);
if __name__ == "__main__":
main()