Skip to content

Commit 402917f

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1636 from teojgo/enhancement/drop_override_support
[feat] Drop support of pipeline stage method override
2 parents dbf60bb + ffa2416 commit 402917f

File tree

4 files changed

+97
-64
lines changed

4 files changed

+97
-64
lines changed

docs/migration_2_to_3.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Pipeline methods and hooks
6565

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.
68-
ReFrame 3.0 deprecates the old practice of overriding pipeline stage methods in favor of using pipeline hooks.
68+
ReFrame 3.0 deprecates the old practice of overriding pipeline stage methods in favor of using pipeline hooks and ReFrame 3.4 disables that by default.
6969
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.
7070
The following is a typical example of that:
7171

@@ -93,7 +93,7 @@ Alternatively, this example could have been written as follows:
9393
self.build_system.cflags = ['-qopenmp']
9494
9595
96-
This syntax now issues a deprecation warning.
96+
This syntax is no longer valid and it will raise a deprecation warning for ReFrame versions >= 3.0 and a reframe syntax error for versions >=3.4.
9797
Rewriting this using pipeline hooks is quite straightforward and leads to nicer and more intuitive code:
9898

9999
.. code:: python
@@ -109,6 +109,10 @@ Rewriting this using pipeline hooks is quite straightforward and leads to nicer
109109
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.
110110
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``.
111111

112+
.. warning::
113+
.. versionchanged:: 3.4
114+
Overriding a pipeline stage method is no longer allowed and a reframe syntax error is raised.
115+
112116

113117
--------------------------------
114118
Force override a pipeline method
@@ -125,7 +129,7 @@ In this case, all you have to do is mark your test class as "special", and ReFra
125129
super().setup(partition, environ, **job_opts)
126130
127131
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.
132+
If you try to override the ``setup()`` method in any of the subclasses of ``MyExtendedTest``, it will again result in a reframe syntax error, which is a desired behavior since the subclasses should be normal tests.
129133

130134

131135
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: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import reframe.utility.sanity as sn
3131
import reframe.utility.typecheck as typ
3232
import reframe.utility.udeps as udeps
33-
from reframe.core.backends import (getlauncher, getscheduler)
33+
from reframe.core.backends import getlauncher, getscheduler
3434
from reframe.core.buildsystems import BuildSystemField
3535
from reframe.core.containers import ContainerPlatformField
3636
from reframe.core.deferrable import _DeferredExpression
@@ -1094,6 +1094,11 @@ def setup(self, partition, environ, **job_opts):
10941094
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
10951095
more details.
10961096
1097+
.. versionchanged:: 3.4
1098+
Overriding this method directly in no longer allowed. See `here
1099+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1100+
more details.
1101+
10971102
'''
10981103
self._current_partition = partition
10991104
self._current_environ = environ
@@ -1135,6 +1140,11 @@ def compile(self):
11351140
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
11361141
more details.
11371142
1143+
.. versionchanged:: 3.4
1144+
Overriding this method directly in no longer allowed. See `here
1145+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1146+
more details.
1147+
11381148
'''
11391149
if not self._current_environ:
11401150
raise PipelineError('no programming environment set')
@@ -1232,6 +1242,11 @@ def compile_wait(self):
12321242
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
12331243
more details.
12341244
1245+
.. versionchanged:: 3.4
1246+
Overriding this method directly in no longer allowed. See `here
1247+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1248+
more details.
1249+
12351250
'''
12361251
self._build_job.wait()
12371252

@@ -1254,6 +1269,12 @@ def run(self):
12541269
special test. See `here
12551270
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
12561271
more details.
1272+
1273+
.. versionchanged:: 3.4
1274+
Overriding this method directly in no longer allowed. See `here
1275+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1276+
more details.
1277+
12571278
'''
12581279
if not self.current_system or not self._current_partition:
12591280
raise PipelineError('no system or system partition is set')
@@ -1359,6 +1380,12 @@ def run_complete(self):
13591380
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
13601381
more details.
13611382
1383+
1384+
.. versionchanged:: 3.4
1385+
Overriding this method directly in no longer allowed. See `here
1386+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1387+
more details.
1388+
13621389
'''
13631390
if not self._job:
13641391
return True
@@ -1389,6 +1416,11 @@ def run_wait(self):
13891416
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
13901417
more details.
13911418
1419+
.. versionchanged:: 3.4
1420+
Overriding this method directly in no longer allowed. See `here
1421+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1422+
more details.
1423+
13921424
'''
13931425
self._job.wait()
13941426

@@ -1430,6 +1462,11 @@ def check_sanity(self):
14301462
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
14311463
more details.
14321464
1465+
.. versionchanged:: 3.4
1466+
Overriding this method directly in no longer allowed. See `here
1467+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1468+
more details.
1469+
14331470
'''
14341471
if rt.runtime().get_option('general/0/trap_job_errors'):
14351472
sanity_patterns = [
@@ -1463,6 +1500,11 @@ def check_performance(self):
14631500
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
14641501
more details.
14651502
1503+
.. versionchanged:: 3.4
1504+
Overriding this method directly in no longer allowed. See `here
1505+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1506+
more details.
1507+
14661508
'''
14671509
if self.perf_patterns is None:
14681510
return
@@ -1581,6 +1623,11 @@ def cleanup(self, remove_files=False):
15811623
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
15821624
more details.
15831625
1626+
.. versionchanged:: 3.4
1627+
Overriding this method directly in no longer allowed. See `here
1628+
<migration_2_to_3.html#force-override-a-pipeline-method>`__ for
1629+
more details.
1630+
15841631
'''
15851632
aliased = os.path.samefile(self._stagedir, self._outputdir)
15861633
if aliased:

unittests/test_loader.py

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import pytest
88

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

1613

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

8481

8582
def test_special_test():
86-
with pytest.warns(ReframeDeprecationWarning):
83+
with pytest.raises(ReframeSyntaxError):
8784
@rfm.simple_test
88-
class TestDeprecated(rfm.RegressionTest):
85+
class TestOverride(rfm.RegressionTest):
8986
def setup(self, partition, environ, **job_opts):
9087
super().setup(system, environ, **job_opts)
9188

92-
with pytest.warns(ReframeDeprecationWarning):
89+
with pytest.raises(ReframeSyntaxError):
9390
@rfm.simple_test
94-
class TestDeprecatedRunOnly(rfm.RunOnlyRegressionTest):
91+
class TestOverrideRunOnly(rfm.RunOnlyRegressionTest):
9592
def setup(self, partition, environ, **job_opts):
9693
super().setup(system, environ, **job_opts)
9794

98-
with pytest.warns(ReframeDeprecationWarning):
95+
with pytest.raises(ReframeSyntaxError):
9996
@rfm.simple_test
100-
class TestDeprecatedCompileOnly(rfm.CompileOnlyRegressionTest):
97+
class TestOverrideCompileOnly(rfm.CompileOnlyRegressionTest):
10198
def setup(self, partition, environ, **job_opts):
10299
super().setup(system, environ, **job_opts)
103100

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
101+
@rfm.simple_test
102+
class TestSimple(rfm.RegressionTest):
103+
def __init__(self):
104+
pass
115105

116-
@rfm.simple_test
117-
class TestSpecial(rfm.RegressionTest, special=True):
118-
def __init__(self):
119-
pass
106+
@rfm.simple_test
107+
class TestSpecial(rfm.RegressionTest, special=True):
108+
def __init__(self):
109+
pass
120110

121-
def setup(self, partition, environ, **job_opts):
122-
super().setup(system, environ, **job_opts)
111+
def setup(self, partition, environ, **job_opts):
112+
super().setup(system, environ, **job_opts)
123113

124-
@rfm.simple_test
125-
class TestSpecialRunOnly(rfm.RunOnlyRegressionTest,
126-
special=True):
127-
def __init__(self):
128-
pass
114+
@rfm.simple_test
115+
class TestSpecialRunOnly(rfm.RunOnlyRegressionTest,
116+
special=True):
117+
def __init__(self):
118+
pass
129119

130-
def setup(self, partition, environ, **job_opts):
131-
super().setup(system, environ, **job_opts)
120+
def setup(self, partition, environ, **job_opts):
121+
super().setup(system, environ, **job_opts)
132122

133-
def run(self):
134-
super().run()
123+
def run(self):
124+
super().run()
135125

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)
126+
@rfm.simple_test
127+
class TestSpecialCompileOnly(rfm.CompileOnlyRegressionTest,
128+
special=True):
129+
def __init__(self):
130+
pass
144131

145-
def run(self):
146-
super().run()
132+
def setup(self, partition, environ, **job_opts):
133+
super().setup(system, environ, **job_opts)
147134

148-
assert not any(isinstance(w.message, ReframeDeprecationWarning)
149-
for w in warnings)
135+
def run(self):
136+
super().run()
150137

151-
with pytest.warns(ReframeDeprecationWarning) as warnings:
138+
with pytest.raises(ReframeSyntaxError):
152139
@rfm.simple_test
153140
class TestSpecialDerived(TestSpecial):
154141
def __init__(self):
@@ -157,21 +144,16 @@ def __init__(self):
157144
def setup(self, partition, environ, **job_opts):
158145
super().setup(system, environ, **job_opts)
159146

160-
def run(self):
161-
super().run()
162-
163-
assert len(warnings) == 2
164-
165147
@rfm.simple_test
166148
class TestFinal(rfm.RegressionTest):
167149
def __init__(self):
168150
pass
169151

170152
@rfm.final
171-
def my_new_final(seld):
153+
def my_new_final(self):
172154
pass
173155

174-
with pytest.warns(ReframeDeprecationWarning):
156+
with pytest.raises(ReframeSyntaxError):
175157
@rfm.simple_test
176158
class TestFinalDerived(TestFinal):
177159
def my_new_final(self, a, b):

0 commit comments

Comments
 (0)