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

Add 'get_partition_walltime_infos' function

parent 22606d0c
No related branches found
No related tags found
1 merge request!14Add 'get_partition_walltime_infos' function
Pipeline #206915 passed
from __future__ import annotations
import subprocess
import platform as _platform_mod
from shutil import which
......@@ -54,6 +56,30 @@ def get_partition_gpus(partition: str) -> tuple:
return tuple()
def get_partition_walltime_infos(partition: str) -> dict[str, str]:
"""
Return for the given partition:
* time: walltime limit
* default_time: default walltime
"""
process = SubProcessCommand(
command=f"sinfo --partition={partition} -O DefaultTime,Time"
)
try:
res = process.run()
except Exception:
return None, None
# treat output string
res = res.split("\n")
if len(res) < 1:
return None, None
else:
times = filter(lambda a: a, res[1].split(" "))
default_time, time = times
return default_time, time
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