Skip to content

Commit a9674f2

Browse files
examples: document expiry workflow design patterns
1 parent eefa042 commit a9674f2

File tree

1 file changed

+71
-11
lines changed

1 file changed

+71
-11
lines changed

src/user-guide/writing-workflows/scheduling.rst

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,14 +1507,62 @@ to the task cycle point.
15071507
Clock-Expire Triggers
15081508
^^^^^^^^^^^^^^^^^^^^^
15091509

1510-
Tasks can be configured to :term:`expire <expired task>` if the wall clock
1511-
time exceeds some offset from their cycle point.
1510+
Tasks can be configured to :term:`expire <expired task>` if the real-world
1511+
(wall clock) time exceeds some offset from their cycle point.
15121512

1513+
Task expiration is configured with
1514+
:cylc:conf:`[scheduling][special tasks]clock-expire` using a syntax like
1515+
:cylc:conf:`clock-trigger <[scheduling][special tasks]clock-trigger>`
1516+
with a datetime offset relative to cycle point.
1517+
The offset should be positive to make the task expire if the wallclock time
1518+
has gone beyond the cycle point.
1519+
1520+
In this example:
1521+
1522+
* The task ``foo`` is configured to expire when the wall clock
1523+
time passes the cycle time:
1524+
* Whereas ``bar`` is configured to expire one hour *after* the cycle time.
1525+
1526+
.. code-block:: cylc
15131527
1514-
The associated ``:expire`` :term:`output <task output>` can be used to
1528+
[scheduling]
1529+
[[special tasks]]
1530+
clock-expire = foo, bar(PT1H)
1531+
1532+
So, in the cycle ``2000-01-01T00:00Z``:
1533+
1534+
* ``foo`` would expire at ``2000-01-01T00:00Z``.
1535+
* ``bar`` would expire at ``2000-01-01T01:00Z``.
1536+
1537+
Only waiting tasks can expire, :term:`active tasks <active>` will not be
1538+
killed if they pass their configured ``clock-expire`` time.
1539+
1540+
When a task expires, it produces the ``expired`` :term:`output`.
1541+
This can be used to
15151542
trigger other tasks. It must be marked as an :term:`optional output`,
15161543
i.e. expiry cannot be :term:`required <required output>`.
15171544

1545+
In this example:
1546+
1547+
* ``foo`` will not run before the wall clock time.
1548+
* ``foo`` will expire if it does not start running within 6 hours of the wall
1549+
clock time being reached.
1550+
* If ``foo`` runs, the task ``bar`` will run after.
1551+
* If ``foo`` expires, the task ``baz`` will run after.
1552+
1553+
.. code-block:: cylc
1554+
1555+
[scheduling]
1556+
initial cycle point = 2000
1557+
[[special tasks]]
1558+
clock-expire = foo(PT6H)
1559+
[[graph]]
1560+
P1D = """
1561+
@wall_clock => foo
1562+
foo => bar
1563+
foo:expired? => baz
1564+
"""
1565+
15181566
Family triggers are also provided for task expiry:
15191567

15201568
.. code-block:: cylc-graph
@@ -1523,19 +1571,31 @@ Family triggers are also provided for task expiry:
15231571
FAM:expire-all? => baz
15241572
FAM:expire-any? => qux
15251573
1526-
Task expiration is configured with
1527-
:cylc:conf:`[scheduling][special tasks]clock-expire` using a syntax like
1528-
:cylc:conf:`clock-trigger <[scheduling][special tasks]clock-trigger>`
1529-
with a datetime offset relative to cycle point.
1530-
1531-
The offset should be positive to make the task expire if the wallclock time
1532-
has gone beyond the cycle point.
1533-
15341574
.. warning::
15351575

15361576
The scheduler can only determine that a task has expired once it
15371577
enters the :term:`n=0 window <n-window>`.
15381578

1579+
This means that at least one of a task's prerequisites must be satisfied
1580+
before the task may expire.
1581+
1582+
So in the following example, the task ``b`` will only expire, **after**
1583+
the task ``a`` has succeeded:
1584+
1585+
.. code-block:: cylc
1586+
1587+
[scheduling]
1588+
initial cycle point = 2000
1589+
[[special tasks]]
1590+
clock-expire = b
1591+
[[graph]]
1592+
P1D = a => b
1593+
1594+
.. seealso::
1595+
1596+
For worked examples of workflows that use expiry, see the
1597+
:ref:`examples section<examples.expiry>`.
1598+
15391599

15401600
.. _WorkflowConfigExternalTriggers:
15411601

0 commit comments

Comments
 (0)