63
63
)
64
64
from cylc .flow .pathutil import SYMLINKABLE_LOCATIONS
65
65
from cylc .flow .platforms import validate_platforms
66
+ from cylc .flow .task_events_mgr import TaskEventsManager as TEM
66
67
from cylc .flow .workflow_events import WorkflowEventHandler
67
68
68
69
171
172
Configure :term:`event handlers` that run when certain workflow
172
173
events occur.
173
174
174
- This section configures *workflow* event handlers; see
175
- :cylc:conf:`flow.cylc[runtime][<namespace>][events]` for *task* event
176
- handlers.
175
+ .. admonition:: Not to be confused with
176
+ :class: tip
177
+
178
+ For *task* events, see
179
+ :cylc:conf:`flow.cylc[runtime][<namespace>][events]`.
177
180
178
181
Event handlers can be held in the workflow ``bin/`` directory,
179
182
otherwise it is up to you to ensure their location is in ``$PATH``
194
197
195
198
.. seealso::
196
199
197
- :ref:`user_guide.scheduler.workflow_events`
200
+ :ref:`user_guide.scheduler.workflow_events.list `
198
201
''' ,
199
202
'options' : WorkflowEventHandler .EVENTS .copy (),
200
203
'depr_options' : WorkflowEventHandler .EVENTS_DEPRECATED .copy (),
204
+ 'warn_options' : True ,
201
205
},
202
206
'mail events' : {
203
207
'desc' : '''
204
208
Specify the workflow events for which notification emails should
205
209
be sent.
210
+
211
+ .. seealso::
212
+
213
+ :ref:`user_guide.scheduler.workflow_events.list`
206
214
''' ,
207
215
'options' : WorkflowEventHandler .EVENTS .copy (),
208
216
'depr_options' : WorkflowEventHandler .EVENTS_DEPRECATED .copy (),
217
+ 'warn_options' : True ,
209
218
},
210
219
'startup handlers' : f'''
211
220
Handlers to run at scheduler startup.
546
555
TASK_EVENTS_DESCR = '''
547
556
Configure the task event handling system.
548
557
549
- See also :cylc:conf:`flow.cylc[scheduler][events]` for *workflow* events.
558
+ .. admonition:: Not to be confused with
559
+ :class: tip
560
+
561
+ For *workflow* events, see :cylc:conf:`flow.cylc[scheduler][events]`.
550
562
551
563
Task :term:`event handlers` are scripts to run when task events occur.
552
564
576
588
For more information, see
577
589
:ref:`user_guide.runtime.task_event_handling`.
578
590
579
- For workflow events, see
580
- :ref:`user_guide.scheduler.workflow_event_handling`.
581
-
582
591
Example::
583
592
584
593
echo %(event)s occurred in %(workflow)s >> my-log-file
585
594
586
595
''' ,
587
- 'execution timeout' : '''
588
- If a task has not finished after the specified interval, the execution
589
- timeout event handler(s) will be called.
590
- ''' ,
591
- 'handler events' : '''
592
- A list of events for which :cylc:conf:`[..]handlers` are run.
596
+ 'handler events' : f'''
597
+ :Options: ``{ "``, ``" .join (TEM .STD_EVENTS )} `` & any custom event
593
598
594
- Specify the events for which the general task event handlers
595
- :cylc:conf:`flow.cylc[runtime][<namespace>][events]handlers`
596
- should be invoked.
599
+ A list of events for which :cylc:conf:`[..]handlers` are run.
597
600
598
- See :ref:`user_guide.runtime.task_event_handling` for more information.
601
+ See :ref:`user_guide.runtime.task_event_handling.list` for more
602
+ information on task events.
599
603
600
604
Example::
601
605
612
616
613
617
PT10S, PT1M, PT5M
614
618
''' ,
615
- 'mail events' : '''
616
- Specify the events for which notification emails should be sent.
619
+ 'mail events' : f'''
620
+ :Options: ``{ "``, ``" .join (TEM .STD_EVENTS )} `` & any custom event
621
+
622
+ A list of events for which notification emails should be sent.
623
+
624
+ See :ref:`user_guide.runtime.task_event_handling.list` for more
625
+ information on task events.
617
626
618
627
Example::
619
628
620
629
submission failed, failed
621
630
''' ,
631
+ 'execution timeout' : '''
632
+ If a task has not finished after the specified interval, any configured
633
+ execution timeout event handler(s) will be called.
634
+ ''' ,
622
635
'submission timeout' : '''
623
- If a task has not started after the specified interval, the submission
624
- timeout event handler(s) will be called.
636
+ If a task has not started after the specified interval, any configured
637
+ submission timeout event handler(s) will be called.
625
638
'''
626
639
}
627
640
@@ -670,15 +683,36 @@ def comma_sep_section_note(version_changed: str = '') -> str:
670
683
671
684
672
685
def short_descr (text : str ) -> str :
673
- """Get dedented one-paragraph description from long description."""
674
- return dedent (text ).split ('\n \n ' , 1 )[0 ]
686
+ r"""Get dedented one-paragraph description from long description.
687
+
688
+ Examples:
689
+ >>> short_descr('foo\n\nbar')
690
+ 'foo'
691
+
692
+ >>> short_descr(':Field: Value\n\nfoo\n\nbar')
693
+ ':Field: Value\n\nfoo'
694
+
695
+ """
696
+ lines = []
697
+ for line in dedent (text ).splitlines ():
698
+ if not line :
699
+ continue
700
+ elif line .startswith (':' ):
701
+ lines .append (line )
702
+ else :
703
+ lines .append (line )
704
+ break
705
+ return '\n \n ' .join (lines )
675
706
676
707
677
708
def default_for (
678
709
text : str , config_path : str , section : bool = False
679
710
) -> str :
680
- """Get dedented short description and insert a 'Default(s) For' directive
681
- that links to this config item's flow.cylc counterpart."""
711
+ """Return a ":Default For: field for this config.
712
+
713
+ Get dedented short description and insert a 'Default(s) For' field
714
+ that links to this config item's flow.cylc counterpart.
715
+ """
682
716
directive = f":Default{ 's' if section else '' } For:"
683
717
return (
684
718
f"{ directive } :cylc:conf:`flow.cylc{ config_path } `.\n \n "
@@ -1998,12 +2032,6 @@ def default_for(
1998
2032
TASK_EVENTS_DESCR , "[runtime][<namespace>][events]" , section = True
1999
2033
) + "\n \n " + ".. versionadded:: 8.0.0"
2000
2034
)):
2001
- Conf ('execution timeout' , VDR .V_INTERVAL , desc = (
2002
- default_for (
2003
- TASK_EVENTS_SETTINGS ['execution timeout' ],
2004
- "[runtime][<namespace>][events]execution timeout"
2005
- )
2006
- ))
2007
2035
Conf ('handlers' , VDR .V_STRING_LIST , desc = (
2008
2036
default_for (
2009
2037
TASK_EVENTS_SETTINGS ['handlers' ],
@@ -2028,6 +2056,12 @@ def default_for(
2028
2056
"[runtime][<namespace>][events]mail events"
2029
2057
)
2030
2058
))
2059
+ Conf ('execution timeout' , VDR .V_INTERVAL , desc = (
2060
+ default_for (
2061
+ TASK_EVENTS_SETTINGS ['execution timeout' ],
2062
+ "[runtime][<namespace>][events]execution timeout"
2063
+ )
2064
+ ))
2031
2065
Conf ('submission timeout' , VDR .V_INTERVAL , desc = (
2032
2066
default_for (
2033
2067
TASK_EVENTS_SETTINGS ['submission timeout' ],
0 commit comments