This repository was archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathrejectWorkflows.py
More file actions
executable file
·58 lines (49 loc) · 1.87 KB
/
Copy pathrejectWorkflows.py
File metadata and controls
executable file
·58 lines (49 loc) · 1.87 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
#!/usr/bin/env python
"""
Reject a given list of workflows.
This can be used when input workflows are in status: assigened or assignment-approved
input arg: Text file with list of workflows.
"""
import sys
from optparse import OptionParser
import reqMgrClient
import dbs3Client as dbs3
import logging
def rejectWorkflow(wf, url, invalidate):
import reqMgrClient
import dbs3Client as dbs3
import logging
logging.info("Rejecting workflow: " + wf)
reqMgrClient.rejectWorkflow(url, wf)
logging.info("Rejected")
if invalidate:
logging.info("Invalidating datasets")
datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
for ds in datasets:
logging.info(ds)
dbs3.setDatasetStatus(ds, 'INVALID', files=True)
def main():
url='cmsweb.cern.ch'
#Create option parser
usage = "\n python %prog [-f FILE_NAME | WORKFLOW_NAME ...]\n"
parser = OptionParser(usage=usage)
parser.add_option('-f', '--file', help='Text file with a list of workflows', dest='file')
parser.add_option('-a', '--afile', help='Text file with output of autoACDC', dest='afile')
parser.add_option('-i', '--invalidate', action='store_true', default=False,
help='Also invalidate output datasets on DBS', dest='invalidate')
(options, args) = parser.parse_args()
if options.file:
wfs = [l.strip() for l in open(options.file) if l.strip()]
elif options.afile:
ins = [l.strip() for l in open(options.afile) if l.strip()]
# select only ones w/ errors
wfs = [w.split(", ")[-2] for w in ins if len(w.split(", ")) > 2]
elif args:
wfs = args
else:
parser.error("Provide the workflow of a file of workflows")
sys.exit(1)
for wf in wfs:
rejectWorkflow(wf, url, options.invalidate)
if __name__ == "__main__":
main()