Skip to content
Snippets Groups Projects
Commit 21d0f5f1 authored by Matthew K Defenderfer's avatar Matthew K Defenderfer
Browse files

Add random delay to nested sbatch submissions

parent 3f9bb027
No related branches found
No related tags found
1 merge request!62Add random delay to nested sbatch submissions
import argparse import argparse
import subprocess import subprocess
import time
import random
from pathlib import Path from pathlib import Path
import polars as pl import polars as pl
...@@ -76,6 +78,12 @@ def submit_batch(**kwargs): ...@@ -76,6 +78,12 @@ def submit_batch(**kwargs):
script = f"#!/bin/bash\n#\n{slurm_opts}\n{BATCH_CMDS.format(**kwargs)}" script = f"#!/bin/bash\n#\n{slurm_opts}\n{BATCH_CMDS.format(**kwargs)}"
# Wait between 1 and 5 seconds before batch submission. This helps avoid a situation where this setup is running in
# a batch array job and all of the array tasks submit their child array jobs at the same time. That results in jobs
# failing to be submitted due to overwhelming the scheduler with simultaneous requests. Adding a random delay should
# fix that
time.sleep(random.uniform(1,5))
subprocess.run(['sbatch'],input=script,shell=True,text=True) subprocess.run(['sbatch'],input=script,shell=True,text=True)
pass pass
......
import argparse import argparse
import re import time
import random
import subprocess import subprocess
from pathlib import Path from pathlib import Path
import multiprocessing import multiprocessing
...@@ -71,6 +72,12 @@ def submit_batch(**kwargs): ...@@ -71,6 +72,12 @@ def submit_batch(**kwargs):
script = BATCH_SCRIPT.format(**kwargs) script = BATCH_SCRIPT.format(**kwargs)
# Wait between 1 and 5 seconds before batch submission. This helps avoid a situation where this setup is running in
# a batch array job and all of the array tasks submit their child array jobs at the same time. That results in jobs
# failing to be submitted due to overwhelming the scheduler with simultaneous requests. Adding a random delay should
# fix that
time.sleep(random.uniform(1, 5))
subprocess.run(['sbatch'],input=script,shell=True,text=True) subprocess.run(['sbatch'],input=script,shell=True,text=True)
pass pass
......
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