in ablations/evaluation/launch_evals.py [0:0]
def launch_slurm_job(launch_file_contents, *args):
"""
Small helper function to save a sbatch script and call it.
Args:
launch_file_contents: Contents of the sbatch script
*args: any other arguments to pass to the sbatch command
Returns: the id of the launched slurm job
"""
with tempfile.NamedTemporaryFile("w") as f:
f.write(launch_file_contents)
f.flush()
try:
return subprocess.check_output(["sbatch", *args, f.name]).decode("utf-8").split()[-1]
except Exception as e:
print(launch_file_contents, flush=True)
raise e