Skip to content

Commit a5bf3d0

Browse files
authored
Xtriggers: improve docs (#686)
1 parent 3a3aacb commit a5bf3d0

File tree

11 files changed

+112
-96
lines changed

11 files changed

+112
-96
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
8080
- name: build & test
8181
run: |
82-
make html spelling linkcheck doctest \
82+
make html spelling linkcheck \
8383
SPHINXOPTS='-Wn --keep-going' FORCE_COLOR=true
8484
8585
- name: debug sphinx failure

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ clean:
2020
# remove auto-generated content
2121
rm -rf src/plugins/main-loop/built-in
2222
rm -rf src/plugins/install/built-in
23+
rm -rf src/plugins/xtriggers/built-in
2324
rm -rf src/user-guide/task-implementation/job-runner-handlers
2425

2526
watch: clean

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ allows it to pick up changes to autodocumented items in the source code.
183183

184184
```console
185185
# note: -W tells Sphinx to fail on warnings
186-
$ make html linkcheck doctest SPHINXOPTS='-W'
186+
$ make html linkcheck SPHINXOPTS='-W'
187187
```
188188

189189
### Deploying

bin/version

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ from pkg_resources import parse_version
2727
DUMMY_FORMATS = [
2828
'doctrees',
2929
'linkcheck',
30-
'doctest',
3130
'coverage'
3231
]
3332

src/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
# sphinx built-in extensions
3535
'sphinx.ext.autodoc',
3636
'sphinx.ext.autosummary',
37-
'sphinx.ext.doctest',
3837
'sphinx.ext.graphviz',
3938
'sphinx.ext.intersphinx',
4039
'sphinx.ext.napoleon',
@@ -111,6 +110,10 @@
111110
autosummary_generate_overwrite = True
112111
autosummary_imported_members = False
113112

113+
# Autodoc type hints can look very messy if they are included in the signature,
114+
# so we only include them in the description instead:
115+
autodoc_typehints = 'description'
116+
114117
# Mapping to other Sphinx projects we want to import references from.
115118
# NOTE: To search available references, use:
116119
# $ python -m sphinx.ext.intersphinx <url>/objects.inv | less

src/dictionaries/words

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ filesystem
4646
filesystems
4747
fillchar
4848
foo
49+
fpath
4950
freeform
5051
fullmatch
5152
globals
@@ -129,6 +130,7 @@ py
129130
pythonically
130131
queueing
131132
qux
133+
randint
132134
rc
133135
refactor
134136
regex
@@ -148,6 +150,7 @@ ret
148150
retrigger
149151
retriggered
150152
retriggering
153+
rmtree
151154
roadmap
152155
ruleset
153156
rulesets
@@ -156,10 +159,12 @@ runnable
156159
runtime
157160
schd
158161
screenshot
162+
secs
159163
setup
160164
setups
161165
shebang
162166
shutdown
167+
shutil
163168
situ
164169
speedup
165170
ssh
@@ -186,6 +191,7 @@ symlink
186191
symlinked
187192
symlinking
188193
symlinks
194+
sys
189195
taskdef
190196
templated
191197
templating
@@ -195,6 +201,7 @@ timeouts
195201
timestep
196202
timezone
197203
timezones
204+
tuple
198205
uiserver
199206
unpaused
200207
unpausing
@@ -209,6 +216,7 @@ vs
209216
wallclock
210217
websocket
211218
websockets
219+
whitelist
212220
whitelisting
213221
whitespace
214222
workflow

src/plugins/xtriggers/index.rst

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,70 @@
11
Xtrigger Plugins
22
======================================
33

4-
Xtrigger plugins allow you to install and use xtriggers without them being
5-
in your ``CYLC_PYTHONPATH``.
4+
.. versionadded:: 8.3
65

6+
Xtrigger plugins allow you to install and use
7+
:ref:`xtriggers <Section External Triggers>` without them being
8+
in ``<workflow-dir>/lib/python/`` or ``$CYLC_PYTHONPATH``.
79

8-
Built In Plugins
9-
----------------
10+
.. seealso::
1011

11-
Cylc Flow provides the following xtriggers.
12+
* :ref:`Built-in Clock Triggers`
13+
* :ref:`Built-in Workflow State Triggers`
14+
* :ref:`Built-in Toy Xtriggers`
1215

13-
.. autosummary::
14-
:toctree: built-in
15-
:template: docstring_only.rst
1616

17-
cylc.flow.xtriggers.echo
18-
cylc.flow.xtriggers.workflow_state
19-
cylc.flow.xtriggers.xrandom
20-
21-
.. Note: Autosummary generates files in this directory, these are cleaned
22-
up by `make clean`.
17+
.. _developing.xtrigger.plugins:
2318

2419
Developing ``xtrigger`` plugins
2520
-------------------------------
2621

27-
Cylc uses entry points registered by setuptools to search for xtrigger
28-
plugins.
22+
Cylc uses the ``cylc.xtriggers`` entry point registered by setuptools to search
23+
for xtrigger plugins. Each xtrigger is registered individually.
2924

3025
Example
3126
^^^^^^^
3227

33-
Plugins are registered by registering them with the ``cylc.xtriggers``
34-
entry points. Each xtrigger is registered individually.
28+
Consider a package called ``my_package`` with the following structure:
29+
30+
.. code-block:: python
31+
:caption: ``my_package/foo.py``
32+
33+
def foo():
34+
...
35+
36+
def bar():
37+
...
38+
39+
.. code-block:: python
40+
:caption: ``my_package/baz.py``
41+
42+
def baz():
43+
...
44+
45+
These xtriggers can be registered in the package's ``setup.cfg`` or
46+
``pyproject.toml`` file.
3547

3648
.. code-block:: ini
3749
:caption: ``setup.cfg``
3850
3951
[options.entry_points]
40-
cylc.xtriggers =
41-
foo = my_package.foo:foo
42-
bar = my_package.foo:bar
43-
baz = my_package.baz:baz
52+
cylc.xtriggers =
53+
foo = my_package.foo
54+
bar = my_package.foo
55+
baz = my_package.baz
4456
4557
.. code-block:: toml
4658
:caption: ``pyproject.toml``
4759
4860
[project.entry-points."cylc.xtriggers"]
49-
foo = "my_package.foo:foo"
50-
bar = "my_package.foo:bar"
51-
baz = "my_package.baz:baz"
61+
foo = "my_package.foo"
62+
bar = "my_package.foo"
63+
baz = "my_package.baz"
64+
65+
.. tip::
66+
67+
It is recommended to implement only one xtrigger per module. This allows
68+
you to write a ``validate`` function for each xtrigger - see
69+
:ref:`user-guide.xtrigger-validation-functions`.
5270

src/tutorial/furthertopics/clock-triggered-tasks.rst

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Clock-triggering effectively enables us to tether the "cycle time" to the
1414
.. note::
1515

1616
Clock triggers are :ref:`Section External Triggers`. They differ from
17-
custom external triggers only in that they are provided with Cylc.
17+
custom external triggers only in that they are provided with Cylc, and
18+
that the ``:interval`` suffix has no effect.
1819

1920

2021
Clock Triggering
@@ -135,9 +136,9 @@ Edit the ``[[scheduling]]`` section to read:
135136
initial cycle point = now
136137
final cycle point = +P1D # Run for one day
137138
[[xtriggers]]
138-
quarter_past_trigger = wall_clock(offset=PT15M):PT30S
139-
half_past_trigger = wall_clock(offset=PT30M):PT30S
140-
quarter_to_trigger = wall_clock(offset=PT45M):PT30S
139+
quarter_past_trigger = wall_clock(offset=PT15M)
140+
half_past_trigger = wall_clock(offset=PT30M)
141+
quarter_to_trigger = wall_clock(offset=PT45M)
141142
[[graph]]
142143
PT1H = """
143144
@wall_clock => bell
@@ -165,15 +166,6 @@ Leave your workflow running for a while to confirm it is working as expected
165166
before stopping it.
166167

167168

168-
.. note::
169-
170-
You may have noticed the ``:PT30S`` at the end of each clock trigger
171-
definition. This how often the :ref:`Section External Triggers` is checked.
172-
By default external triggers are checked every 10 seconds, but if there
173-
are a lot of external triggers this can be hard work for the computer
174-
running the workflow and it may not be necessary to check this often.
175-
176-
177169
Summary
178170
-------
179171

src/tutorial/scheduling/further-scheduling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Clock Triggers
7575
[scheduling]
7676
initial cycle point = 2000-01-01T00Z
7777
[[xtriggers]]
78-
PT1H_trigger = wall_clock(offset=-PT1H):PT30S
78+
PT1H_trigger = wall_clock(offset=-PT1H)
7979
[[graph]]
8080
# "daily" will run, at the earliest, one hour before midday.
8181
T12 = @PT1H_trigger => daily

0 commit comments

Comments
 (0)