Skip to content

Commit 397fdce

Browse files
author
Theofilos Manitaras
committed
Drop support of pipeline stage method override
1 parent edfd903 commit 397fdce

File tree

4 files changed

+114
-60
lines changed

4 files changed

+114
-60
lines changed

docs/migration_2_to_3.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Pipeline methods and hooks
6666
ReFrame 2.20 introduced a new powerful mechanism for attaching arbitrary functions hooks at the different pipeline stages.
6767
This mechanism provides an easy way to configure and extend the functionality of a test, eliminating essentially the need to override pipeline stages for this purpose.
6868
ReFrame 3.0 deprecates the old practice of overriding pipeline stage methods in favor of using pipeline hooks.
69+
From ReFrame 3.4, overriding pipeline stage methods is no longer allowed.
6970
In the old syntax, it was quite common to override the ``setup()`` method, in order to configure your test based on the current programming environment or the current system partition.
7071
The following is a typical example of that:
7172

@@ -93,7 +94,7 @@ Alternatively, this example could have been written as follows:
9394
self.build_system.cflags = ['-qopenmp']
9495
9596
96-
This syntax now issues a deprecation warning.
97+
This syntax is no longer valid and a ``ReframeSyntaxError`` is raised.
9798
Rewriting this using pipeline hooks is quite straightforward and leads to nicer and more intuitive code:
9899

99100
.. code:: python
@@ -109,6 +110,10 @@ Rewriting this using pipeline hooks is quite straightforward and leads to nicer
109110
You could equally attach this function to run after the "setup" phase with ``@rfm.run_after('setup')``, as in the original example, but attaching it to the "compile" phase makes more sense.
110111
However, you can't attach this function *before* the "setup" phase, because the ``current_environ`` will not be available and it will be still ``None``.
111112

113+
.. warning::
114+
.. versionchanged:: 3.4
115+
Overriding a pipeline stage method is no longer allowed and a ``ReframeSyntaxError`` is raised.
116+
112117

113118
--------------------------------
114119
Force override a pipeline method
@@ -125,7 +130,7 @@ In this case, all you have to do is mark your test class as "special", and ReFra
125130
super().setup(partition, environ, **job_opts)
126131
127132
128-
If you try to override the ``setup()`` method in any of the subclasses of ``MyExtendedTest``, you will still get a deprecation warning, which a desired behavior since the subclasses should be normal tests.
133+
If you try to override the ``setup()`` method in any of the subclasses of ``MyExtendedTest``, will again result in a ``ReframeSyntaxError``, which a desired behavior since the subclasses should be normal tests.
129134

130135

131136
Getting schedulers and launchers by name

reframe/core/meta.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55

66
#
7-
# Met-class for creating regression tests.
7+
# Meta-class for creating regression tests.
88
#
99

10-
from reframe.core.warnings import user_deprecation_warning
10+
from reframe.core.exceptions import ReframeSyntaxError
1111

1212

1313
class RegressionTestMeta(type):
@@ -57,5 +57,5 @@ def __init__(cls, name, bases, namespace, **kwargs):
5757
msg = (f"'{cls.__qualname__}.{v.__name__}' attempts to "
5858
f"override final method "
5959
f"'{b.__qualname__}.{v.__name__}'; "
60-
f"consider using the pipeline hooks instead")
61-
user_deprecation_warning(msg)
60+
f"you should use the pipeline hooks instead")
61+
raise ReframeSyntaxError(msg)

reframe/core/pipeline.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,12 @@ def setup(self, partition, environ, **job_opts):
10921092
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
10931093
more details.
10941094
1095+
.. versionchanged:: 3.4
1096+
Overriding this method directly unless you are in
1097+
special test. See `here
1098+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1099+
more details.
1100+
10951101
'''
10961102
self._current_partition = partition
10971103
self._current_environ = environ
@@ -1133,6 +1139,12 @@ def compile(self):
11331139
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
11341140
more details.
11351141
1142+
.. versionchanged:: 3.4
1143+
Overriding this method directly unless you are in
1144+
special test. See `here
1145+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1146+
more details.
1147+
11361148
'''
11371149
if not self._current_environ:
11381150
raise PipelineError('no programming environment set')
@@ -1230,6 +1242,12 @@ def compile_wait(self):
12301242
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
12311243
more details.
12321244
1245+
.. versionchanged:: 3.4
1246+
Overriding this method directly unless you are in
1247+
special test. See `here
1248+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1249+
more details.
1250+
12331251
'''
12341252
self._build_job.wait()
12351253

@@ -1252,6 +1270,13 @@ def run(self):
12521270
special test. See `here
12531271
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
12541272
more details.
1273+
1274+
.. versionchanged:: 3.4
1275+
Overriding this method directly unless you are in
1276+
special test. See `here
1277+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1278+
more details.
1279+
12551280
'''
12561281
if not self.current_system or not self._current_partition:
12571282
raise PipelineError('no system or system partition is set')
@@ -1357,6 +1382,13 @@ def run_complete(self):
13571382
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
13581383
more details.
13591384
1385+
1386+
.. versionchanged:: 3.4
1387+
Overriding this method directly unless you are in
1388+
special test. See `here
1389+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1390+
more details.
1391+
13601392
'''
13611393
if not self._job:
13621394
return True
@@ -1387,6 +1419,14 @@ def run_wait(self):
13871419
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
13881420
more details.
13891421
1422+
.. versionchanged:: 3.4
1423+
Overriding this method directly unless you are in
1424+
special test. See `here
1425+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1426+
more details.
1427+
1428+
1429+
13901430
'''
13911431
self._job.wait()
13921432

@@ -1428,6 +1468,14 @@ def check_sanity(self):
14281468
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
14291469
more details.
14301470
1471+
.. versionchanged:: 3.4
1472+
Overriding this method directly unless you are in
1473+
special test. See `here
1474+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1475+
more details.
1476+
1477+
1478+
14311479
'''
14321480
if rt.runtime().get_option('general/0/trap_job_errors'):
14331481
sanity_patterns = [
@@ -1461,6 +1509,14 @@ def check_performance(self):
14611509
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
14621510
more details.
14631511
1512+
.. versionchanged:: 3.4
1513+
Overriding this method directly unless you are in
1514+
special test. See `here
1515+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1516+
more details.
1517+
1518+
1519+
14641520
'''
14651521
if self.perf_patterns is None:
14661522
return
@@ -1579,6 +1635,14 @@ def cleanup(self, remove_files=False):
15791635
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
15801636
more details.
15811637
1638+
.. versionchanged:: 3.4
1639+
Overriding this method directly unless you are in
1640+
special test. See `here
1641+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1642+
more details.
1643+
1644+
1645+
15821646
'''
15831647
aliased = os.path.samefile(self._stagedir, self._outputdir)
15841648
if aliased:

unittests/test_loader.py

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import reframe as rfm
1010
from reframe.core.exceptions import (ConfigError, NameConflictError,
11-
RegressionTestLoadError)
11+
RegressionTestLoadError,
12+
ReframeSyntaxError)
1213
from reframe.core.systems import System
13-
from reframe.core.warnings import ReframeDeprecationWarning
1414
from reframe.frontend.loader import RegressionCheckLoader
1515

1616

@@ -83,72 +83,62 @@ def test_load_bad_init(loader):
8383

8484

8585
def test_special_test():
86-
with pytest.warns(ReframeDeprecationWarning):
86+
with pytest.raises(ReframeSyntaxError):
8787
@rfm.simple_test
88-
class TestDeprecated(rfm.RegressionTest):
88+
class TestOverride(rfm.RegressionTest):
8989
def setup(self, partition, environ, **job_opts):
9090
super().setup(system, environ, **job_opts)
9191

92-
with pytest.warns(ReframeDeprecationWarning):
92+
with pytest.raises(ReframeSyntaxError):
9393
@rfm.simple_test
94-
class TestDeprecatedRunOnly(rfm.RunOnlyRegressionTest):
94+
class TestOverrideRunOnly(rfm.RunOnlyRegressionTest):
9595
def setup(self, partition, environ, **job_opts):
9696
super().setup(system, environ, **job_opts)
9797

98-
with pytest.warns(ReframeDeprecationWarning):
98+
with pytest.raises(ReframeSyntaxError):
9999
@rfm.simple_test
100-
class TestDeprecatedCompileOnly(rfm.CompileOnlyRegressionTest):
100+
class TestOverrideCompileOnly(rfm.CompileOnlyRegressionTest):
101101
def setup(self, partition, environ, **job_opts):
102102
super().setup(system, environ, **job_opts)
103103

104-
with pytest.warns(ReframeDeprecationWarning):
105-
@rfm.simple_test
106-
class TestDeprecatedCompileOnlyDerived(TestDeprecatedCompileOnly):
107-
def setup(self, partition, environ, **job_opts):
108-
super().setup(system, environ, **job_opts)
109-
110-
with pytest.warns(None) as warnings:
111-
@rfm.simple_test
112-
class TestSimple(rfm.RegressionTest):
113-
def __init__(self):
114-
pass
104+
@rfm.simple_test
105+
class TestSimple(rfm.RegressionTest):
106+
def __init__(self):
107+
pass
115108

116-
@rfm.simple_test
117-
class TestSpecial(rfm.RegressionTest, special=True):
118-
def __init__(self):
119-
pass
109+
@rfm.simple_test
110+
class TestSpecial(rfm.RegressionTest, special=True):
111+
def __init__(self):
112+
pass
120113

121-
def setup(self, partition, environ, **job_opts):
122-
super().setup(system, environ, **job_opts)
114+
def setup(self, partition, environ, **job_opts):
115+
super().setup(system, environ, **job_opts)
123116

124-
@rfm.simple_test
125-
class TestSpecialRunOnly(rfm.RunOnlyRegressionTest,
126-
special=True):
127-
def __init__(self):
128-
pass
117+
@rfm.simple_test
118+
class TestSpecialRunOnly(rfm.RunOnlyRegressionTest,
119+
special=True):
120+
def __init__(self):
121+
pass
129122

130-
def setup(self, partition, environ, **job_opts):
131-
super().setup(system, environ, **job_opts)
123+
def setup(self, partition, environ, **job_opts):
124+
super().setup(system, environ, **job_opts)
132125

133-
def run(self):
134-
super().run()
126+
def run(self):
127+
super().run()
135128

136-
@rfm.simple_test
137-
class TestSpecialCompileOnly(rfm.CompileOnlyRegressionTest,
138-
special=True):
139-
def __init__(self):
140-
pass
141-
142-
def setup(self, partition, environ, **job_opts):
143-
super().setup(system, environ, **job_opts)
129+
@rfm.simple_test
130+
class TestSpecialCompileOnly(rfm.CompileOnlyRegressionTest,
131+
special=True):
132+
def __init__(self):
133+
pass
144134

145-
def run(self):
146-
super().run()
135+
def setup(self, partition, environ, **job_opts):
136+
super().setup(system, environ, **job_opts)
147137

148-
assert not any(isinstance(w.message, ReframeDeprecationWarning)
149-
for w in warnings)
138+
def run(self):
139+
super().run()
150140

151-
with pytest.warns(ReframeDeprecationWarning) as warnings:
141+
with pytest.raises(ReframeSyntaxError):
152142
@rfm.simple_test
153143
class TestSpecialDerived(TestSpecial):
154144
def __init__(self):
@@ -157,21 +147,16 @@ def __init__(self):
157147
def setup(self, partition, environ, **job_opts):
158148
super().setup(system, environ, **job_opts)
159149

160-
def run(self):
161-
super().run()
162-
163-
assert len(warnings) == 2
164-
165150
@rfm.simple_test
166151
class TestFinal(rfm.RegressionTest):
167152
def __init__(self):
168153
pass
169154

170155
@rfm.final
171-
def my_new_final(seld):
156+
def my_new_final(self):
172157
pass
173158

174-
with pytest.warns(ReframeDeprecationWarning):
159+
with pytest.raises(ReframeSyntaxError):
175160
@rfm.simple_test
176161
class TestFinalDerived(TestFinal):
177162
def my_new_final(self, a, b):

0 commit comments

Comments
 (0)