Skip to content

Commit dcc72f0

Browse files
authored
Merge pull request #64 from marinak-ebi/rate-limiting
Create function `submit_limit_jobs` that limit number of submitted job
2 parents 593e8f1 + ec4a986 commit dcc72f0

File tree

1 file changed

+22
-1
lines changed
  • Late adults stats pipeline/DRrequiredAgeing/DRrequiredAgeingPackage/R

1 file changed

+22
-1
lines changed

Late adults stats pipeline/DRrequiredAgeing/DRrequiredAgeingPackage/R/sideFunctions.R

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4552,6 +4552,27 @@ waitTillCommandFinish = function(checkcommand = 'squeue --format="%A %.30j"',
45524552
message0('continuing the pipeline ...')
45534553
}
45544554

4555+
submit_limit_jobs = function(bch_file,
4556+
job_id_logfile,
4557+
max_jobs=400) {
4558+
message0("Start submit_limit_jobs")
4559+
system(paste("echo > ", job_id_logfile))
4560+
file <- file(bch_file, "r")
4561+
while (length(command <- readLines(file, n = 1, warn = FALSE)) > 0) {
4562+
while(TRUE) {
4563+
num_running <- as.integer(system("squeue | wc -l", wait=TRUE, intern = TRUE))
4564+
if(num_running <= max_jobs) {
4565+
break
4566+
}
4567+
Sys.sleep(1)
4568+
}
4569+
job_id <- system(command, wait=TRUE, intern = TRUE)
4570+
system(paste("echo '", job_id, "' >> ", job_id_logfile))
4571+
}
4572+
close(file)
4573+
message0("End submit_limit_jobs")
4574+
}
4575+
45554576
filesContain = function(path = getwd(),
45564577
extension = NULL,
45574578
containWhat = 'Exit',
@@ -4852,7 +4873,7 @@ StatsPipeline = function(path = getwd(),
48524873
DRversion)
48534874

48544875
system('chmod 775 AllJobs.bch', wait = TRUE)
4855-
system('sbatch --job-name=impc_stats_pipeline_job --time=05:00:00 --mem=1G -o ../../compressed_logs/phase3_job_id.txt --wrap="bash ./AllJobs.bch"', wait = TRUE)
4876+
submit_limit_jobs(bch_file="AllJobs.bch", job_id_logfile="../../compressed_logs/phase3_job_id.txt")
48564877
waitTillCommandFinish(
48574878
WaitIfTheOutputContains = waitUntillSee,
48584879
ignoreline = ignoreThisLineInWaitingCheck

0 commit comments

Comments
 (0)