Skip to content

Commit 02eb9b4

Browse files
event handlers: improve docs
1 parent 0f132a6 commit 02eb9b4

File tree

5 files changed

+64
-33
lines changed

5 files changed

+64
-33
lines changed

src/glossary.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,8 +1654,6 @@ Glossary
16541654
WARNING messages from a task :term:`job`.
16551655

16561656

1657-
.. TODO cylc-flow cfgspec/workflow.py references "event handlers" plural
1658-
16591657
handler
16601658
event handler
16611659
event handlers
@@ -1671,9 +1669,8 @@ Glossary
16711669

16721670
.. seealso::
16731671

1674-
- :cylc:conf:`task events <[runtime][<namespace>][events]>`
1675-
- :cylc:conf:`workflow events <[scheduler][events]>`
1676-
- :ref:`Cylc User Guide <EventHandling>`
1672+
- :ref:`user_guide.scheduler.workflow_event_handling`
1673+
- :ref:`user_guide.runtime.task_event_handling`
16771674

16781675

16791676
runahead limit

src/installation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ To do so create a symbolic link to the wrapper, for each of these commands:
250250
ln -s cylc rosie
251251
ln -s cylc isodatetime
252252
253+
253254
Configuration
254255
-------------
255256

@@ -259,7 +260,7 @@ However, many things may need to be configured, e.g:
259260

260261
* :ref:`AdminGuide.PlatformConfigs` (jobs hosts, runners, etc)
261262
* :ref:`Scheduler Hosts<Submitting Workflows To a Pool Of Hosts>`
262-
* :ref:`Default Event Handlers<EventHandlers>`
263+
* :ref:`Default Event Handlers<user_guide.runtime.task_event_handling.general_event_handlers>`.
263264

264265
Cylc Flow
265266
^^^^^^^^^

src/user-guide/task-implementation/job-scripts.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ execution has started, succeeded, or failed. Custom messages can also be sent
127127
by the same mechanism, with various severity levels. These can be used to
128128
trigger other tasks off specific task outputs (see :ref:`MessageTriggers`), or
129129
to trigger execution of event handlers by the scheduler (see
130-
:ref:`EventHandling`), or just to write information to the scheduler log.
130+
:ref:`user_guide.runtime.task_event_handling`)
131+
or just to write information to the scheduler log.
131132

132133
.. cylc-scope:: global.cylc[platforms][<platform name>]
133134

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

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -567,22 +567,25 @@ task ``whizz`` downstream. The scheduler will then stall with
567567
script = "sleep 10"
568568
569569
570-
.. _EventHandling:
570+
.. _user_guide.runtime.task_event_handling:
571571

572-
Event Handling
573-
--------------
572+
Task Event Handling
573+
-------------------
574574

575-
.. seealso::
575+
Task event handlers allow configured commands to run when task events occur.
576576

577-
* Task events :cylc:conf:`[runtime][<namespace>][events]`
578-
* Workflow events :cylc:conf:`[scheduler][events]`
577+
.. note::
579578

580-
.. cylc-scope:: flow.cylc[runtime][<namespace>]
579+
Cylc supports workflow events e.g. ``startup`` and ``shutdown``
580+
and task events e.g. ``submitted`` and ``failed``.
581581

582-
Custom *event handler* scripts can be called when certain workflow and task
583-
events occur. Event handlers can be used to send a message, raise an alarm, or
584-
whatever you like. They can even call ``cylc`` commands to intervene in the
585-
workflow.
582+
See also :ref:`user_guide.scheduler.workflow_event_handling`.
583+
584+
Event handlers can be used to send a message, raise an alarm, or whatever you
585+
like. They can even call ``cylc`` commands to intervene in the workflow.
586+
587+
Task event handlers are configured by
588+
:cylc:conf:`flow.cylc[runtime][<namespace>][events]`.
586589

587590
.. note::
588591

@@ -596,7 +599,7 @@ They should return quickly to avoid tying up the scheduler process pool -
596599
see :ref:`Managing External Command Execution`.
597600

598601

599-
.. cylc-scope::
602+
.. _user_guide.runtime.task_event_handling.event_specific_handlers:
600603

601604
Event-Specific Handlers
602605
^^^^^^^^^^^^^^^^^^^^^^^
@@ -634,18 +637,40 @@ can be:
634637
Values should be a list of commands, command lines, or command line templates
635638
(see below) to call if the specified event is triggered.
636639

640+
641+
.. _user_guide.runtime.task_event_handling.general_event_handlers:
642+
637643
General Event Handlers
638644
^^^^^^^^^^^^^^^^^^^^^^
639645

640-
Alternatively you can configure ``handler events`` and ``handlers``
641-
under :cylc:conf:`[runtime][<namespace>][events]`, where the former is a list
642-
of events (as above), and the latter a list of commands, command lines, lines
643-
or command line templates (see below) to call if any of the specified events
644-
are triggered.
646+
.. cylc-scope:: flow.cylc[runtime][<namespace>][events]
647+
648+
Alternatively you can configure a list of generic event :cylc:conf:`handlers` to be run
649+
for configured :cylc:conf:`handler events`.
650+
651+
:cylc:conf:`handler events`
652+
A list of events which may include any of the above
653+
events (e.g. ``submission failed`` or ``warning``) or
654+
any of a task's :term:`custom outputs <custom output>`.
655+
:cylc:conf:`handlers`
656+
A list of commands to be run for these events.
657+
Information about the event can be provided using
658+
:ref:`user_guide.runtime.event_handlers.task_event_handling.template_variables`.
659+
660+
Example:
661+
662+
.. code-block:: cylc
663+
664+
handlers = """
665+
my-handler %(event)s %(workflow)s,
666+
echo %(workflow)s-%(event)s >> my-log-file
667+
"""
668+
handler events = submission failed, failed, warning, my-custom-output
645669
646670
.. cylc-scope::
647671

648-
.. _task_event_template_variables:
672+
673+
.. _user_guide.runtime.event_handlers.task_event_handling.template_variables:
649674

650675
Task Event Template Variables
651676
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,27 @@ Many of these configurations can also be defined at the site or user level in
88
the :cylc:conf:`global.cylc[scheduler]` section where it applies to all
99
workflows.
1010

11-
.. _EventHandlers:
1211

13-
Event handlers
14-
--------------
12+
.. _user_guide.scheduler.workflow_event_handling:
13+
14+
Workflow Event Handling
15+
-----------------------
16+
17+
Workflow event handlers allow configured commands to run when workflow events
18+
occur.
1519

1620
.. note::
1721

18-
Workflow event handlers are configured by:
22+
Cylc supports workflow events e.g. ``startup`` and ``shutdown``
23+
and task events e.g. ``submitted`` and ``failed``.
24+
25+
See also :ref:`user_guide.runtime.task_event_handling`.
26+
27+
Workflow event handlers are configured by:
1928

20-
* :cylc:conf:`flow.cylc[scheduler][events]`
21-
* :cylc:conf:`global.cylc[scheduler][events]`
29+
* :cylc:conf:`flow.cylc[scheduler][events]` (per workflow)
30+
* :cylc:conf:`global.cylc[scheduler][events]` (user/site defaults)
2231

23-
Workflow event handlers allow configurable actions to be performed when
24-
workflow events occur.
2532

2633
Workflow Events
2734
^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)