forked from cylc/cylc-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix xtrigger entry point example and improve docs (#6)
* Fix xtrigger entry point example * Update xtrigger plugins docs
- Loading branch information
Showing
3 changed files
with
82 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,68 @@ | ||
Xtrigger Plugins | ||
====================================== | ||
|
||
Xtrigger plugins allow you to install and use xtriggers without them being | ||
in your ``CYLC_PYTHONPATH``. | ||
.. versionadded:: 8.3 | ||
|
||
Xtrigger plugins allow you to install and use | ||
:ref:`xtriggers <Section External Triggers>` without them being | ||
in ``<workflow-dir>/lib/python/`` or ``$CYLC_PYTHONPATH``. | ||
|
||
Built In Plugins | ||
---------------- | ||
.. seealso:: | ||
|
||
Cylc Flow provides the following xtriggers. | ||
* :ref:`Built-in Clock Triggers` | ||
* :ref:`Built-in Workflow State Triggers` | ||
|
||
.. autosummary:: | ||
:toctree: built-in | ||
:template: docstring_only.rst | ||
|
||
cylc.flow.xtriggers.echo.echo | ||
cylc.flow.xtriggers.workflow_state.workflow_state | ||
cylc.flow.xtriggers.xrandom.xrandom | ||
|
||
.. Note: Autosummary generates files in this directory, these are cleaned | ||
up by `make clean`. | ||
|
||
.. _developing.xtrigger.plugins: | ||
|
||
Developing ``xtrigger`` plugins | ||
------------------------------- | ||
|
||
Cylc uses entry points registered by setuptools to search for xtrigger | ||
plugins. | ||
Cylc uses the ``cylc.xtriggers`` entry point registered by setuptools to search | ||
for xtrigger plugins. Each xtrigger is registered individually. | ||
|
||
Example | ||
^^^^^^^ | ||
|
||
Plugins are registered by registering them with the ``cylc.xtriggers`` | ||
entry points. Each xtrigger is registered individually. | ||
Consider a package called ``my_package`` with the following structure: | ||
|
||
.. code-block:: python | ||
:caption: ``my_package/foo.py`` | ||
def foo(): | ||
... | ||
def bar(): | ||
... | ||
.. code-block:: python | ||
:caption: ``my_package/baz.py`` | ||
def baz(): | ||
... | ||
These xtriggers can be registered in the package's ``setup.cfg`` or | ||
``pyproject.toml`` file. | ||
|
||
.. code-block:: ini | ||
:caption: ``setup.cfg`` | ||
[options.entry_points] | ||
cylc.xtriggers = | ||
foo = my_package.foo:foo | ||
bar = my_package.foo:bar | ||
baz = my_package.baz:baz | ||
cylc.xtriggers = | ||
foo = my_package.foo | ||
bar = my_package.foo | ||
baz = my_package.baz | ||
.. code-block:: toml | ||
:caption: ``pyproject.toml`` | ||
[project.entry-points."cylc.xtriggers"] | ||
foo = "my_package.foo:foo" | ||
bar = "my_package.foo:bar" | ||
baz = "my_package.baz:baz" | ||
foo = "my_package.foo" | ||
bar = "my_package.foo" | ||
baz = "my_package.baz" | ||
.. tip:: | ||
|
||
It is recommended to implement only one xtrigger per module. This allows | ||
you to write a ``validate`` function for each xtrigger - see | ||
:ref:`xrandom.validate` for an example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters