| 1 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 2 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 3 |
# |
| 4 |
# This program is free software: you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
"""Task state properties for display.""" |
| 17 |
|
| 18 |
from cylc.flow.task_state import ( |
| 19 |
TASK_STATUS_WAITING, |
| 20 |
TASK_STATUS_PREPARING, |
| 21 |
TASK_STATUS_EXPIRED, |
| 22 |
TASK_STATUS_SUBMITTED, |
| 23 |
TASK_STATUS_SUBMIT_FAILED, |
| 24 |
TASK_STATUS_RUNNING, |
| 25 |
TASK_STATUS_SUCCEEDED, |
| 26 |
TASK_STATUS_FAILED |
| 27 |
) |
| 28 |
|
| 29 |
|
| 30 |
def extract_group_state(child_states, is_stopped=False): |
| 31 |
"""Summarise child states as a group.""" |
| 32 |
ordered_states = [ |
| 33 |
TASK_STATUS_SUBMIT_FAILED, |
| 34 |
TASK_STATUS_FAILED, |
| 35 |
TASK_STATUS_EXPIRED, |
| 36 |
TASK_STATUS_RUNNING, |
| 37 |
TASK_STATUS_SUBMITTED, |
| 38 |
TASK_STATUS_PREPARING, |
| 39 |
TASK_STATUS_WAITING, |
| 40 |
TASK_STATUS_SUCCEEDED |
| 41 |
] |
| 42 |
if is_stopped: |
| 43 |
ordered_states = [ |
| 44 |
TASK_STATUS_SUBMIT_FAILED, |
| 45 |
TASK_STATUS_FAILED, |
| 46 |
TASK_STATUS_RUNNING, |
| 47 |
TASK_STATUS_SUBMITTED, |
| 48 |
TASK_STATUS_EXPIRED, |
| 49 |
TASK_STATUS_PREPARING, |
| 50 |
TASK_STATUS_SUCCEEDED, |
| 51 |
TASK_STATUS_WAITING |
| 52 |
] |
| 53 |
for state in ordered_states: |
| 54 |
if state in child_states: |
| 55 |
return state |
| 56 |
return None |