|
16 | 16 | """Workflow status constants."""
|
17 | 17 |
|
18 | 18 | from enum import Enum
|
19 |
| -from typing import Tuple, TYPE_CHECKING |
| 19 | +from typing import TYPE_CHECKING |
20 | 20 |
|
21 | 21 | from cylc.flow.wallclock import get_time_string_from_unix_time as time2str
|
22 | 22 |
|
@@ -143,62 +143,41 @@ class AutoRestartMode(Enum):
|
143 | 143 | """Workflow will stop immediately but *not* attempt to restart."""
|
144 | 144 |
|
145 | 145 |
|
146 |
| -def get_workflow_status(schd: 'Scheduler') -> Tuple[str, str]: |
147 |
| - """Return the status of the provided workflow. |
148 |
| -
|
149 |
| - This should be a short, concise description of the workflow state. |
150 |
| -
|
151 |
| - Args: |
152 |
| - schd: The running workflow |
153 |
| -
|
154 |
| - Returns: |
155 |
| - tuple - (state, state_msg) |
156 |
| -
|
157 |
| - state: |
158 |
| - The WorkflowState. |
159 |
| - state_msg: |
160 |
| - Text describing the current state (may be an empty string). |
| 146 | +def get_workflow_status(schd: 'Scheduler') -> WorkflowStatus: |
| 147 | + """Return the status of the provided workflow.""" |
| 148 | + if schd.stop_mode is not None: |
| 149 | + return WorkflowStatus.STOPPING |
| 150 | + if schd.is_paused or schd.reload_pending: |
| 151 | + return WorkflowStatus.PAUSED |
| 152 | + return WorkflowStatus.RUNNING |
161 | 153 |
|
162 |
| - """ |
163 |
| - status = WorkflowStatus.RUNNING |
164 |
| - status_msg = '' |
165 | 154 |
|
| 155 | +def get_workflow_status_msg(schd: 'Scheduler') -> str: |
| 156 | + """Return a short, concise status message for the provided workflow.""" |
166 | 157 | if schd.stop_mode is not None:
|
167 |
| - status = WorkflowStatus.STOPPING |
168 |
| - status_msg = f'stopping: {schd.stop_mode.explain()}' |
169 |
| - elif schd.reload_pending: |
170 |
| - status = WorkflowStatus.PAUSED |
171 |
| - status_msg = f'reloading: {schd.reload_pending}' |
172 |
| - elif schd.is_stalled: |
173 |
| - status_msg = 'stalled' |
174 |
| - elif schd.is_paused: |
175 |
| - status = WorkflowStatus.PAUSED |
176 |
| - status_msg = 'paused' |
177 |
| - elif schd.pool.hold_point: |
178 |
| - status_msg = ( |
179 |
| - WORKFLOW_STATUS_RUNNING_TO_HOLD % |
180 |
| - schd.pool.hold_point) |
181 |
| - elif schd.pool.stop_point: |
182 |
| - status_msg = ( |
183 |
| - WORKFLOW_STATUS_RUNNING_TO_STOP % |
184 |
| - schd.pool.stop_point) |
185 |
| - elif schd.stop_clock_time is not None: |
186 |
| - status_msg = ( |
187 |
| - WORKFLOW_STATUS_RUNNING_TO_STOP % |
188 |
| - time2str(schd.stop_clock_time)) |
189 |
| - elif schd.pool.stop_task_id: |
190 |
| - status_msg = ( |
191 |
| - WORKFLOW_STATUS_RUNNING_TO_STOP % |
192 |
| - schd.pool.stop_task_id) |
193 |
| - elif schd.config and schd.config.final_point: |
194 |
| - status_msg = ( |
195 |
| - WORKFLOW_STATUS_RUNNING_TO_STOP % |
196 |
| - schd.config.final_point) |
197 |
| - else: |
198 |
| - # fallback - running indefinitely |
199 |
| - status_msg = 'running' |
200 |
| - |
201 |
| - return (status.value, status_msg) |
| 158 | + return f'stopping: {schd.stop_mode.explain()}' |
| 159 | + if schd.reload_pending: |
| 160 | + return f'reloading: {schd.reload_pending}' |
| 161 | + if schd.is_stalled: |
| 162 | + if schd.is_paused: |
| 163 | + return 'stalled (paused)' |
| 164 | + return 'stalled' |
| 165 | + if schd.is_paused: |
| 166 | + return 'paused' |
| 167 | + if schd.pool.hold_point: |
| 168 | + return WORKFLOW_STATUS_RUNNING_TO_HOLD % schd.pool.hold_point |
| 169 | + if schd.pool.stop_point: |
| 170 | + return WORKFLOW_STATUS_RUNNING_TO_STOP % schd.pool.stop_point |
| 171 | + if schd.stop_clock_time is not None: |
| 172 | + return WORKFLOW_STATUS_RUNNING_TO_STOP % time2str( |
| 173 | + schd.stop_clock_time |
| 174 | + ) |
| 175 | + if schd.pool.stop_task_id: |
| 176 | + return WORKFLOW_STATUS_RUNNING_TO_STOP % schd.pool.stop_task_id |
| 177 | + if schd.config and schd.config.final_point: |
| 178 | + return WORKFLOW_STATUS_RUNNING_TO_STOP % schd.config.final_point |
| 179 | + # fallback - running indefinitely |
| 180 | + return 'running' |
202 | 181 |
|
203 | 182 |
|
204 | 183 | class RunMode:
|
|
0 commit comments