Skip to content

Commit 45b1f5e

Browse files
author
Vasileios Karakasis
authored
Merge branch 'master' into spack-default-env
2 parents 5944c20 + 1d33ac0 commit 45b1f5e

File tree

28 files changed

+357
-280
lines changed

28 files changed

+357
-280
lines changed

docs/configure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ You can view logger's log level as a general cut off.
194194
For example, if we have set it to ``warning``, no debug or informational messages would ever be printed.
195195

196196
Finally, there is a special set of handlers for handling performance log messages.
197-
Performance log messages are generated *only* for `performance tests <tutorial_basics.html#writing-a-performance-test>`__, i.e., tests defining the :attr:`perf_patterns <reframe.core.pipeline.RegressionTest.perf_patterns>` attribute.
197+
Performance log messages are generated *only* for `performance tests <tutorial_basics.html#writing-a-performance-test>`__, i.e., tests defining the :attr:`~reframe.core.pipeline.RegressionTest.perf_variables` or the :attr:`~reframe.core.pipeline.RegressionTest.perf_patterns` attributes.
198198
The performance log handlers are stored in the ``handlers_perflog`` property.
199199
The ``filelog`` handler used in this example will create a file per test and per system/partition combination (``./<system>/<partition>/<testname>.log``) and will append to it the obtained performance data every time a performance test is run.
200200
Notice how the message to be logged is structured in the ``format`` property, such that it can be easily parsed from post processing tools.

docs/tutorial_advanced.rst

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ Let's have a look at the test itself:
135135
136136
137137
.. literalinclude:: ../tutorials/advanced/makefiles/maketest.py
138-
:lines: 6-29
139-
:emphasize-lines: 18,22-24
138+
:lines: 6-27
139+
:emphasize-lines: 18,22
140140

141141
First, if you're using any build system other than ``SingleSource``, you must set the :attr:`executable` attribute of the test, because ReFrame cannot know what is the actual executable to be run.
142142
We then set the build system to :class:`~reframe.core.buildsystems.Make` and set the preprocessor flags as we would do with the :class:`SingleSource` build system.
@@ -161,7 +161,7 @@ Let's inspect the build script generated by ReFrame:
161161
162162
trap _onerror ERR
163163
164-
make -j 1 CPPFLAGS="-DELEM_TYPE=float"
164+
make -j 1 CC="cc" CXX="CC" FC="ftn" NVCC="nvcc" CPPFLAGS="-DELEM_TYPE=float"
165165
166166
167167
The compiler variables (``CC``, ``CXX`` etc.) are set based on the corresponding values specified in the `configuration <config_reference.html#environment-configuration>`__ of the current environment.
@@ -249,7 +249,7 @@ Writing a Run-Only Regression Test
249249
----------------------------------
250250

251251
There are cases when it is desirable to perform regression testing for an already built executable.
252-
In the following test we use simply the ``echo`` Bash shell command to print a random integer between specific lower and upper bounds:
252+
In the following test we use simply the ``echo`` Bash shell command to print a random integer between specific lower and upper bounds.
253253
Here is the full regression test:
254254

255255
.. code-block:: console
@@ -281,7 +281,7 @@ The following test is a compile-only version of the :class:`MakefileTest` presen
281281
282282
283283
.. literalinclude:: ../tutorials/advanced/makefiles/maketest.py
284-
:lines: 32-
284+
:lines: 30-
285285
:emphasize-lines: 2
286286

287287
What is worth noting here is that the standard output and standard error of the test, which are accessible through the :attr:`~reframe.core.pipeline.RegressionTest.stdout` and :attr:`~reframe.core.pipeline.RegressionTest.stderr` attributes, correspond now to the standard output and error of the compilation command.
@@ -337,7 +337,7 @@ Notice how the parameters are expanded in each of the individual tests:
337337
Applying a Sanity Function Iteratively
338338
--------------------------------------
339339

340-
It is often the case that a common sanity pattern has to be applied many times.
340+
It is often the case that a common sanity function has to be applied many times.
341341
The following script prints 100 random integers between the limits given by the environment variables ``LOWER`` and ``UPPER``.
342342

343343
.. code-block:: console
@@ -372,7 +372,7 @@ There is still a small complication that needs to be addressed.
372372
As a direct replacement of the built-in :py:func:`all` function, ReFrame's :func:`~reframe.utility.sanity.all` sanity function returns :class:`True` for empty iterables, which is not what we want.
373373
So we must make sure that all 100 numbers are generated.
374374
This is achieved by the ``sn.assert_eq(sn.count(numbers), 100)`` statement, which uses the :func:`~reframe.utility.sanity.count` sanity function for counting the generated numbers.
375-
Finally, we need to combine these two conditions to a single deferred expression that will be assigned to the test's :attr:`sanity_patterns`.
375+
Finally, we need to combine these two conditions to a single deferred expression that will be returned by the test's :attr:`@sanity_function<reframe.core.pipeline.RegressionMixin.sanity_function>`.
376376
We accomplish this by using the :func:`~reframe.utility.sanity.all` sanity function.
377377

378378
For more information about how exactly sanity functions work and how their execution is deferred, please refer to :doc:`deferrables`.
@@ -458,7 +458,7 @@ Here is the test:
458458
459459
460460
.. literalinclude:: ../tutorials/advanced/jobopts/eatmemory.py
461-
:lines: 6-23
461+
:lines: 6-25
462462
:emphasize-lines: 12-14
463463

464464
Each ReFrame test has an associated `run job descriptor <regression_test_api.html#reframe.core.pipeline.RegressionTest.job>`__ which represents the scheduler job that will be used to run this test.
@@ -492,7 +492,7 @@ Let's run the test and inspect the generated job script:
492492
The job options specified inside a ReFrame test are always the last to be emitted in the job script preamble and do not affect the options that are passed implicitly through other test attributes or configuration options.
493493

494494
There is a small problem with this test though.
495-
What if we change the job scheduler in that partition or what if we want to port the test to a different system that does not use Slurm and and another option is needed to achieve the same result.
495+
What if we change the job scheduler in that partition or what if we want to port the test to a different system that does not use Slurm and another option is needed to achieve the same result.
496496
The obvious answer is to adapt the test, but is there a more portable way?
497497
The answer is yes and this can be achieved through so-called *extra resources*.
498498
ReFrame gives you the possibility to associate scheduler options to a "resource" managed by the partition scheduler.
@@ -625,7 +625,7 @@ It resembles a scaling test, except that all happens inside a single ReFrame tes
625625
626626
.. literalinclude:: ../tutorials/advanced/multilaunch/multilaunch.py
627627
:lines: 6-
628-
:emphasize-lines: 12-19
628+
:emphasize-lines: 13-19
629629

630630
The additional parallel launch commands are inserted in either the :attr:`prerun_cmds` or :attr:`postrun_cmds` lists.
631631
To retrieve the actual parallel launch command for the current partition that the test is running on, you can use the :func:`~reframe.core.launchers.Launcher.run_command` method of the launcher object.
@@ -680,13 +680,9 @@ The test will verify that all the nodes print the expected host name:
680680
:lines: 6-
681681
:emphasize-lines: 10-
682682

683-
The first thing to notice in this test is that :attr:`~reframe.core.pipeline.RegressionTest.num_tasks` is set to zero.
684-
This is a requirement for flexible tests.
685-
The sanity check of this test simply counts the host names printed and verifies that they are as many as expected.
686-
Notice, however, that the sanity check does not use :attr:`num_tasks` directly, but rather access the attribute through the :func:`~reframe.utility.sanity.getattr` sanity function, which is a replacement for the :func:`getattr` builtin.
687-
The reason for that is that at the time the sanity check expression is created, :attr:`num_tasks` is ``0`` and it will only be set to its actual value during the run phase.
688-
Consequently, we need to defer the attribute retrieval, thus we use the :func:`~reframe.utility.sanity.getattr` sanity function instead of accessing it directly
689-
683+
The first thing to notice in this test is that :attr:`~reframe.core.pipeline.RegressionTest.num_tasks` is set to zero as default, which is a requirement for flexible tests.
684+
However, with flexible tests, this value is updated right after the job completes to the actual number of tasks that were used.
685+
Consequently, this allows the sanity function of the test to assert that the number host names printed matches :attr:`~reframe.core.pipeline.RegressionTest.num_tasks`.
690686

691687
.. |--flex-alloc-nodes| replace:: :attr:`--flex-alloc-nodes`
692688
.. _--flex-alloc-nodes: manpage.html#cmdoption-flex-alloc-nodes
@@ -723,7 +719,7 @@ The following parameterized test, will create two tests, one for each of the sup
723719
724720
.. literalinclude:: ../tutorials/advanced/containers/container_test.py
725721
:lines: 6-
726-
:emphasize-lines: 16-22
722+
:emphasize-lines: 11-19
727723

728724
A container-based test can be written as :class:`~reframe.core.pipeline.RunOnlyRegressionTest` that sets the :attr:`~reframe.core.pipeline.RegressionTest.container_platform` attribute.
729725
This attribute accepts a string that corresponds to the name of the container platform that will be used to run the container for this test.
@@ -780,7 +776,7 @@ and ``/rfm_workdir`` corresponds to the stage directory on the host system.
780776
Therefore, the ``release.txt`` file can now be used in the subsequent sanity checks:
781777

782778
.. literalinclude:: ../tutorials/advanced/containers/container_test.py
783-
:lines: 15-17
779+
:lines: 26-29
784780

785781

786782
For a complete list of the available attributes of a specific container platform, please have a look at the :ref:`container-platforms` section of the :doc:`regression_test_api` guide.
@@ -793,8 +789,8 @@ Writing reusable tests
793789
.. versionadded:: 3.5.0
794790

795791
So far, all the examples shown above were tight to a particular system or configuration, which makes reusing these tests in other systems not straightforward.
796-
However, the introduction of the :py:func:`~reframe.core.pipeline.RegressionTest.parameter` and :py:func:`~reframe.core.pipeline.RegressionTest.variable` ReFrame built-ins solves this problem, eliminating the need to specify any of the test variables in the :func:`__init__` method and simplifying code reuse.
797-
Hence, readers who are not familiar with these built-in functions are encouraged to read their basic use examples (see :py:func:`~reframe.core.pipeline.RegressionTest.parameter` and :py:func:`~reframe.core.pipeline.RegressionTest.variable`) before delving any deeper into this tutorial.
792+
However, the introduction of the :py:func:`~reframe.core.pipeline.RegressionMixin.parameter` and :py:func:`~reframe.core.pipeline.RegressionMixin.variable` ReFrame built-ins solves this problem, eliminating the need to specify any of the test variables in the :func:`__init__` method and simplifying code reuse.
793+
Hence, readers who are not familiar with these built-in functions are encouraged to read their basic use examples (see :py:func:`~reframe.core.pipeline.RegressionMixin.parameter` and :py:func:`~reframe.core.pipeline.RegressionMixin.variable`) before delving any deeper into this tutorial.
798794

799795
In essence, parameters and variables can be treated as simple class attributes, which allows us to leverage Python's class inheritance and write more modular tests.
800796
For simplicity, we illustrate this concept with the above :class:`ContainerTest` example, where the goal here is to re-write this test as a library that users can simply import from and derive their tests without having to rewrite the bulk of the test.
@@ -821,7 +817,7 @@ In fact, writing the test in this way permits having hooks that depend on undefi
821817
This is the case with the :func:`set_container_platform` hook, which depends on the undefined parameter ``platform``.
822818
Hence, the derived test **must** define all the required parameters and variables; otherwise ReFrame will notice that the test is not well defined and will raise an error accordingly.
823819

824-
Before moving onwards to the derived test, note that the :class:`ContainerBase` class takes the additional argument ``pin_prefix=True``, which locks the prefix of all derived tests to this base test.
820+
Before moving ahead with the derived test, note that the :class:`ContainerBase` class takes the additional argument ``pin_prefix=True``, which locks the prefix of all derived tests to this base test.
825821
This will allow the retrieval of the sources located in the library by any derived test, regardless of what their containing directory is.
826822

827823
.. code-block:: console

0 commit comments

Comments
 (0)