Skip to content

Commit 9d122a0

Browse files
committed
Merge branch 'develop' into jackm/cpu-vendor
2 parents ec5ead5 + ead9f84 commit 9d122a0

File tree

11 files changed

+76
-11
lines changed

11 files changed

+76
-11
lines changed

docs/config_reference.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ System Partition Configuration
596596
:default: ``[]``
597597

598598
User defined features of the partition.
599+
599600
These are accessible through the :attr:`~reframe.core.systems.SystemPartition.features` attribute of the :attr:`~reframe.core.pipeline.RegressionTest.current_partition` and can also be selected through the extended syntax of :attr:`~reframe.core.pipeline.RegressionTest.valid_systems`.
600601
The values of this list must be alphanumeric strings starting with a non-digit character and may also contain a ``-``.
601602

@@ -608,11 +609,18 @@ System Partition Configuration
608609
:default: ``{}``
609610

610611
User defined attributes of the partition.
612+
611613
These are accessible through the :attr:`~reframe.core.systems.SystemPartition.extras` attribute of the :attr:`~reframe.core.pipeline.RegressionTest.current_partition` and can also be selected through the extended syntax of :attr:`~reframe.core.pipeline.RegressionTest.valid_systems`.
612614
The attributes of this object must be alphanumeric strings starting with a non-digit character and their values can be of any type.
613615

616+
By default, the values of the :attr:`~config.systems.partitions.scheduler` and :attr:`~config.systems.partitions.launcher` of the partition are added to the partition's extras, if not already present.
617+
614618
.. versionadded:: 3.5.0
615619

620+
.. versionchanged:: 4.6.0
621+
622+
The default ``scheduler`` and ``launcher`` extras are added.
623+
616624
.. _container-platform-configuration:
617625

618626

docs/manpage.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Test discovery and test loading
2727
This is the very first phase of the frontend.
2828
ReFrame will search for tests in its *check search path* and will load them.
2929
When ReFrame loads a test, it actually *instantiates* it, meaning that it will call its :func:`__init__` method unconditionally whether this test is meant to run on the selected system or not.
30-
This is something that writers of regression tests should bear in mind.
30+
This is something that test developers should bear in mind.
3131

3232
.. option:: -c, --checkpath=PATH
3333

@@ -45,6 +45,14 @@ This is something that writers of regression tests should bear in mind.
4545

4646
This option can also be set using the :envvar:`RFM_CHECK_SEARCH_RECURSIVE` environment variable or the :attr:`~config.general.check_search_recursive` general configuration parameter.
4747

48+
.. note::
49+
ReFrame will fail to load a test with a relative import unless *any* of the following holds true:
50+
51+
1. The test is located under ReFrame's installation prefix.
52+
2. The parent directory of the test contains an ``__init__.py`` file.
53+
54+
For versions prior to 4.6, relative imports are supported only for case (1).
55+
4856

4957
.. _test-filtering:
5058

reframe/core/systems.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ def __init__(self, *, parent, name, sched_type, launcher_type,
189189
self._features = features
190190
self._time_limit = time_limit
191191

192+
# Add implicit extras from scheduler and launcher
193+
sched_name = self._sched_type.registered_name
194+
launcher_name = self._launcher_type.registered_name
195+
self._extras.setdefault('scheduler', sched_name)
196+
self._extras.setdefault('launcher', launcher_name)
197+
192198
@property
193199
def access(self):
194200
'''The scheduler options for accessing this system partition.

reframe/frontend/loader.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,15 @@ def load_from_file(self, filename, force=False):
195195
dirname = os.path.dirname(filename)
196196
with osext.change_dir(dirname):
197197
with util.temp_sys_path(dirname):
198+
if os.path.exists(os.path.join(dirname, '__init__.py')):
199+
# If the containing directory is a package,
200+
# import it, too.
201+
parent = util.import_module_from_file(dirname).__name__
202+
else:
203+
parent = None
204+
198205
return self.load_from_module(
199-
util.import_module_from_file(filename, force)
206+
util.import_module_from_file(filename, force, parent)
200207
)
201208
except Exception:
202209
exc_info = sys.exc_info()

reframe/utility/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _do_import_module_from_file(filename, module_name=None):
7070
return module
7171

7272

73-
def import_module_from_file(filename, force=False):
73+
def import_module_from_file(filename, force=False, parent=None):
7474
'''Import module from file.
7575
7676
If the file location refers to a directory, the contained ``__init__.py``
@@ -85,7 +85,14 @@ def import_module_from_file(filename, force=False):
8585
8686
:arg filename: The path to the filename of a Python module.
8787
:arg force: Force reload of module in case it is already loaded.
88+
:arg parent: The name of the parent module of the one that will be loaded.
89+
This will essentially prefix the module of the newly loaded module with
90+
``parent`` so that Python would be able to resolve relative imports in
91+
the module file.
8892
:returns: The loaded Python module.
93+
94+
.. versionchanged:: 4.6
95+
The ``parent`` argument is added.
8996
'''
9097

9198
# Expand and sanitize filename
@@ -103,6 +110,9 @@ def import_module_from_file(filename, force=False):
103110
# with other modules loaded with a standard `import` or with multiple
104111
# test files with the same name that reside in different directories.
105112
module_hash = sha256(filename.encode('utf-8')).hexdigest()[:8]
113+
if parent:
114+
module_name = f'{parent}.{module_name}'
115+
106116
module_name = f'{module_name}@{module_hash}'
107117
return _do_import_module_from_file(filename, module_name)
108118

unittests/resources/checks_unlisted/testlib/__init__.py

Whitespace-only changes.

unittests/resources/checks_unlisted/testlib/simple.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@
55

66
import reframe as rfm
77
import reframe.utility.sanity as sn
8-
9-
10-
class dummy_fixture(rfm.RunOnlyRegressionTest, pin_prefix=True):
11-
executable = 'echo'
12-
sanity_patterns = sn.assert_true(1)
8+
from .utility import dummy_fixture
139

1410

1511
@rfm.simple_test
16-
class simple_echo_check(rfm.RunOnlyRegressionTest):
12+
class simple_echo_check(rfm.RunOnlyRegressionTest, pin_prefix=True):
1713
descr = 'Simple Echo Test'
1814
valid_systems = ['*']
1915
valid_prog_environs = ['builtin']
2016
executable = 'echo'
2117
executable_opts = ['Hello']
22-
message = variable(str, value='World')
18+
message = variable(str, value='World')
2319
dummy = fixture(dummy_fixture, scope='environment')
2420

2521
@run_before('run')
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import reframe as rfm
2+
import reframe.utility.sanity as sn
3+
4+
5+
class dummy_fixture(rfm.RunOnlyRegressionTest):
6+
executable = 'echo'
7+
sanity_patterns = sn.assert_true(1)

unittests/resources/checks_unlisted/testlib_inheritance_foo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55

66
import reframe as rfm
7-
87
from testlib.simple import simple_echo_check
98

109

unittests/test_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,16 @@ def test_system_create(site_config):
436436
assert partition.local_env.env_vars == {'FOO_GPU': 'yes'}
437437
assert partition.max_jobs == 10
438438
assert partition.time_limit is None
439+
440+
# Check partition extras and features
441+
assert partition.features == ['cuda', 'mpi']
442+
assert partition.extras == {
443+
'gpu_arch': 'a100',
444+
'scheduler': 'slurm',
445+
'launcher': 'srun'
446+
}
447+
448+
# Check partition environments
439449
assert len(partition.environs) == 2
440450
assert partition.environment('PrgEnv-gnu').cc == 'cc'
441451
assert partition.environment('PrgEnv-gnu').cflags == []

0 commit comments

Comments
 (0)