Skip to content

Commit 6bcdb55

Browse files
author
Vasileios Karakasis
authored
Merge branch 'master' into tensorflow_test
2 parents f439abd + 82a6bc8 commit 6bcdb55

File tree

8 files changed

+62
-12
lines changed

8 files changed

+62
-12
lines changed

config/cscs-ci.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@
209209
'checks/'
210210
],
211211
'check_search_recursive': True,
212-
'remote_detect': True
213212
}
214213
]
215214
}

docs/config_reference.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ System Partition Configuration
416416
:required: No
417417
:default: ``{}``
418418

419-
User defined attributes of the system partition that will be accessible from the ReFrame tests.
420-
By default it is an empty dictionary.
419+
User defined attributes of the partition. This will be accessible through the :attr:`~reframe.core.systems.SystemPartition.extras` attribute of the :attr:`~reframe.core.pipeline.RegressionTest.current_partition`.
421420

422421
.. versionadded:: 3.5.0
423422

@@ -582,6 +581,16 @@ They are associated with `system partitions <#system-partition-configuration>`__
582581
Variables are set after the environment modules are loaded.
583582

584583

584+
.. js:attribute:: .environments[].extras
585+
586+
:required: No
587+
:default: ``{}``
588+
589+
User defined attributes of the environment. This will be accessible through the :attr:`~reframe.core.environments.Environment.extras` attribute of the :attr:`~reframe.core.pipeline.RegressionTest.current_environ`.
590+
591+
.. versionadded:: 3.9.1
592+
593+
585594
.. js:attribute:: .environments[].cc
586595

587596
:required: No

reframe/core/environments.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ class Environment(jsonext.JSONSerializable):
3737
Users may not create :class:`Environment` objects directly.
3838
'''
3939

40-
def __init__(self, name, modules=None, variables=None):
40+
def __init__(self, name, modules=None, variables=None, extras=None):
4141
modules = modules or []
4242
variables = variables or []
4343
self._name = name
4444
self._modules = normalize_module_list(modules)
4545
self._module_names = [m['name'] for m in self._modules]
4646
self._variables = collections.OrderedDict(variables)
47+
self._extras = extras or {}
4748

4849
@property
4950
def name(self):
@@ -89,6 +90,17 @@ def variables(self):
8990
'''
9091
return util.MappingView(self._variables)
9192

93+
@property
94+
def extras(self):
95+
'''User defined properties defined in the configuration.
96+
97+
.. versionadded:: 3.9.1
98+
99+
:type: :class:`Dict[str, object]`
100+
'''
101+
102+
return self._extras
103+
92104
def __eq__(self, other):
93105
if not isinstance(other, type(self)):
94106
return NotImplemented
@@ -161,6 +173,7 @@ def __init__(self,
161173
name,
162174
modules=None,
163175
variables=None,
176+
extras=None,
164177
cc='cc',
165178
cxx='CC',
166179
ftn='ftn',
@@ -171,7 +184,7 @@ def __init__(self,
171184
fflags=None,
172185
ldflags=None,
173186
**kwargs):
174-
super().__init__(name, modules, variables)
187+
super().__init__(name, modules, variables, extras)
175188
self._cc = cc
176189
self._cxx = cxx
177190
self._ftn = ftn

reframe/core/systems.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,11 @@ def devices(self):
365365

366366
@property
367367
def extras(self):
368-
'''User defined attributes of the system.
369-
370-
By default, it is an empty dictionary.
368+
'''User defined properties defined in the configuration.
371369
372370
.. versionadded:: 3.5.0
373371
374-
:type: :class:`object`
372+
:type: :class:`Dict[str, object]`
375373
'''
376374
return self._extras
377375

@@ -481,6 +479,7 @@ def create(cls, site_config):
481479
name=e,
482480
modules=site_config.get(f'environments/@{e}/modules'),
483481
variables=site_config.get(f'environments/@{e}/variables'),
482+
extras=site_config.get(f'environments/@{e}/extras'),
484483
cc=site_config.get(f'environments/@{e}/cc'),
485484
cxx=site_config.get(f'environments/@{e}/cxx'),
486485
ftn=site_config.get(f'environments/@{e}/ftn'),

reframe/schemas/config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@
357357
"type": "array",
358358
"items": {"type": "string"}
359359
},
360+
"extras": {"type": "object"},
360361
"target_systems": {"$ref": "#/defs/system_ref"}
361362
},
362363
"required": ["name"],
@@ -494,6 +495,7 @@
494495
"environments/cxxflags": [],
495496
"environments/fflags": [],
496497
"environments/ldflags": [],
498+
"environments/extras": {},
497499
"environments/target_systems": ["*"],
498500
"general/check_search_path": ["${RFM_INSTALL_PREFIX}/checks/"],
499501
"general/check_search_recursive": false,

unittests/resources/settings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,21 @@
163163
'modules': [
164164
{'name': 'PrgEnv-gnu', 'collection': False, 'path': None}
165165
],
166+
'extras': {
167+
'foo': 2,
168+
'bar': 'y'
169+
},
166170
},
167171
{
168172
'name': 'PrgEnv-gnu',
169173
'modules': ['PrgEnv-gnu'],
170174
'cc': 'gcc',
171175
'cxx': 'g++',
172176
'ftn': 'gfortran',
177+
'extras': {
178+
'foo': 1,
179+
'bar': 'x'
180+
},
173181
'target_systems': ['testsys:login']
174182
},
175183
{

unittests/test_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ def test_select_subconfig():
259259
assert site_config.get('environments/1/cxx') == 'CC'
260260
assert (site_config.get('environments/@PrgEnv-cray/modules') ==
261261
[{'name': 'PrgEnv-cray', 'collection': False, 'path': None}])
262+
assert site_config.get('environments/@PrgEnv-gnu/extras') == {'foo': 1,
263+
'bar': 'x'}
264+
assert site_config.get('environments/@PrgEnv-cray/extras') == {}
265+
262266
assert len(site_config.get('general')) == 1
263267
assert site_config.get('general/0/check_search_path') == ['a:b']
264268

@@ -358,6 +362,7 @@ def test_system_create():
358362
assert len(partition.environs) == 2
359363
assert partition.environment('PrgEnv-gnu').cc == 'cc'
360364
assert partition.environment('PrgEnv-gnu').cflags == []
365+
assert partition.environment('PrgEnv-gnu').extras == {'foo': 2, 'bar': 'y'}
361366

362367
# Check resource instantiation
363368
resource_spec = partition.get_resource('gpu', num_gpus_per_node=16)

unittests/test_environments.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def user_runtime(make_exec_ctx_g):
5252
def env0():
5353
return env.Environment(
5454
'TestEnv1', ['testmod_foo'],
55-
[('_var0', 'val1'), ('_var2', '$_var0'), ('_var3', '${_var1}')]
55+
[('_var0', 'val1'), ('_var2', '$_var0'), ('_var3', '${_var1}')],
56+
{'foo': 1, 'bar': 2}
5657
)
5758

5859

@@ -74,8 +75,22 @@ def test_env_construction(base_environ, env0):
7475
assert env0.variables['_var0'] == 'val1'
7576

7677
# No variable expansion, if environment is not loaded
77-
env0.variables['_var2'] == '$_var0'
78-
env0.variables['_var3'] == '${_var1}'
78+
assert env0.variables['_var2'] == '$_var0'
79+
assert env0.variables['_var3'] == '${_var1}'
80+
81+
# Assert extras
82+
assert env0.extras == {'foo': 1, 'bar': 2}
83+
84+
85+
def test_progenv_construction():
86+
environ = env.ProgEnvironment('myenv',
87+
modules=['modfoo'],
88+
variables=[('var', 'val')],
89+
extras={'foo': 'bar'})
90+
assert environ.name == 'myenv'
91+
assert environ.modules == ['modfoo']
92+
assert environ.variables == {'var': 'val'}
93+
assert environ.extras == {'foo': 'bar'}
7994

8095

8196
def test_env_snapshot(base_environ, env0, env1):

0 commit comments

Comments
 (0)