Skip to content

Commit 194762e

Browse files
authored
Merge branch 'develop' into feat/job-submission-time-loggable
2 parents 3757091 + b1a3391 commit 194762e

File tree

9 files changed

+140
-93
lines changed

9 files changed

+140
-93
lines changed

docs/regression_test_api.rst

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ So although a "post-init" and a "pre-setup" hook will both run *after* a test ha
111111
the post-init hook will execute *right after* the test is initialized.
112112
The framework will then continue with other activities and it will execute the pre-setup hook *just before* it schedules the test for executing its setup stage.
113113

114-
Pipeline hooks are executed in reverse MRO order, i.e., the hooks of the least specialized class will be executed first.
114+
Pipeline hooks are normally executed in reverse MRO order, i.e., the hooks of the least specialized class will be executed first.
115115
In the following example, :func:`BaseTest.x` will execute before :func:`DerivedTest.y`:
116116

117-
.. code:: python
117+
.. code-block:: python
118118
119119
class BaseTest(rfm.RegressionTest):
120120
@run_after('setup')
@@ -127,6 +127,34 @@ In the following example, :func:`BaseTest.x` will execute before :func:`DerivedT
127127
'''Hook y'''
128128
129129
130+
This order can be altered using the ``always_last`` argument of the :func:`@run_before <reframe.core.builtins.run_before>` and :func:`@run_after <reframe.core.builtins.run_after>` decorators.
131+
In this case, all hooks of the same stage defined with ``always_last=True`` will be executed in MRO order at the end of the stage's hook chain.
132+
For example, given the following hierarchy:
133+
134+
.. code-block:: python
135+
136+
class X(rfm.RunOnlyRegressionTest):
137+
@run_before('run', always_last=True)
138+
def hook_a(self): pass
139+
140+
@run_before('run')
141+
def hook_b(self): pass
142+
143+
class Y(X):
144+
@run_before('run', always_last=True)
145+
def hook_c(self): pass
146+
147+
@run_before('run')
148+
def hook_d(self): pass
149+
150+
151+
the run hooks of :class:`Y` will be executed as follows:
152+
153+
.. code-block:: console
154+
155+
X.hook_b, Y.hook_d, Y.hook_c, X.hook_a
156+
157+
130158
.. seealso::
131159
- :func:`@run_before <reframe.core.builtins.run_before>`, :func:`@run_after <reframe.core.builtins.run_after>` decorators
132160

@@ -146,6 +174,12 @@ In the following example, :func:`BaseTest.x` will execute before :func:`DerivedT
146174
with osext.change_dir(self.stagedir):
147175
...
148176
177+
.. note::
178+
In versions prior to 4.3.4, overriding a pipeline hook in a subclass would re-attach it from scratch in the stage, therefore changing its execution order relative to other hooks of the superclass.
179+
This is fixed in versions >= 4.3.4 where the execution order of the hook is not changed.
180+
However, the fix may break existing workaround code that used to call explicitly the base class' hook from the derived one.
181+
Check issue `#3012 <https://github.com/reframe-hpc/reframe/issues/3012>`__ for details on how to properly address this.
182+
149183
.. warning::
150184
.. versionchanged:: 3.7.0
151185
Declaring pipeline hooks using the same name functions from the :py:mod:`reframe` or :py:mod:`reframe.core.decorators` modules is now deprecated.

reframe/core/builtins.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ def run_before(stage, *, always_last=False):
4848
:param stage: The pipeline stage where this function will be attached to.
4949
See :ref:`pipeline-hooks` for the list of valid stage values.
5050
51-
:param always_last: Run this hook always as the last one of the stage. In
52-
a whole test hierarchy, only a single hook can be explicitly pinned at
53-
the end of the same-stage sequence of hooks. If another hook is
54-
declared as ``always_last`` in the same stage, an error will be
55-
issued.
51+
:param always_last: Run this hook at the end of the stage's hook chain
52+
instead of the beginning. If multiple tests set this flag for a hook
53+
in the same stage, then all ``always_last`` hooks will be executed in
54+
MRO order at the end of stage's hook chain. See :ref:`pipeline-hooks`
55+
for an example execution.
5656
5757
.. versionchanged:: 4.4
5858
The ``always_last`` argument was added.
5959
60+
.. versionchanged:: 4.5
61+
Multiple tests can set ``always_last`` in the same stage.
62+
6063
'''
6164

6265
return hooks.attach_to('pre_' + stage, always_last)

reframe/core/parameters.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ class AbstractB(Bar):
121121
122122
:param loggable: Mark this parameter as loggable. If :obj:`True`, this
123123
parameter will become a log record attribute under the name
124-
``check_NAME``, where ``NAME`` is the name of the parameter.
124+
``check_NAME``, where ``NAME`` is the name of the parameter (default:
125+
:obj:`True`)
125126
126127
:returns: A new test parameter.
127128
@@ -130,10 +131,14 @@ class AbstractB(Bar):
130131
131132
.. versionadded:: 3.11.0
132133
The ``loggable`` argument is added.
134+
135+
.. versionchanged:: 4.5
136+
Parameters are now loggable by default.
137+
133138
'''
134139

135140
def __init__(self, values=None, inherit_params=False,
136-
filter_params=None, fmt=None, loggable=False):
141+
filter_params=None, fmt=None, loggable=True):
137142
if values is None:
138143
values = []
139144

0 commit comments

Comments
 (0)