Skip to content

Commit

Permalink
Automatically bump MiniAOD-only workflow priority
Browse files Browse the repository at this point in the history
  • Loading branch information
justinasr authored Oct 31, 2018
1 parent 31b3152 commit 66ea753
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mcm/rest_api/BatchActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ def announce_with_text(self, bid, message):
else:
r = b.announce(message)
if r:
map_wf_to_prepid = {}
for dictionary in b.get_attribute('requests'):
wf = dictionary.get('name')
prepid = dictionary.get('content', {}).get('pdmv_prep_id')
if not wf or not prepid:
continue

if wf not in map_wf_to_prepid:
map_wf_to_prepid[wf] = []

map_wf_to_prepid[wf].append(prepid)

rdb = database('requests')
priority_coeff = settings.get_value('nanoaod_priority_increase_coefficient')
for wf, requests in map_wf_to_prepid.iteritems():
if len(requests) == 1 and 'nanoaod' in requests[0].lower():
for r_prepid in requests:
req = request(rdb.get(r_prepid))
current_priority = req.get_attribute('priority')
new_priority = int(current_priority + priority_coeff * 1000)
req.change_priority(new_priority)

return {
"results": bdb.update(b.json()),
"message": r,
Expand Down

0 comments on commit 66ea753

Please # to comment.