Chromium Code Reviews| Index: scripts/slave/recipe_modules/swarming/api.py |
| diff --git a/scripts/slave/recipe_modules/swarming/api.py b/scripts/slave/recipe_modules/swarming/api.py |
| index af138e6d97b830dee776e58a4e61b4ccb2d6ba46..b0eef2edce805f728ef475152f3bb96fef88f55d 100644 |
| --- a/scripts/slave/recipe_modules/swarming/api.py |
| +++ b/scripts/slave/recipe_modules/swarming/api.py |
| @@ -12,6 +12,15 @@ from recipe_engine import recipe_api |
| # Minimally supported version of swarming.py script (reported by --version). |
| MINIMAL_SWARMING_VERSION = (0, 4, 10) |
| +NAMED_PRIORITIES = { |
|
M-A Ruel
2016/03/23 12:55:32
I wonder if it should go in chromium_tests or here
Sergiy Byelozyorov
2016/03/23 13:58:53
I don't have a strong preference. But if it goes t
|
| + 'min': 1, # higest possible priority |
|
M-A Ruel
2016/03/23 12:55:32
The infrastructure should never use anything below
Sergiy Byelozyorov
2016/03/23 13:58:53
Done. Note that this also changes the logic of the
|
| + 'higher': 25, # used by most masters |
| + 'normal': 30, # used by CQ |
| + 'lower': 35, # used by chromium.fyi |
| + 'default': 200, # very low, should be increased depending on the type of task |
| + 'max': 255, # lowest possible priority |
|
M-A Ruel
2016/03/23 12:55:31
You should use 'highest' and 'lowest' to reduce co
Sergiy Byelozyorov
2016/03/23 13:58:53
Done.
|
| +} |
| + |
| def parse_time(value): |
| """Converts serialized time from the API to datetime.datetime.""" |
| @@ -103,9 +112,7 @@ class SwarmingApi(recipe_api.RecipeApi): |
| self._default_hard_timeout = 60*60 |
| self._default_idempotent = False |
| self._default_io_timeout = 20*60 |
| - # The default priority is extremely low and should be increased dependending |
| - # on the type of task. |
| - self._default_priority = 200 |
| + self._default_priority = NAMED_PRIORITIES['default'] |
| self._default_tags = set() |
| self._default_user = None |
| self._pending_tasks = set() |
| @@ -276,7 +283,7 @@ class SwarmingApi(recipe_api.RecipeApi): |
| @default_priority.setter |
| def default_priority(self, value): |
| - assert 1 <= value <= 255 |
| + assert NAMED_PRIORITIES['min'] <= value <= NAMED_PRIORITIES['max'] |
| self._default_priority = value |
| def add_default_tag(self, tag): |
| @@ -581,6 +588,15 @@ class SwarmingApi(recipe_api.RecipeApi): |
| # To keep compatibility with some build_internal code. To be removed as well. |
| collect_each = collect |
| + def parse_priority_adjustment(self, adjustment): |
| + if isinstance(adjustment, basestring) and adjustment in NAMED_PRIORITIES: |
| + return NAMED_PRIORITIES[adjustment] |
| + |
| + try: |
| + return int(adjustment) |
|
M-A Ruel
2016/03/23 12:55:31
I prefer to not support that and just use names fo
Sergiy Byelozyorov
2016/03/23 13:58:53
Done.
|
| + except (ValueError, TypeError): |
| + return None |
| + |
| @staticmethod |
| def _display_pending(summary_json, step_presentation): |
| """Shows max pending time in seconds across all shards if it exceeds 10s.""" |