Skip to content

Commit fdcf262

Browse files
author
Vasileios Karakasis
committed
Address PR comments
1 parent e0f8e79 commit fdcf262

File tree

4 files changed

+30
-33
lines changed

4 files changed

+30
-33
lines changed

reframe/core/schedulers/slurm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def filternodes(self, job, nodes):
292292
# Collect options that restrict node selection, but we need to first
293293
# create a mutable list out of the immutable SequenceView that
294294
# sched_access is
295-
options = list(job.sched_access + job.options + job.cli_options)
295+
options = job.sched_access + job.options + job.cli_options
296296
option_parser = ArgumentParser()
297297
option_parser.add_argument('--reservation')
298298
option_parser.add_argument('-p', '--partition')

reframe/frontend/autodetect.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ def detect_topology():
200200
if not found_procinfo:
201201
# No topology found, try to auto-detect it
202202
getlogger().debug(f'> no topology file found; auto-detecting...')
203-
temp_modules = rt.system.preload_environ.modules
204-
temp_vars = rt.system.preload_environ.variables
203+
modules = list(rt.system.preload_environ.modules)
204+
vars = dict(rt.system.preload_environ.variables.items())
205205
if _is_part_local(part):
206-
temp_modules += part.local_env.modules
207-
temp_vars += part.local_env.variables
206+
modules += part.local_env.modules
207+
vars.update(part.local_env.variables)
208+
208209
# Unconditionally detect the system for fully local partitions
209-
with runtime.temp_environment(modules=temp_modules,
210-
variables=temp_vars):
210+
with runtime.temp_environment(modules=modules, variables=vars):
211211
part.processor._info = cpuinfo()
212212

213213
_save_info(topo_file, part.processor.info)

reframe/utility/__init__.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,12 @@ class SequenceView(collections.abc.Sequence):
13381338
:raises TypeError: If the container does not fulfill the
13391339
:py:class:`collections.abc.Sequence` interface.
13401340
1341+
.. note::
1342+
1343+
You can concatenate a :class:`SequenceView` with a container of the
1344+
same type as the underlying container of the view, in which case a new
1345+
container with the concatenated elements will be returned.
1346+
13411347
'''
13421348

13431349
def __init__(self, container):
@@ -1388,16 +1394,16 @@ def __reversed__(self):
13881394
return self.__container.__reversed__()
13891395

13901396
def __add__(self, other):
1391-
if not isinstance(other, collections.abc.Sequence):
1397+
if not isinstance(other, type(self.__container)):
13921398
return NotImplemented
13931399

1394-
if isinstance(other, SequenceView):
1395-
return SequenceView(self.__container + other.__container)
1396-
else:
1397-
return SequenceView(self.__container + other)
1400+
return self.__container + other
13981401

1399-
def __iadd__(self, other):
1400-
return NotImplemented
1402+
def __radd__(self, other):
1403+
if not isinstance(other, type(self.__container)):
1404+
return NotImplemented
1405+
1406+
return other + self.__container
14011407

14021408
def __eq__(self, other):
14031409
if isinstance(other, SequenceView):
@@ -1473,11 +1479,3 @@ def __repr__(self):
14731479

14741480
def __str__(self):
14751481
return str(self.__mapping)
1476-
1477-
def __add__(self, other):
1478-
if not isinstance(other, type(self)):
1479-
return NotImplemented
1480-
1481-
new_mapping = self.__mapping.copy()
1482-
new_mapping.update(other.__mapping)
1483-
return MappingView(new_mapping)

unittests/test_utility.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,18 +1072,18 @@ def test_sequence_view():
10721072
# Assert immutability
10731073
m = l + [3, 4]
10741074
assert [1, 2, 2, 3, 4] == m
1075-
assert isinstance(m, util.SequenceView)
1075+
assert isinstance(m, list)
10761076

1077-
m = l
1078-
l += [3, 4]
1079-
assert m is not l
1080-
assert [1, 2, 2] == m
1081-
assert [1, 2, 2, 3, 4] == l
1082-
assert isinstance(l, util.SequenceView)
1077+
m_orig = m = util.SequenceView([1])
1078+
m += [3, 4]
1079+
assert m is not m_orig
1080+
assert [1] == m_orig
1081+
assert [1, 3, 4] == m
1082+
assert isinstance(m, list)
10831083

10841084
n = m + l
1085-
assert [1, 2, 2, 1, 2, 2, 3, 4] == n
1086-
assert isinstance(n, util.SequenceView)
1085+
assert [1, 3, 4, 1, 2, 2] == n
1086+
assert isinstance(n, list)
10871087

10881088
with pytest.raises(TypeError):
10891089
l[1] = 3
@@ -1137,8 +1137,6 @@ def test_mapping_view():
11371137
assert d == util.MappingView({'b': 2, 'a': 1})
11381138
assert str(d) == str({'a': 1, 'b': 2})
11391139
assert {'a': 1, 'b': 2, 'c': 3} != d
1140-
e = util.MappingView({'c': 3})
1141-
assert {'a': 1, 'b': 2, 'c': 3} == d + e
11421140

11431141
# Assert immutability
11441142
with pytest.raises(TypeError):
@@ -1548,6 +1546,7 @@ def test_jsonext_dumps():
15481546
)
15491547
assert '{"(1, 2, 3)": 1}' == jsonext.dumps({(1, 2, 3): 1})
15501548

1549+
15511550
# Classes to test JSON deserialization
15521551

15531552
class _D(jsonext.JSONSerializable):

0 commit comments

Comments
 (0)