Skip to content

Commit 6af68b2

Browse files
authored
Merge branch 'master' into bugfix_expand_nodelist
2 parents fe05d83 + 53aad83 commit 6af68b2

File tree

13 files changed

+57
-25
lines changed

13 files changed

+57
-25
lines changed

reframe/core/environments.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ def __init__(self, name, modules=None, env_vars=None,
4545
self._name = name
4646
self._modules = normalize_module_list(modules)
4747
self._module_names = [m['name'] for m in self._modules]
48-
self._env_vars = collections.OrderedDict(env_vars)
48+
49+
# Convert values of env_vars to strings before storing
50+
if isinstance(env_vars, dict):
51+
env_vars = env_vars.items()
52+
53+
self._env_vars = collections.OrderedDict()
54+
for k, v in env_vars:
55+
self._env_vars[k] = str(v)
56+
4957
self._extras = extras or {}
5058
self._features = features or []
5159

@@ -131,9 +139,19 @@ def __eq__(self, other):
131139
if not isinstance(other, type(self)):
132140
return NotImplemented
133141

134-
return (self.name == other.name and
135-
set(self.modules) == set(other.modules) and
136-
self.env_vars == other.env_vars)
142+
if (self.name != other.name or
143+
set(self.modules) != set(other.modules)):
144+
return False
145+
146+
# Env. variables are checked against their string representation
147+
for kv0, kv1 in zip(self.env_vars.items(),
148+
other.env_vars.items()):
149+
k0, v0 = kv0
150+
k1, v1 = kv1
151+
if k0 != k1 or str(v0) != str(v1):
152+
return False
153+
154+
return True
137155

138156
def __str__(self):
139157
return self.name

reframe/core/pipeline.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,18 @@ def pipeline_hooks(cls):
781781

782782
#: Environment variables to be set before running this test.
783783
#:
784-
#: :type: :class:`Dict[str, str]`
784+
#: The value of the environment variables can be of any type. ReFrame will
785+
#: invoke :func:`str` on it whenever it needs to emit it in a script.
786+
#:
787+
#: :type: :class:`Dict[str, object]`
785788
#: :default: ``{}``
786789
#:
787790
#: .. versionadded:: 4.0.0
788-
env_vars = variable(typ.Dict[str, str], value={}, loggable=True)
791+
env_vars = variable(typ.Dict[str, str],
792+
typ.Dict[str, object], value={}, loggable=True)
793+
# NOTE: We still keep the original type, just to allow setting this
794+
# variable from the command line, because otherwise, ReFrame will not know
795+
# how to convert a value to an arbitrary object.
789796

790797
#: Environment variables to be set before running this test.
791798
#:

reframe/core/runtime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ def __init__(self, modules=[], variables=[]):
382382
self._variables = variables
383383

384384
def __enter__(self):
385-
new_env = Environment('_rfm_temp_env', self._modules, self._variables)
385+
new_env = Environment('_rfm_temp_env', self._modules,
386+
self._variables.items())
386387
self._environ_save, _ = loadenv(new_env)
387388
return new_env
388389

tutorials/advanced/parameterized/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def set_num_threads(self):
6868
num_threads = self.cores.get(self.current_partition.fullname, 1)
6969
self.num_cpus_per_task = num_threads
7070
self.env_vars = {
71-
'OMP_NUM_THREADS': str(num_threads),
71+
'OMP_NUM_THREADS': num_threads,
7272
'OMP_PLACES': 'cores'
7373
}
7474

tutorials/basics/stream/stream4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StreamMultiSysTest(rfm.RegressionTest):
1818
build_system = 'SingleSource'
1919
sourcepath = 'stream.c'
2020
env_vars = {
21-
'OMP_NUM_THREADS': '4',
21+
'OMP_NUM_THREADS': 4,
2222
'OMP_PLACES': 'cores'
2323
}
2424
reference = {
@@ -57,7 +57,7 @@ def set_num_threads(self):
5757
num_threads = self.cores.get(self.current_partition.fullname, 1)
5858
self.num_cpus_per_task = num_threads
5959
self.env_vars = {
60-
'OMP_NUM_THREADS': str(num_threads),
60+
'OMP_NUM_THREADS': num_threads,
6161
'OMP_PLACES': 'cores'
6262
}
6363

tutorials/cscs-webinar-2022/tests/stream4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def setup_omp_env(self):
3030
procinfo = self.current_partition.processor
3131
self.num_cpus_per_task = procinfo.num_cores
3232
self.env_vars = {
33-
'OMP_NUM_THREADS': str(self.num_cpus_per_task),
33+
'OMP_NUM_THREADS': self.num_cpus_per_task,
3434
'OMP_PLACES': 'cores'
3535
}
3636

tutorials/cscs-webinar-2022/tests/stream5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setup_omp_env(self):
3333
procinfo = self.current_partition.processor
3434
self.num_cpus_per_task = procinfo.num_cores
3535
self.env_vars = {
36-
'OMP_NUM_THREADS': str(self.num_cpus_per_task),
36+
'OMP_NUM_THREADS': self.num_cpus_per_task,
3737
'OMP_PLACES': 'cores'
3838
}
3939

tutorials/cscs-webinar-2022/tests/stream6.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def setup_omp_env(self):
3535
procinfo = self.current_partition.processor
3636
self.num_cpus_per_task = procinfo.num_cores
3737
self.env_vars = {
38-
'OMP_NUM_THREADS': str(self.num_cpus_per_task),
38+
'OMP_NUM_THREADS': self.num_cpus_per_task,
3939
'OMP_PLACES': 'cores'
4040
}
4141

tutorials/cscs-webinar-2022/tests/stream7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def setup_omp_env(self):
4646
procinfo = self.current_partition.processor
4747
self.num_cpus_per_task = procinfo.num_cores
4848
self.env_vars = {
49-
'OMP_NUM_THREADS': str(self.num_cpus_per_task),
49+
'OMP_NUM_THREADS': self.num_cpus_per_task,
5050
'OMP_PLACES': 'cores'
5151
}
5252

tutorials/cscs-webinar-2022/tests/stream8.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def setup_omp_env(self):
4646
procinfo = self.current_partition.processor
4747
self.num_cpus_per_task = procinfo.num_cores
4848
self.env_vars = {
49-
'OMP_NUM_THREADS': str(self.num_cpus_per_task),
49+
'OMP_NUM_THREADS': self.num_cpus_per_task,
5050
'OMP_PLACES': 'cores'
5151
}
5252

@@ -67,7 +67,7 @@ class stream_scale_test(stream_test):
6767
@run_before('run')
6868
def set_cpus_per_task(self):
6969
self.num_cpus_per_task = self.num_threads
70-
self.env_vars['OMP_NUM_THREADS'] = str(self.num_cpus_per_task)
70+
self.env_vars['OMP_NUM_THREADS'] = self.num_cpus_per_task
7171

7272
@run_after('setup')
7373
def skip_if_too_large(self):

0 commit comments

Comments
 (0)