From 66ea75381462acbc8599803a50ab187c8e602d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justinas=20Rum=C5=A1evi=C4=8Dius?= Date: Wed, 31 Oct 2018 11:30:41 +0100 Subject: [PATCH] Automatically bump MiniAOD-only workflow priority --- mcm/rest_api/BatchActions.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mcm/rest_api/BatchActions.py b/mcm/rest_api/BatchActions.py index cd97738d..698facad 100644 --- a/mcm/rest_api/BatchActions.py +++ b/mcm/rest_api/BatchActions.py @@ -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,