Skip to content

Commit af11e44

Browse files
author
Theofilos Manitaras
committed
Initial support for or(|) operator in node state
Signed-off-by: Theofilos Manitaras <manitaras@cscs.ch>
1 parent ce5a2e3 commit af11e44

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

reframe/core/schedulers/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,14 @@ def filter_nodes_by_state(nodelist, state):
165165
state string.
166166
:returns: the filtered node list
167167
'''
168-
if state == 'avail':
168+
if '|' in state:
169+
allowed_states = state.split('|')
170+
final_nodelist = set()
171+
for s in allowed_states:
172+
final_nodelist.update(filter_nodes_by_state(nodelist, s))
173+
174+
nodelist = final_nodelist
175+
elif state == 'avail':
169176
nodelist = {n for n in nodelist if n.is_avail()}
170177
elif state != 'all':
171178
if state.endswith('*'):

unittests/test_schedulers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,19 @@ def test_flex_alloc_not_enough_nodes_constraint_expr(make_flexible_job):
12471247
prepare_job(job)
12481248

12491249

1250+
def test_flex_alloc_allocated_or_idle_partition(make_flexible_job):
1251+
job = make_flexible_job('allocated|idle')
1252+
job.options = ['--partition=p3']
1253+
prepare_job(job)
1254+
assert job.num_tasks == 12
1255+
1256+
1257+
def test_flex_alloc_maint_star_or_allocated(make_flexible_job):
1258+
job = make_flexible_job('maint*|idle')
1259+
prepare_job(job)
1260+
assert job.num_tasks == 16
1261+
1262+
12501263
@pytest.fixture
12511264
def slurm_node_allocated():
12521265
return _SlurmNode(

0 commit comments

Comments
 (0)