Skip to content

Commit

Permalink
make code refs work
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Apr 24, 2024
1 parent bfc92d1 commit f445bbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/plugins/xtriggers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ These xtriggers can be registered in the package's ``setup.cfg`` or

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.
:py:mod:`cylc.flow.xtriggers.xrandom` for an example.
36 changes: 10 additions & 26 deletions src/user-guide/writing-workflows/external-triggers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,22 @@ properties:
- The module containing the xtrigger function may also contain a ``validate``
function taking a single argument, which is a dictionary of all the arguments
passed to the xtrigger function in ``flow.cylc``. It should raise an
exception if validation fails. See :py:mod:`cylc.flow.xtriggers.xrandom` for an example
of a validate function.
exception if validation fails. See
:py:mod:`cylc.flow.xtriggers.xrandom`
for an example of a validate function.
- The arguments you call the xtrigger function with are automatically
validated against the function signature, so you don't necessarily need
to check for the presence of arguments or their types in the validate
function. However, you may want to check that the values are of the correct
type or within a certain range.

.. note::

Trigger functions cannot store data Pythonically between invocations
because each call is executed in an independent process in the process
pool. If necessary the filesystem can be used for this purpose.


.. spelling:word-list::
vv
Expand Down Expand Up @@ -383,7 +390,7 @@ time (useful for testing the effect of a long-running trigger function
- which should be avoided) and has a configurable random chance of
success. The function signature is:

.. autofunction:: cylc.flow.xtriggers.xrandom.xrandom
.. automodule:: cylc.flow.xtriggers.xrandom

The ``percent`` argument sets the odds of success in any given call;
``secs`` is the number of seconds to sleep before returning; and the
Expand All @@ -397,29 +404,6 @@ An example xrandom trigger workflow:
.. literalinclude:: ../../workflows/xtrigger/xrandom/flow.cylc
:language: cylc

.. _xrandom.validate:

Validation example using xrandom
""""""""""""""""""""""""""""""""

The ``xrandom`` xtrigger module contains an example of an xtrigger validation
function.

Validation functions are run on the inputs to the xtrigger when calling
``cylc validate``, and should raise an exception with user facing error
messages if validation fails.

.. autofunction:: cylc.flow.xtriggers.xrandom.validate

.. tip::

The arguments you call the xtrigger function with are automatically
validated against the function signature, so you don't necessarily need
to check for the presence of arguments or their types in the validate
function. However, you may want to check that the values are of the correct
type or within a certain range.


.. _Current Trigger Function Limitations:

Current Limitations
Expand Down

0 comments on commit f445bbf

Please sign in to comment.