Reference Guide¶
This page provides a reference guide of the ReFrame API for writing regression tests covering all the relevant details. Internal data structures and APIs are covered only to the extent that might be helpful to the final user of the framework.
Regression test classes and related utilities¶
-
reframe.core.decorators.
parameterized_test
(*inst)[source]¶ Class decorator for registering multiple instantiations of a test class.
The decorated class must derive from
reframe.core.pipeline.RegressionTest
. This decorator is also available directly under thereframe
module.Parameters: inst – The different instantiations of the test. Each instantiation argument may be either a sequence or a mapping. New in version 2.13.
Note
This decorator does not instantiate any test. It only registers them. The actual instantiation happens during the loading phase of the test.
-
reframe.core.decorators.
simple_test
(cls)[source]¶ Class decorator for registering parameterless tests with ReFrame.
The decorated class must derive from
reframe.core.pipeline.RegressionTest
. This decorator is also available directly under thereframe
module.New in version 2.13.
-
reframe.core.decorators.
required_version
(*versions)[source]¶ Class decorator for specifying the required ReFrame versions for the following test.
If the test is not compatible with the current ReFrame version it will be skipped.
Parameters: versions – A list of ReFrame version specifications that this test is allowed to run. A version specification string can have one of the following formats:
VERSION
: Specifies a single version.
2.
{OP}VERSION
, where{OP}
can be any of>
,>=
,<
,<=
,==
and!=
. For example, the version specification string'>=2.15'
will only allow the following test to be loaded only by ReFrame 2.15 and higher. The==VERSION
specification is the equivalent ofVERSION
.V1..V2
: Specifies a range of versions.
You can specify multiple versions with this decorator, such as
@required_version('2.13', '>=2.16')
, in which case the test will be selected if any of the versions is satisfied, even if the versions specifications are conflicting.New in version 2.13.
-
reframe.core.decorators.
require_deps
(func)[source]¶ Denote that the decorated test method will use the test dependencies.
The arguments of the decorated function must be named after the dependencies that the function intends to use. The decorator will bind the arguments to a partial realization of the
reframe.core.pipeline.RegressionTest.getdep()
function, such that conceptually the new function arguments will be the following:new_arg = functools.partial(getdep, orig_arg_name)
The converted arguments are essentially functions accepting a single argument, which is the target test’s programming environment.
This decorator is also directly available under the
reframe
module.New in version 2.21.
-
reframe.core.decorators.
run_before
(stage)[source]¶ Run the decorated function before the specified pipeline stage.
The decorated function must be a method of a regression test.
New in version 2.20.
-
reframe.core.decorators.
run_after
(stage)[source]¶ Run the decorated function after the specified pipeline stage.
The decorated function must be a method of a regression test.
New in version 2.20.
-
class
reframe.core.pipeline.
RegressionTest
[source]¶ Bases:
object
Base class for regression tests.
All regression tests must eventually inherit from this class. This class provides the implementation of the pipeline phases that the regression test goes through during its lifetime.
Parameters: - name – The name of the test.
If
None
, the framework will try to assign a unique and human-readable name to the test. - prefix – The directory prefix of the test.
If
None
, the framework will set it to the directory containing the test file.
Note
The
name
andprefix
arguments are just maintained for backward compatibility to the old (prior to 2.13) syntax of regression tests. Users are advised to use the new simplified syntax for writing regression tests. Refer to the ReFrame Tutorial for more information.This class is also directly available under the top-level
reframe
module.Changed in version 2.13.
-
build_system
¶ The build system to be used for this test. If not specified, the framework will try to figure it out automatically based on the value of
sourcepath
.This field may be set using either a string referring to a concrete build system class name (see build systems) or an instance of
reframe.core.buildsystems.BuildSystem
. The former is the recommended way.Type: str
orreframe.core.buildsystems.BuildSystem
.Default: None
.New in version 2.14.
-
check_performance
()[source]¶ The performance checking phase of the regression test pipeline.
Raises: reframe.core.exceptions.SanityError – If the performance check fails.
-
check_sanity
()[source]¶ The sanity checking phase of the regression test pipeline.
Raises: reframe.core.exceptions.SanityError – If the sanity check fails.
-
cleanup
(remove_files=False)[source]¶ The cleanup phase of the regression test pipeline.
Parameters: remove_files – If True
, the stage directory associated with this test will be removed.
-
compile
()[source]¶ The compilation phase of the regression test pipeline.
Raises: reframe.core.exceptions.ReframeError – In case of errors.
-
container_platform
¶ The container platform to be used for launching this test.
If this field is set, the test will run inside a container using the specified container runtime. Container-specific options must be defined additionally after this field is set:
self.container_platform = 'Singularity' self.container_platform.image = 'docker://ubuntu:18.04' self.container_platform.commands = ['cat /etc/os-release']
If this field is set,
executable
andexecutable_opts
attributes are ignored. The container platform’scommands
will be used instead. For more information on the container platform support, see the tutorial and the reference guide.Type: str
orreframe.core.containers.ContainerPlatform
.Default: None
.New in version 2.20.
-
current_environ
¶ The programming environment that the regression test is currently executing with.
This is set by the framework during the
setup()
phase.Type: reframe.core.environments.Environment
.
-
current_partition
¶ The system partition the regression test is currently executing on.
This is set by the framework during the
setup()
phase.Type: reframe.core.systems.SystemPartition
.
-
current_system
¶ The system the regression test is currently executing on.
This is set by the framework during the initialization phase.
Type: reframe.core.runtime.HostSystem
.
-
depends_on
(target, how=2, subdeps=None)[source]¶ Add a dependency to
target
in this test.Parameters: - target – The name of the target test.
- how – How the dependency should be mapped in the test cases space.
This argument can accept any of the three constants
DEPEND_EXACT
,DEPEND_BY_ENV
(default),DEPEND_FULLY
. - subdeps –
An adjacency list representation of how this test’s test cases depend on those of the target test. This is only relevant if
how == DEPEND_EXACT
. The value of this argument is a dictionary having as keys the names of this test’s supported programming environments. The values are lists of the programming environments names of the target test that this test’s test cases will depend on. In the following example, this test’sE0
programming environment case will depend on bothE0
andE1
test cases of the target testT0
, but itsE1
case will depend only on theE1
test case ofT0
:self.depends_on(‘T0’, how=rfm.DEPEND_EXACT, subdeps={‘E0’: [‘E0’, ‘E1’], ‘E1’: [‘E1’]})
For more details on how test dependencies work in ReFrame, please refer to How Test Dependencies Work In ReFrame.
New in version 2.21.
-
exclusive_access
¶ Specify whether this test needs exclusive access to nodes.
Type: boolean Default: False
-
executable
¶ The name of the executable to be launched during the run phase.
Type: str
Default: os.path.join('.', self.name)
-
executable_opts
¶ List of options to be passed to the
executable
.Type: List[str]
Default: []
-
extra_resources
¶ Extra resources for this test.
This field is for specifying custom resources needed by this test. These resources are defined in the configuration of a system partition. For example, assume that two additional resources, named
gpu
anddatawarp
, are defined in the configuration file as follows:'resources': { 'gpu': [ '--gres=gpu:{num_gpus_per_node}' ], 'datawarp': [ '#DW jobdw capacity={capacity}', '#DW stage_in source={stagein_src}' ] }
A regression test then may instantiate the above resources by setting the
extra_resources
attribute as follows:self.extra_resources = { 'gpu': {'num_gpus_per_node': 2} 'datawarp': { 'capacity': '100GB', 'stagein_src': '/foo' } }
The generated batch script (for Slurm) will then contain the following lines:
#SBATCH --gres=gpu:2 #DW jobdw capacity=100GB #DW stage_in source=/foo
Notice that if the resource specified in the configuration uses an alternative directive prefix (in this case
#DW
), this will replace the standard prefix of the backend scheduler (in this case#SBATCH
)If the resource name specified in this variable does not match a resource name in the partition configuration, it will be simply ignored. The
num_gpus_per_node
attribute translates internally to the_rfm_gpu
resource, so that settingself.num_gpus_per_node = 2
is equivalent to the following:self.extra_resources = {'_rfm_gpu': {'num_gpus_per_node': 2}}
Type: Dict[str, Dict[str, object]]
Default: {}
Note
New in version 2.8.
Changed in version 2.9.
A new more powerful syntax was introduced that allows also custom job script directive prefixes.
-
getdep
(target, environ=None)[source]¶ Retrieve the test case of a target dependency.
This is a low-level method. The
@require_deps
decorators should be preferred.Parameters: - target – The name of the target dependency to be retrieved.
- environ – The name of the programming environment that will be
used to retrieve the test case of the target test. If
None
,RegressionTest.current_environ
will be used.
New in version 2.21.
-
info
()[source]¶ Provide live information of a running test.
This method is used by the front-end to print the status message during the test’s execution. This function is also called to provide the message for the
check_info
logging attribute. By default, it returns a message reporting the test name, the current partition and the current programming environment that the test is currently executing on.Returns: a string with an informational message about this test Note
When overriding this method, you should pay extra attention on how you use the
RegressionTest
’s attributes, because this method may be called at any point of the test’s lifetime.New in version 2.10.
-
is_local
()[source]¶ Check if the test will execute locally.
A test executes locally if the
local
attribute is set or if the current partition’s scheduler does not support job submission.
-
job
¶ The job descriptor associated with this test.
This is set by the framework during the
setup()
phase.Type: reframe.core.schedulers.Job
.
-
keep_files
¶ List of files to be kept after the test finishes.
By default, the framework saves the standard output, the standard error and the generated shell script that was used to run this test.
These files will be copied over to the framework’s output directory during the
cleanup()
phase.Directories are also accepted in this field.
Relative path names are resolved against the stage directory.
Type: List[str]
Default: []
-
local
¶ Always execute this test locally.
Type: boolean Default: False
-
logger
¶ A logger associated with this test.
You can use this logger to log information for your test.
-
maintainers
¶ List of people responsible for this test.
When the test fails, this contact list will be printed out.
Type: List[str]
Default: []
-
modules
¶ List of modules to be loaded before running this test.
These modules will be loaded during the
setup()
phase.Type: List[str]
Default: []
-
name
¶ The name of the test.
Type: string that can contain any character except /
-
num_cpus_per_task
¶ Number of CPUs per task required by this test.
Ignored if
None
.Type: integral or None
Default: None
-
num_gpus_per_node
¶ Number of GPUs per node required by this test.
Type: integral Default: 0
-
num_tasks
¶ Number of tasks required by this test.
If the number of tasks is set to a number
<=0
, ReFrame will try to flexibly allocate the number of tasks, based on the command line option--flex-alloc-nodes
. A negative number is used to indicate the minimum number of tasks required for the test. In this case the minimum number of tasks is the absolute value of the number, while Settingnum_tasks
to0
is equivalent to setting it to-num_tasks_per_node
.Type: integral Default: 1
Note
Changed in version 2.15: Added support for flexible allocation of the number of tasks according to the
--flex-alloc-tasks
command line option (see Flexible node allocation) if the number of tasks is set to0
.Changed in version 2.16: Negative
num_tasks
is allowed for specifying the minimum number of required tasks by the test.Changed in version 2.21: Flexible node allocation is now controlled by the
--flex-alloc-nodes
command line option (see Flexible node allocation)
-
num_tasks_per_core
¶ Number of tasks per core required by this test.
Ignored if
None
.Type: integral or None
Default: None
-
num_tasks_per_node
¶ Number of tasks per node required by this test.
Ignored if
None
.Type: integral or None
Default: None
-
num_tasks_per_socket
¶ Number of tasks per socket required by this test.
Ignored if
None
.Type: integral or None
Default: None
-
outputdir
¶ The output directory of the test.
This is set during the
setup()
phase.New in version 2.13.
Type: str
.
-
perf_patterns
¶ Patterns for verifying the performance of this test.
Refer to the ReFrame Tutorial for concrete usage examples.
If set to
None
, no performance checking will be performed.Type: A dictionary with keys of type str
and deferrable expressions (i.e., the result of a sanity function) as values.None
is also allowed.Default: None
-
poll
()[source]¶ Poll the test’s state.
Returns: True
if the associated job has finished,False
otherwise.If no job descriptor is yet associated with this test,
True
is returned.Raises: reframe.core.exceptions.ReframeError – In case of errors.
-
post_run
¶ List of shell commands to execute after launching this job.
See
pre_run
for a more detailed description of the semantics.Type: List[str]
Default: []
Note
New in version 2.10.
-
postbuild_cmd
¶ List of shell commands to be executed after a successful compilation.
These commands are executed during the compilation phase and from inside the stage directory. Each entry in the list spawns a new shell.
Type: List[str]
Default: []
-
pre_run
¶ List of shell commands to execute before launching this job.
These commands do not execute in the context of ReFrame. Instead, they are emitted in the generated job script just before the actual job launch command.
Type: List[str]
Default: []
Note
New in version 2.10.
-
prebuild_cmd
¶ List of shell commands to be executed before compiling.
These commands are executed during the compilation phase and from inside the stage directory. Each entry in the list spawns a new shell.
Type: List[str]
Default: []
-
readonly_files
¶ List of files or directories (relative to the
sourcesdir
) that will be symlinked in the stage directory and not copied.You can use this variable to avoid copying very large files to the stage directory.
Type: List[str]
Default: []
-
reference
¶ The set of reference values for this test.
The reference values are specified as a scoped dictionary keyed on the performance variables defined in
perf_patterns
and scoped under the system/partition combinations. The reference itself is a three- or four-tuple that contains the reference value, the lower and upper thresholds and, optionally, the measurement unit. An example follows:self.reference = { 'sys0:part0': { 'perfvar0': (50, -0.1, 0.1, 'Gflop/s'), 'perfvar1': (20, -0.1, 0.1, 'GB/s') }, 'sys0:part1': { 'perfvar0': (100, -0.1, 0.1, 'Gflop/s'), 'perfvar1': (40, -0.1, 0.1, 'GB/s') } }
Type: A scoped dictionary with system names as scopes or None
Default: {}
-
run
()[source]¶ The run phase of the regression test pipeline.
This call is non-blocking. It simply submits the job associated with this test and returns.
-
sanity_patterns
¶ Refer to the ReFrame Tutorial for concrete usage examples.
If set to
None
, a sanity error will be raised during sanity checking.Type: A deferrable expression (i.e., the result of a sanity function) or None
Default: None
Note
Changed in version 2.9: The default behaviour has changed and it is now considered a sanity failure if this attribute is set to
None
.If a test doesn’t care about its output, this must be stated explicitly as follows:
self.sanity_patterns = sn.assert_found(r'.*', self.stdout)
-
setup
(partition, environ, **job_opts)[source]¶ The setup phase of the regression test pipeline.
Parameters: - partition – The system partition to set up this test for.
- environ – The environment to set up this test for.
- job_opts – Options to be passed through to the backend scheduler.
When overriding this method users should always pass through
job_opts
to the base class method.
Raises: reframe.core.exceptions.ReframeError – In case of errors.
-
sourcepath
¶ The path to the source file or source directory of the test.
It must be a path relative to the
sourcesdir
, pointing to a subfolder or a file contained insourcesdir
. This applies also in the case wheresourcesdir
is a Git repository.If it refers to a regular file, this file will be compiled using the
SingleSource
build system. If it refers to a directory, ReFrame will try to infer the build system to use for the project and will fall back in using theMake
build system, if it cannot find a more specific one.Type: str
Default: ''
-
sourcesdir
¶ The directory containing the test’s resources.
This directory may be specified with an absolute path or with a path relative to the location of the test. Its contents will always be copied to the stage directory of the test.
This attribute may also accept a URL, in which case ReFrame will treat it as a Git repository and will try to clone its contents in the stage directory of the test.
If set to
None
, the test has no resources an no action is taken.Type: str
orNone
Default: 'src'
Note
Changed in version 2.9: Allow
None
values to be set also in regression tests with a compilation phaseChanged in version 2.10: Support for Git repositories was added.
-
stderr
¶ The name of the file containing the standard error of the test.
This is set during the
setup()
phase.This attribute is evaluated lazily, so it can by used inside sanity expressions.
Type: str
.
-
stdout
¶ The name of the file containing the standard output of the test.
This is set during the
setup()
phase.This attribute is evaluated lazily, so it can by used inside sanity expressions.
Type: str
.
-
strict_check
¶ Mark this test as a strict performance test.
If a test is marked as non-strict, the performance checking phase will always succeed, unless the
--strict
command-line option is passed when invoking ReFrame.Type: boolean Default: True
Set of tags associated with this test.
This test can be selected from the frontend using any of these tags.
Type: Set[str]
Default: an empty set
-
time_limit
¶ Time limit for this test.
Time limit is specified as a three-tuple in the form
(hh, mm, ss)
, withhh >= 0
,0 <= mm <= 59
and0 <= ss <= 59
. If set toNone
, no time limit will be set. The default time limit of the system partition’s scheduler will be used.Type: tuple[int]
Default: (0, 10, 0)
Note
Changed in version 2.15.
This attribute may be set to
None
.
-
use_multithreading
¶ Specify whether this tests needs simultaneous multithreading enabled.
Ignored if
None
.Type: boolean or None
Default: None
-
valid_prog_environs
¶ List of programming environments supported by this test.
If
*
is in the list then all programming environments are supported by this test.Type: List[str]
Default: []
Note
Changed in version 2.12: Programming environments can now be specified using wildcards.
Changed in version 2.17: Support for wildcards is dropped.
-
valid_systems
¶ List of systems supported by this test. The general syntax for systems is
<sysname>[:<partname]
.Type: List[str]
Default: []
- name – The name of the test.
If
-
class
reframe.core.pipeline.
RunOnlyRegressionTest
[source]¶ Bases:
reframe.core.pipeline.RegressionTest
Base class for run-only regression tests.
This class is also directly available under the top-level
reframe
module.-
compile
()[source]¶ The compilation phase of the regression test pipeline.
This is a no-op for this type of test.
-
compile_wait
()[source]¶ Wait for compilation phase to finish.
This is a no-op for this type of test.
-
run
()[source]¶ The run phase of the regression test pipeline.
The resources of the test are copied to the stage directory and the rest of execution is delegated to the
RegressionTest.run()
.
-
-
class
reframe.core.pipeline.
CompileOnlyRegressionTest
[source]¶ Bases:
reframe.core.pipeline.RegressionTest
Base class for compile-only regression tests.
These tests are by default local and will skip the run phase of the regression test pipeline.
The standard output and standard error of the test will be set to those of the compilation stage.
This class is also directly available under the top-level
reframe
module.-
setup
(partition, environ, **job_opts)[source]¶ The setup stage of the regression test pipeline.
Similar to the
RegressionTest.setup()
, except that no job descriptor is set up for this test.
-
stderr
¶ The name of the file containing the standard error of the test.
This is set during the
setup()
phase.This attribute is evaluated lazily, so it can by used inside sanity expressions.
Type: str
.
-
-
reframe.core.pipeline.
DEPEND_EXACT
= 1¶ Constant to be passed as the
how
argument of theRegressionTest.depends_on()
method. It denotes that test case dependencies will be explicitly specified by the user.This constant is directly available under thereframe
module.
-
reframe.core.pipeline.
DEPEND_BY_ENV
= 2¶ Constant to be passed as the
how
argument of theRegressionTest.depends_on()
method. It denotes that the test cases of the current test will depend only on the corresponding test cases of the target test that use the same programming environment.This constant is directly available under thereframe
module.
-
reframe.core.pipeline.
DEPEND_FULLY
= 3¶ Constant to be passed as the
how
argument of theRegressionTest.depends_on()
method. It denotes that each test case of this test depends on all the test cases of the target test.This constant is directly available under thereframe
module.
Environments and Systems¶
-
class
reframe.core.environments.
Environment
(name, modules=[], variables=[])[source]¶ Bases:
object
This class abstracts away an environment to run regression tests.
It is simply a collection of modules to be loaded and environment variables to be set when this environment is loaded by the framework.
-
is_loaded
¶ True
if this environment is loaded,False
otherwise.
-
-
class
reframe.core.environments.
ProgEnvironment
(name, modules=[], variables={}, cc='cc', cxx='CC', ftn='ftn', nvcc='nvcc', cppflags=None, cflags=None, cxxflags=None, fflags=None, ldflags=None, **kwargs)[source]¶ Bases:
reframe.core.environments.Environment
A class representing a programming environment.
This type of environment adds also attributes for setting the compiler and compilation flags.
If compilation flags are set to
None
(the default, if not set otherwise in ReFrame’s configuration), they are not passed to themake
invocation.If you want to disable completely the propagation of the compilation flags to the
make
invocation, even if they are set, you should set thepropagate
attribute toFalse
.
-
reframe.core.environments.
load
(*environs)[source]¶ Load environments in the current Python context.
Returns a tuple containing a snapshot of the environment at entry to this function and a list of shell commands required to load
environs
.
-
class
reframe.core.environments.
temp_environment
(modules=[], variables=[])[source]¶ Bases:
object
Context manager to temporarily change the environment.
-
class
reframe.core.systems.
System
(name, descr=None, hostnames=[], partitions=[], preload_env=None, prefix='.', stagedir=None, outputdir=None, perflogdir=None, resourcesdir='.', modules_system=None)[source]¶ Bases:
object
A representation of a system inside ReFrame.
-
descr
¶ The description of this system.
-
hostnames
¶ The hostname patterns associated with this system.
-
modules_system
¶ The modules system name associated with this system.
-
name
¶ The name of this system.
-
outputdir
¶ The ReFrame output directory prefix associated with this system.
-
partitions
¶ All the system partitions associated with this system.
-
perflogdir
¶ The ReFrame log directory prefix associated with this system.
-
prefix
¶ The ReFrame prefix associated with this system.
-
preload_environ
¶ The environment to load whenever ReFrame runs on this system.
Note
New in version 2.19.
-
resourcesdir
¶ Global resources directory for this system.
You may use this directory for storing large resource files of your regression tests. See here on how to configure this.
Type: str
-
stagedir
¶ The ReFrame stage directory prefix associated with this system.
-
-
class
reframe.core.systems.
SystemPartition
(name, descr=None, scheduler=None, launcher=None, access=[], environs=[], resources={}, local_env=None, max_jobs=1)[source]¶ Bases:
object
A representation of a system partition inside ReFrame.
This class is immutable.
-
descr
¶ A detailed description of this partition.
-
fullname
¶ Return the fully-qualified name of this partition.
The fully-qualified name is of the form
<parent-system-name>:<partition-name>
.Type: str
-
launcher
¶ The type of the backend launcher of this partition.
Returns: a subclass of reframe.core.launchers.JobLauncher
.Note
New in version 2.8.
-
name
¶ The name of this partition.
Type: str
-
scheduler
¶ The type of the backend scheduler of this partition.
Returns: a subclass of reframe.core.schedulers.Job
.Note
Changed in version 2.8.
Prior versions returned a string representing the scheduler and job launcher combination.
-
Job schedulers and parallel launchers¶
-
class
reframe.core.schedulers.
Job
(name, workdir='.', script_filename=None, stdout=None, stderr=None, sched_flex_alloc_nodes=None, sched_access=[], sched_account=None, sched_partition=None, sched_reservation=None, sched_nodelist=None, sched_exclude_nodelist=None, sched_exclusive_access=None, sched_options=None)[source]¶ Bases:
object
A job descriptor.
A job descriptor is created by the framework after the “setup” phase and is associated with the test. It can be retrieved through the
reframe.core.pipeline.RegressionTest.job
attribute and stores information about the job submitted during the “run” phase.Note
Users cannot create a job descriptor directly and associate it with a test.
-
exitcode
¶ The exit code of the job.
This may or may not be set depending on the scheduler backend.
Type: int
orNone
.New in version 2.21.
-
launcher
¶ The (parallel) program launcher that will be used to launch the (parallel) executable of this job.
Users are allowed to explicitly set the current job launcher, but this is only relevant in rare situations, such as when you want to wrap the current launcher command. For this specific scenario, you may have a look at the
reframe.core.launchers.LauncherWrapper
class.The following example shows how you can replace the current partition’s launcher for this test with the “local” launcher:
from reframe.core.launchers.registry import getlauncher @rfm.run_after('setup') def set_launcher(self): self.job.launcher = getlauncher('local')()
Type: reframe.core.launchers.JobLauncher
-
nodelist
¶ The list of node names assigned to this job.
This attribute is
None
if no nodes are assigned to the job yet. This attribute is set reliably only for theslurm
backend, i.e., Slurm with accounting enabled. Thesqueue
scheduler backend, i.e., Slurm without accounting, might not set this attribute for jobs that finish very quickly. For thelocal
scheduler backend, this returns an one-element list containing the hostname of the current host.This attribute might be useful in a flexible regression test for determining the actual nodes that were assigned to the test. For more information on flexible node allocation, please refer to the corresponding section of the tutorial.
This attribute is not supported by the
pbs
scheduler backend.New in version 2.17.
-
options
¶ Options to be passed to the backend job scheduler.
Type: List[str]
Default: []
-
-
class
reframe.core.launchers.
JobLauncher
[source]¶ Bases:
abc.ABC
A job launcher.
A job launcher is the executable that actually launches a distributed program to multiple nodes, e.g.,
mpirun
,srun
etc.Note
Users cannot create job launchers directly. You may retrieve a registered launcher backend through the
reframe.core.launchers.registry.getlauncher()
function.Note
Changed in version 2.8: Job launchers do not get a reference to a job during their initialization.
-
class
reframe.core.launchers.
LauncherWrapper
(target_launcher, wrapper_command, wrapper_options=[])[source]¶ Bases:
reframe.core.launchers.JobLauncher
Wrap a launcher object so as to modify its invocation.
This is useful for parallel debuggers. For example, to launch a regression test using the ARM DDT debugger, you can do the following:
@rfm.run_after('setup') def set_launcher(self): self.job.launcher = LauncherWrapper(self.job.launcher, 'ddt', ['--offline'])
If the current system partition uses native Slurm for job submission, this setup will generate the following command in the submission script:
ddt --offline srun <test_executable>
If the current partition uses
mpirun
instead, it will generateddt --offline mpirun -np <num_tasks> ... <test_executable>
Parameters: - target_launcher – The launcher to wrap.
- wrapper_command – The wrapper command.
- wrapper_options – List of options to pass to the wrapper command.
-
reframe.core.launchers.registry.
getlauncher
(name)[source]¶ Get launcher by its registered name.
The available names are those specified in the configuration file.
This method may become handy in very special situations, e.g., testing an application that needs to replace the system partition launcher or if a different launcher must be used for a different programming environment.
For example, if you want to replace the current partition’s launcher with the local one, here is how you can achieve it:
def setup(self, partition, environ, **job_opts): super().setup(partition, environ, **job_opts) self.job.launcher = getlauncher('local')()
Note that this method returns a launcher class type and not an instance of that class. You have to instantiate it explicitly before assigning it to the
launcher
attribute of the job.Note
New in version 2.8.
Parameters: name – The name of the launcher to retrieve. Returns: The class of the launcher requested, which is a subclass of reframe.core.launchers.JobLauncher
.Raises: reframe.core.exceptions.ConfigError – if no launcher is registered with that name.
-
reframe.core.launchers.registry.
register_launcher
(name, local=False)[source]¶ Class decorator for registering new job launchers.
Caution
This decorator is only relevant to developers of new job launchers.
Note
New in version 2.8.
Parameters: - name – The registration name of this launcher
- local –
True
if launcher may only submit local jobs,False
otherwise.
Raises: ValueError – if a job launcher is already registered with the same name.
Runtime services¶
-
class
reframe.core.runtime.
HostResources
(prefix=None, stagedir=None, outputdir=None, perflogdir=None, timefmt=None)[source]¶ Bases:
object
Resources associated with ReFrame execution on the current host.
Note
New in version 2.13.
-
output_prefix
¶ The output prefix directory of ReFrame.
-
prefix
¶ The prefix directory of ReFrame execution. This is always an absolute path.
Type: str
Caution
Users may not set this field.
-
stage_prefix
¶ The stage prefix directory of ReFrame.
-
-
class
reframe.core.runtime.
HostSystem
(system, partname=None)[source]¶ Bases:
object
The host system of the framework.
The host system is a representation of the system that the framework currently runs on.If the framework is properly configured, the host system is automatically detected. If not, it may be explicitly set by the user.
This class is mainly a proxy of
reframe.core.systems.System
that stores optionally a partition name and provides some additional functionality for manipulating system partitions.All attributes of the
reframe.core.systems.System
may be accessed directly from this proxy.Note
New in version 2.13.
-
partition
(name)[source]¶ Return the system partition
name
.Type: reframe.core.systems.SystemPartition
.
-
partitions
¶ The partitions of this system.
Type: list[reframe.core.systems.SystemPartition]
.
-
-
class
reframe.core.runtime.
RuntimeContext
(dict_config, sysdescr=None, **options)[source]¶ Bases:
object
The runtime context of the framework.
This class essentially groups the current host system and the associated resources of the framework on the current system. It also encapsulates other runtime parameters that are relevant to the framework’s execution.
There is a single instance of this class globally in the framework.
Note
New in version 2.13.
-
modules_system
¶ The modules system used by the current host system.
Type: reframe.core.modules.ModulesSystem
.
-
non_default_craype
¶ True if a non-default Cray PE is tested.
This will cause ReFrame to set the
LD_LIBRARY_PATH
as follows after all modules have been loaded:export LD_LIBRARY_PATH=$CRAY_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
This property is set through the
--non-default-craype
command-line option.Type: bool
(default:False
)
-
resources
¶ The framework resources.
Type: reframe.core.runtime.HostResources
-
system
¶ The current host system.
Type: reframe.core.runtime.HostSystem
-
-
class
reframe.core.runtime.
module_use
(*paths)[source]¶ Bases:
object
Context manager for temporarily modifying the module path
-
reframe.core.runtime.
runtime
()[source]¶ Retrieve the framework’s runtime context.
Type: reframe.core.runtime.RuntimeContext
Note
New in version 2.13.
Modules System API¶
-
class
reframe.core.modules.
ModulesSystem
(backend)[source]¶ A modules system abstraction inside ReFrame.
This class interfaces between the framework internals and the actual modules systems implementation.
-
conflicted_modules
(name)[source]¶ Return the list of the modules conflicting with module
name
.If module
name
resolves to multiple real modules, then the returned list will be the concatenation of the conflict lists of all the real modules.This method returns a list of strings.
-
is_module_loaded
(name)[source]¶ Check if module
name
is loaded.If module
name
refers to multiple real modules, this method will returnTrue
only if all the referees are loaded.
-
load_mapping
(mapping)[source]¶ Update the internal module mappings using a single mapping.
Parameters: mapping – a string specifying the module mapping. Example syntax: 'm0: m1 m2'
.
-
load_mapping_from_file
(filename)[source]¶ Update the internal module mappings from mappings read from file.
-
load_module
(name, force=False)[source]¶ Load the module
name
.If
force
is set, forces the loading, unloading first any conflicting modules currently loaded. If modulename
refers to multiple real modules, all of the target modules will be loaded.Returns the list of unloaded modules as strings.
-
name
¶ Return the name of this module system.
-
resolve_module
(name)[source]¶ Resolve module
name
in the registered module map.Returns: the list of real modules names pointed to by name
.Raises: reframe.core.exceptions.ConfigError
if the mapping contains a cycle.
-
searchpath
¶ The module system search path as a list of directories.
-
unload_module
(name)[source]¶ Unload module
name
.If module
name
refers to multiple real modules, all the referred to modules will be unloaded in reverse order.
-
version
¶ Return the version of this module system.
-
Build systems¶
New in version 2.14.
ReFrame delegates the compilation of the regression test to a build system. Build systems in ReFrame are entities that are responsible for generating the necessary shell commands for compiling a code. Each build system defines a set of attributes that users may set in order to customize their compilation. An example usage is the following:
self.build_system = 'SingleSource'
self.build_system.cflags = ['-fopenmp']
Users simply set the build system to use in their regression tests and then they configure it. If no special configuration is needed for the compilation, users may completely ignore the build systems. ReFrame will automatically pick one based on the regression test attributes and will try to compile the code.
All build systems in ReFrame derive from the abstract base class reframe.core.buildsystems.BuildSystem
.
This class defines a set of common attributes, such us compilers, compilation flags etc. that all subclasses inherit.
It is up to the concrete build system implementations on how to use or not these attributes.
-
class
reframe.core.buildsystems.
Autotools
[source]¶ Bases:
reframe.core.buildsystems.ConfigureBasedBuildSystem
A build system for compiling Autotools-based projects.
This build system will emit the following commands:
- Create a build directory if
builddir
is notNone
and change to it. - Invoke
configure
to configure the project by setting the corresponding flags for compilers and compiler flags. - Issue
make
to compile the code.
-
emit_build_commands
(environ)[source]¶ Return the list of commands for building using this build system.
The build commands may always assume to be issued from the top-level directory of the code that is to be built.
Parameters: environ ( reframe.core.environments.ProgEnvironment
) – The programming environment for which to emit the build instructions. The framework passes here the current programming environment.Raises: BuildSystemError
in case of errors when generating the build instructions.Note
This method is relevant only to developers of new build systems.
- Create a build directory if
-
class
reframe.core.buildsystems.
BuildSystem
[source]¶ Bases:
abc.ABC
The abstract base class of any build system.
Concrete build systems inherit from this class and must override the
emit_build_commands()
abstract function.-
cc
¶ The C compiler to be used. If set to
None
andflags_from_environ
isTrue
, the compiler defined in the current programming environment will be used.Type: str
Default: None
-
cflags
¶ The C compiler flags to be used. If set to
None
andflags_from_environ
isTrue
, the corresponding flags defined in the current programming environment will be used.Type: List[str]
Default: None
-
cppflags
¶ The preprocessor flags to be used. If set to
None
andflags_from_environ
isTrue
, the corresponding flags defined in the current programming environment will be used.Type: List[str]
Default: None
-
cxx
¶ The C++ compiler to be used. If set to
None
andflags_from_environ
isTrue
, the compiler defined in the current programming environment will be used.Type: str
Default: None
-
cxxflags
¶ The C++ compiler flags to be used. If set to
None
andflags_from_environ
isTrue
, the corresponding flags defined in the current programming environment will be used.Type: List[str]
Default: None
-
emit_build_commands
(environ)[source]¶ Return the list of commands for building using this build system.
The build commands may always assume to be issued from the top-level directory of the code that is to be built.
Parameters: environ ( reframe.core.environments.ProgEnvironment
) – The programming environment for which to emit the build instructions. The framework passes here the current programming environment.Raises: BuildSystemError
in case of errors when generating the build instructions.Note
This method is relevant only to developers of new build systems.
-
fflags
¶ The Fortran compiler flags to be used. If set to
None
andflags_from_environ
isTrue
, the corresponding flags defined in the current programming environment will be used.Type: List[str]
Default: None
-
flags_from_environ
¶ Set compiler and compiler flags from the current programming environment if not specified otherwise.
Type: bool
Default: True
-
ftn
¶ The Fortran compiler to be used. If set to
None
andflags_from_environ
isTrue
, the compiler defined in the current programming environment will be used.Type: str
Default: None
-
ldflags
¶ The linker flags to be used. If set to
None
andflags_from_environ
isTrue
, the corresponding flags defined in the current programming environment will be used.Type: List[str]
Default: None
-
nvcc
¶ The CUDA compiler to be used. If set to
None
andflags_from_environ
isTrue
, the compiler defined in the current programming environment will be used.Type: str
Default: None
-
-
class
reframe.core.buildsystems.
CMake
[source]¶ Bases:
reframe.core.buildsystems.ConfigureBasedBuildSystem
A build system for compiling CMake-based projects.
This build system will emit the following commands:
- Create a build directory if
builddir
is notNone
and change to it. - Invoke
cmake
to configure the project by setting the corresponding CMake flags for compilers and compiler flags. - Issue
make
to compile the code.
-
emit_build_commands
(environ)[source]¶ Return the list of commands for building using this build system.
The build commands may always assume to be issued from the top-level directory of the code that is to be built.
Parameters: environ ( reframe.core.environments.ProgEnvironment
) – The programming environment for which to emit the build instructions. The framework passes here the current programming environment.Raises: BuildSystemError
in case of errors when generating the build instructions.Note
This method is relevant only to developers of new build systems.
- Create a build directory if
-
class
reframe.core.buildsystems.
ConfigureBasedBuildSystem
[source]¶ Bases:
reframe.core.buildsystems.BuildSystem
Abstract base class for configured-based build systems.
-
builddir
¶ The CMake build directory, where all the generated files will be placed.
Type: str
Default: None
-
config_opts
¶ Additional configuration options to be passed to the CMake invocation.
Type: List[str]
Default: []
-
make_opts
¶ Options to be passed to the subsequent
make
invocation.Type: List[str]
Default: []
-
srcdir
¶ The top-level directory of the code.
This is set automatically by the framework based on the
reframe.core.pipeline.RegressionTest.sourcepath
attribute.Type: str
Default: None
-
-
class
reframe.core.buildsystems.
Make
[source]¶ Bases:
reframe.core.buildsystems.BuildSystem
A build system for compiling codes using
make
.The generated build command has the following form:
make -j [N] [-f MAKEFILE] [-C SRCDIR] CC="X" CXX="X" FC="X" NVCC="X" CPPFLAGS="X" CFLAGS="X" CXXFLAGS="X" FCFLAGS="X" LDFLAGS="X" OPTIONS
The compiler and compiler flags variables will only be passed if they are not
None
. Their value is determined by the corresponding attributes ofBuildSystem
. If you want to completely disable passing these variables to themake
invocation, you should make sure not to set any of the correspoding attributes and set also theBuildSystem.flags_from_environ
flag toFalse
.-
emit_build_commands
(environ)[source]¶ Return the list of commands for building using this build system.
The build commands may always assume to be issued from the top-level directory of the code that is to be built.
Parameters: environ ( reframe.core.environments.ProgEnvironment
) – The programming environment for which to emit the build instructions. The framework passes here the current programming environment.Raises: BuildSystemError
in case of errors when generating the build instructions.Note
This method is relevant only to developers of new build systems.
-
makefile
¶ Instruct build system to use this Makefile. This option is useful when having non-standard Makefile names.
Type: str
Default: None
-
max_concurrency
¶ Limit concurrency for
make
jobs. This attribute controls the-j
option passed tomake
. If notNone
,make
will be invoked asmake -j max_concurrency
. Otherwise, it will invoked asmake -j
.Type: integer Default: 1
Note
Changed in version 2.19: The default value is now
1
-
options
¶ Append these options to the
make
invocation. This variable is also useful for passing variables or targets tomake
.Type: List[str]
Default: []
-
srcdir
¶ The top-level directory of the code.
This is set automatically by the framework based on the
reframe.core.pipeline.RegressionTest.sourcepath
attribute.Type: str
Default: None
-
-
class
reframe.core.buildsystems.
SingleSource
[source]¶ Bases:
reframe.core.buildsystems.BuildSystem
A build system for compiling a single source file.
The generated build command will have the following form:
COMP CPPFLAGS XFLAGS SRCFILE -o EXEC LDFLAGS
COMP
is the required compiler for compilingSRCFILE
. This build system will automatically detect the programming language of the source file and pick the correct compiler. See also theSingleSource.lang
attribute.CPPFLAGS
are the preprocessor flags and are passed to any compiler.XFLAGS
is any ofCFLAGS
,CXXFLAGS
orFCFLAGS
depending on the programming language of the source file.SRCFILE
is the source file to be compiled. This is set up automatically by the framework. See also theSingleSource.srcfile
attribute.EXEC
is the executable to be generated. This is also set automatically by the framework. See also theSingleSource.executable
attribute.LDFLAGS
are the linker flags.
For CUDA codes, the language assumed is C++ (for the compilation flags) and the compiler used is
BuildSystem.nvcc
.-
emit_build_commands
(environ)[source]¶ Return the list of commands for building using this build system.
The build commands may always assume to be issued from the top-level directory of the code that is to be built.
Parameters: environ ( reframe.core.environments.ProgEnvironment
) – The programming environment for which to emit the build instructions. The framework passes here the current programming environment.Raises: BuildSystemError
in case of errors when generating the build instructions.Note
This method is relevant only to developers of new build systems.
-
executable
¶ The executable file to be generated.
This is set automatically by the framework based on the
reframe.core.pipeline.RegressionTest.executable
attribute.Type: str
orNone
-
include_path
¶ The include path to be used for this compilation.
All the elements of this list will be appended to the
BuildSystem.cppflags
, by prepending to each of them the-I
option.Type: List[str]
Default: []
-
lang
¶ The programming language of the file that needs to be compiled. If not specified, the build system will try to figure it out automatically based on the extension of the source file. The automatically detected extensions are the following:
- C: .c.
- C++: .cc, .cp, .cxx, .cpp, .CPP, .c++ and .C.
- Fortran: .f, .for, .ftn, .F, .FOR, .fpp, .FPP, .FTN, .f90, .f95, .f03, .f08, .F90, .F95, .F03 and .F08.
- CUDA: .cu.
Type: str
orNone
-
srcfile
¶ The source file to compile. This is automatically set by the framework based on the
reframe.core.pipeline.RegressionTest.sourcepath
attribute.Type: str
orNone
Container platforms¶
New in version 2.20.
ReFrame can run a regression test inside a container.
To achieve that you have to set the reframe.core.pipeline.RegressionTest.container_platform
attribute and then set up the container platform (e.g., image to load, commands to execute).
The reframe.core.ContainerPlatform
abstract base class define the basic interface and a minimal set of attributes that all concrete container platforms must implement.
Concrete container platforms may also define additional fields that are specific to them.
-
class
reframe.core.containers.
ContainerPlatform
[source]¶ Bases:
abc.ABC
The abstract base class of any container platform.
Concrete container platforms inherit from this class and must override the
emit_prepare_commands()
andlaunch_command()
abstract methods.-
commands
¶ The commands to be executed within the container.
Type: list[str]
Default: []
-
emit_prepare_commands
()[source]¶ Returns commands for preparing this container for running.
Such a command could be for pulling the container image from a repository.
-
mount_points
¶ List of mount point pairs for directories to mount inside the container.
Each mount point is specified as a tuple of
(/path/in/host, /path/in/container)
.Type: list[tuple[str, str]]
Default: []
-
options
¶ Additional options to be passed to the container runtime when executed.
Type: list[str]
Default: []
-
workdir
¶ The working directory of ReFrame inside the container.
This is the directory where the test’s stage directory is mounted inside the container. This directory is always mounted regardless if
mount_points
is set or not.Type: str
Default: /rfm_workdir
-
-
class
reframe.core.containers.
Docker
[source]¶ Bases:
reframe.core.containers.ContainerPlatform
Container platform backend for running containers with Docker.
-
class
reframe.core.containers.
Sarus
[source]¶ Bases:
reframe.core.containers.ContainerPlatform
Container platform backend for running containers with Sarus.
-
emit_prepare_commands
()[source]¶ Returns commands for preparing this container for running.
Such a command could be for pulling the container image from a repository.
-
with_mpi
¶ Enable MPI support when launching the container.
Type: boolean Default: False
-
-
class
reframe.core.containers.
ShifterNG
[source]¶ Bases:
reframe.core.containers.Sarus
Container platform backend for running containers with ShifterNG.
-
class
reframe.core.containers.
Singularity
[source]¶ Bases:
reframe.core.containers.ContainerPlatform
Container platform backend for running containers with Singularity.
-
emit_prepare_commands
()[source]¶ Returns commands for preparing this container for running.
Such a command could be for pulling the container image from a repository.
-
with_cuda
¶ Enable CUDA support when launching the container.
Type: boolean Default: False
-