Spaces:
Running
on
Zero
Running
on
Zero
File size: 471 Bytes
2d9a728 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
import shutil
import socket
def has_slurm():
"""determine the system has slurm or not
Returns: True if has else False.
"""
return shutil.which("sbatch") is not None
def random_port():
"""random a unused port
Returns: str
"""
with socket.socket() as s:
s.bind(("", 0))
return s.getsockname()[1]
def runcmd(cmd):
"""run command
Args:
cmd (str): The command to run
"""
os.system(cmd)
|