forked from cms-PdmV/mcm_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_priority.py
25 lines (21 loc) · 1000 Bytes
/
change_priority.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
# NEED this to be sourced before
# export PYTHONPATH=/afs/cern.ch/cms/PPD/PdmV/tools/wmcontrol:${PYTHONPATH}
# export PATH=/afs/cern.ch/cms/PPD/PdmV/tools/wmcontrol:${PATH}
# source /afs/cern.ch/cms/PPD/PdmV/tools/wmclient/current/etc/wmclient.sh
import os
import sys
sys.path.append('/afs/cern.ch/cms/PPD/PdmV/tools/McM/')
from rest import McM
mcm = McM(dev=True)
requests = mcm.get('requests', query='tags=M17p1A')
print('Found %s requests' % (len(requests)))
for request in requests:
if len(request['reqmgr_name']) > 0:
# We change priority only if request has a registered workflow
# Remove echo command to acutally execute it
# Change priority to 90000
result = os.system("echo 'wmpriority.py %s %s'" % (request['reqmgr_name'][-1]['name'], 90000))
if result != 0:
print('Change of priority failed for: %s. Exit code: %s' % (request['prepid'], result))
else:
print('Workflow is not registered for %s' % (request['prepid']))