|
1 | 1 | Xtrigger Plugins
|
2 | 2 | ======================================
|
3 | 3 |
|
4 |
| -Xtrigger plugins allow you to install and use xtriggers without them being |
5 |
| -in your ``CYLC_PYTHONPATH``. |
| 4 | +.. versionadded:: 8.3 |
6 | 5 |
|
| 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``. |
7 | 9 |
|
8 |
| -Built In Plugins |
9 |
| ----------------- |
| 10 | +.. seealso:: |
10 | 11 |
|
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` |
12 | 15 |
|
13 |
| -.. autosummary:: |
14 |
| - :toctree: built-in |
15 |
| - :template: docstring_only.rst |
16 | 16 |
|
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: |
23 | 18 |
|
24 | 19 | Developing ``xtrigger`` plugins
|
25 | 20 | -------------------------------
|
26 | 21 |
|
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. |
29 | 24 |
|
30 | 25 | Example
|
31 | 26 | ^^^^^^^
|
32 | 27 |
|
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. |
35 | 47 |
|
36 | 48 | .. code-block:: ini
|
37 | 49 | :caption: ``setup.cfg``
|
38 | 50 |
|
39 | 51 | [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 |
44 | 56 |
|
45 | 57 | .. code-block:: toml
|
46 | 58 | :caption: ``pyproject.toml``
|
47 | 59 |
|
48 | 60 | [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`. |
52 | 70 |
|
0 commit comments