Skip to content
Snippets Groups Projects
Commit b2e6500c authored by payno's avatar payno
Browse files

utils: add 'get_partition_nodes' function

parent 6ad8f7ec
No related branches found
No related tags found
1 merge request!19utils: add 'get_partition_nodes' function
Pipeline #231970 failed
......@@ -83,6 +83,28 @@ def get_partition_walltime(partition: str) -> dict[str, str]:
}
def get_partition_nodes(partition: str) -> tuple:
"""
For a given partition return the available nodes
"""
process = SubProcessCommand(command=f"sinfo --partition={partition} --Node")
try:
res = process.run()
except Exception:
return None, None
# treat output string
res = res.split("\n")
if len(res) < 1:
return tuple()
else:
# pop first list (HEADER)
res = res[1:]
return tuple(
filter(None, [line.split(" ")[0] for line in res]) # filter empty strings
)
class SubProcessCommand:
def __init__(self, command, platform="Linux"):
if platform != _platform_mod.system():
......
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