| 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 |
|
| 17 |
from cylc.flow import LOG |
| 18 |
import cylc.flow.flags |
| 19 |
from cylc.flow.xtriggers.workflow_state import _workflow_state_backcompat |
| 20 |
|
| 21 |
if not cylc.flow.flags.cylc7_back_compat: |
| 22 |
LOG.warning( |
| 23 |
"The suite_state xtrigger is deprecated. " |
| 24 |
"Please use the workflow_state xtrigger instead." |
| 25 |
) |
| 26 |
|
| 27 |
|
| 28 |
def suite_state(suite, task, point, offset=None, status='succeeded', |
| 29 |
message=None, cylc_run_dir=None, debug=False): |
| 30 |
"""Suite state xtrigger, required for interoperability with Cylc 7. |
| 31 |
|
| 32 |
* The suite_state xtrigger was renamed to workflow_state - |
| 33 |
this breaks Cylc 7-8 interoperability. |
| 34 |
* This suite_state xtrigger replicates workflow_state - |
| 35 |
ensuring back-support. |
| 36 |
|
| 37 |
Arguments: |
| 38 |
suite: |
| 39 |
The workflow to interrogate. |
| 40 |
task: |
| 41 |
The name of the task to query. |
| 42 |
point: |
| 43 |
The cycle point. |
| 44 |
offset: |
| 45 |
The offset between the cycle this xtrigger is used in and the one |
| 46 |
it is querying for as an ISO8601 time duration. |
| 47 |
e.g. PT1H (one hour). |
| 48 |
status: |
| 49 |
The task status required for this xtrigger to be satisfied. |
| 50 |
message: |
| 51 |
The custom task output required for this xtrigger to be satisfied. |
| 52 |
.. note:: |
| 53 |
|
| 54 |
This cannot be specified in conjunction with ``status``. |
| 55 |
|
| 56 |
cylc_run_dir: |
| 57 |
The directory in which the workflow to interrogate. |
| 58 |
|
| 59 |
.. note:: |
| 60 |
|
| 61 |
This only needs to be supplied if the workflow is running in a |
| 62 |
different location to what is specified in the global |
| 63 |
configuration (usually ``~/cylc-run``). |
| 64 |
|
| 65 |
Returns: |
| 66 |
tuple: (satisfied, results) |
| 67 |
|
| 68 |
satisfied: |
| 69 |
True if ``satisfied`` else ``False``. |
| 70 |
results: |
| 71 |
Dictionary containing the args / kwargs which were provided |
| 72 |
to this xtrigger. |
| 73 |
|
| 74 |
""" |
| 75 |
return _workflow_state_backcompat( |
| 76 |
suite, task, point, offset, status, message, cylc_run_dir |
| 77 |
) |