Skip to content

Commit ac576c9

Browse files
authored
Merge branch 'master' into master_printfile
2 parents cf9509a + 982ae36 commit ac576c9

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

reframe/core/schedulers/slurm.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,21 @@ def _get_default_partition(self):
308308

309309
return None
310310

311+
def _get_actual_partition(self, options):
312+
try:
313+
completed = _run_strict(
314+
' '.join(['srun'] + options + ['--test-only', 'true'])
315+
)
316+
partition_match = re.search(r'partition (?P<partition>\S+)\s+',
317+
completed.stderr)
318+
if partition_match:
319+
return partition_match.group('partition')
320+
321+
except SpawnedProcessError as e:
322+
self.log('could not retrieve actual partition')
323+
324+
return None
325+
311326
def _merge_files(self, job):
312327
with osext.change_dir(job.workdir):
313328
out_glob = glob.glob(job.stdout + '_*')
@@ -345,11 +360,15 @@ def filternodes(self, job, nodes):
345360
nodes &= self._get_reservation_nodes(reservation)
346361
self.log(f'[F] Filtering nodes by reservation {reservation}: '
347362
f'available nodes now: {len(nodes)}')
348-
349363
if partitions:
350364
partitions = set(partitions.strip().split(','))
351365
else:
352-
default_partition = self._get_default_partition()
366+
# Use a default partition if one is configured. Otherwise,
367+
# fallback to the partition Slurm chooses for this set of options.
368+
default_partition = (
369+
self._get_default_partition() or
370+
self._get_actual_partition(options)
371+
)
353372
partitions = {default_partition} if default_partition else set()
354373
self.log(
355374
f'[F] No partition specified; using {default_partition!r}'

0 commit comments

Comments
 (0)