Skip to content

Commit b8a521e

Browse files
Merge pull request #731 from oliver-sanders/opt-outputs
completion: add additional documentation
2 parents 7fefff6 + e2e1987 commit b8a521e

File tree

2 files changed

+83
-22
lines changed

2 files changed

+83
-22
lines changed

src/reference/changes.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,41 @@ The graph view now has an option to group tasks by cycle point.
132132
.. image:: changes/cylc-graph-group-by-cycle-point.png
133133
:width: 100%
134134

135+
136+
Completion Expressions
137+
^^^^^^^^^^^^^^^^^^^^^^
138+
139+
When a task achieves a final status, its outputs are validated against a "completion
140+
expression" to ensure that it has produced all of its
141+
:term:`required outputs <required output>`.
142+
If a task fails this validation check it is said to have "incomplete outputs"
143+
and will be retained in the :term:`active window` pending user intervention.
144+
145+
This completion expression is generated automatically from the graph.
146+
By default, tasks are expected to succeed, if you register any additional
147+
required output in the graph, then these must also
148+
be produced.
149+
150+
At Cylc 8.3.0 it is now possible to manually configure this completion
151+
expression for finer control. This is particularly useful for anyone using
152+
:term:`custom outputs <custom output>`.
153+
154+
For example, ``mytask`` must produce one of the outputs ``x`` or ``y`` to pass
155+
the completion expression configured here:
156+
157+
.. code-block:: cylc
158+
159+
[runtime]
160+
[[mytask]]
161+
completion = succeeded and (x or y)
162+
[[[outputs]]]
163+
x = output-x
164+
y = output-y
165+
166+
For more information, see the reference for the
167+
:cylc:conf:`[runtime][<namespace>]completion` configuration.
168+
169+
135170
----------
136171

137172
Cylc 8.2

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

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,12 +1894,12 @@ A more realistic example might have several tasks on each branch. The
18941894
``bar``, but configured differently to avoid the failure.
18951895

18961896

1897-
Message Trigger Example
1898-
^^^^^^^^^^^^^^^^^^^^^^^
1897+
Custom Outputs
1898+
^^^^^^^^^^^^^^
18991899

1900-
Branching is particularly powerful when using :ref:`MessageTriggers` (i.e.
1901-
:term:`custom outputs <custom output>`) to define multiple parallel paths in
1902-
the graph.
1900+
Branching is particularly powerful when using
1901+
:term:`custom outputs <custom output>` to define alternate parallel paths in the
1902+
graph.
19031903

19041904
In the following graph there is a task called ``showdown`` which produces one
19051905
of three possible custom outputs, ``good``, ``bad`` or ``ugly``. Cylc will follow
@@ -1961,7 +1961,7 @@ three custom outputs:
19611961
19621962
[runtime]
19631963
[[showdown]]
1964-
# Randomly return one of the three custom outputs.
1964+
# Randomly return one of the three custom outputs:
19651965
script = """
19661966
SEED=$RANDOM
19671967
if ! (( $SEED % 3 )); then
@@ -1972,36 +1972,62 @@ three custom outputs:
19721972
cylc message 'The Ugly'
19731973
fi
19741974
"""
1975+
1976+
# Ensure that at least one of the custom outputs is produced:
1977+
completion = succeeded and (good or bad or ugly)
1978+
1979+
# Register the three custom outputs:
19751980
[[[outputs]]]
1976-
# Register the three custom outputs.
19771981
good = 'The Good'
19781982
bad = 'The Bad'
19791983
ugly = 'The Ugly'
19801984
1985+
Completion Expressions
1986+
""""""""""""""""""""""
19811987

1982-
When using message triggers in this way there are two things to be aware of:
1988+
.. cylc-scope:: flow.cylc[runtime][<namespace>]
19831989

1984-
1. Message triggers are not exit states.
1990+
The :cylc:conf:`completion` configuration above is optional, it adds a basic
1991+
validation check which ensures that at least one of the three custom outputs is
1992+
produced when the task runs. This protects you against the possibility that
1993+
none of the outputs are produced e.g. due to a task implementation error.
19851994

1986-
Custom output messages are generated *before* the task has completed, so it
1987-
can be useful to combine them with a regular trigger for safety e.g:
1995+
If the task does not produce at least one of these three outputs, then it will
1996+
be marked as having incomplete outputs and will be retained in a similar manner
1997+
to if it had failed. This provides you with an opportunity to intervene to
1998+
rectify the situation: Without intervention the workflow will :term:`stall`.
19881999

1989-
.. code-block:: cylc-graph
2000+
.. cylc-scope:: flow.cylc
2001+
2002+
Mutually Exclusive Outputs
2003+
""""""""""""""""""""""""""
19902004

1991-
# good will wait for showdown to finish before running
1992-
showdown:finish & showdown:good => good
2005+
It is not possible to enforce mutually exclusive outputs in Cylc as
2006+
tasks may be re-run multiple times and the outputs from previous runs
2007+
accumulate.
19932008

1994-
# if showdown fails then good will not run
1995-
showdown:succeed & showdown:good => good
2009+
E.g, this expression ensures that **at least one** of the three custom outputs
2010+
is produced when the task runs:
19962011

1997-
2. Whether message outputs from a single task are mutually exclusive or not
1998-
depends on the task, and the workflow should be designed accordingly.
2012+
.. code-block:: cylc
2013+
2014+
completion = succeeded and (good or bad or ugly)
19992015
2000-
For example, the ``showdown`` task above could instead send all three
2001-
messages in succession, after writing out corresponding *good*, *bad*, and
2002-
*ugly* files.
2016+
However, it is not possible to ensure that **only** one of the three is
2017+
produced.
2018+
2019+
Custom Output Generation Timing
2020+
"""""""""""""""""""""""""""""""
2021+
2022+
Custom outputs are generated *before* the task succeeds or fails. This is handy
2023+
if you don't want downstream tasks to wait for upstream tasks to finish
2024+
executing, e.g:
2025+
2026+
.. code-block:: cylc-graph
20032027
2004-
Check that you understand how your tasks work, if they use custom outputs.
2028+
# run "process_file_1" as soon as the output "file_1" is completed, but
2029+
# don't wait for "model" to finish first
2030+
model:file_1_ready => process_file_1
20052031
20062032
20072033
.. _RunaheadLimit:

0 commit comments

Comments
 (0)