Skip to content
Snippets Groups Projects
Commit d6efc8f4 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-824: processed review comments, better way of input checking.

parent dde44d0a
No related branches found
No related tags found
2 merge requests!74Lofar release 4 0,!73SW-824: Resolve SW-824
......@@ -123,23 +123,22 @@ def get_cep4_slurm_nodes(states, partition: str) -> []:
try:
# filter out unknown states
_states = [s for s in states if s in SLURM_STATES]
if not _states:
if any(s for s in states if s not in SLURM_STATES):
raise ValueError("the given states:%s are not valid slurm states:%s" % (states, SLURM_STATES))
if partition not in SLURM_PARTITIONS:
raise ValueError("the given partition:%s is not one of the valid cep4 slurm partition:%s" % (partition, SLURM_PARTITIONS))
logger.debug('determining available cep4 nodes states:%s, partition:%s', _states, partition)
logger.debug('determining available cep4 nodes states:%s, partition:%s', states, partition)
# find out which nodes are available
cmd = ['sinfo -p %s -t %s' % (partition, ','.join(_states))]
cmd = ['sinfo -p %s -t %s' % (partition, ','.join(states))]
cmd = wrap_command_in_cep4_head_node_ssh_call(cmd)
logger.debug('executing command: %s', ' '.join(cmd))
out = check_output_returning_strings(cmd)
lines = out.split('\n')
for state in _states:
for state in states:
try:
line = next(l for l in lines if state in l).strip()
# get nodes string part of line:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment