Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ pub fn parse_args() -> ArgMatches {
)
.required(true)
)
.arg(
Arg::new("job_prefix")
.short('p')
.long("job_prefix")
.value_name("PREFIX")
.help("prefix for job submission name i.e. prefix_job_array")
.default_value("arrayify")
)
.arg(
Arg::new("log")
.short('l')
Expand All @@ -70,15 +78,15 @@ pub fn parse_args() -> ArgMatches {
.short('m')
.long("memory")
.value_name("MEMORY_GB")
.help("Amount of memory per job in GB (default: 1GB)")
.help("Amount of memory per job in GB")
.default_value("1")
)
.arg(
Arg::new("threads")
.short('t')
.long("threads")
.value_name("THREADS")
.help("Number of threads per job (default: 1)")
.help("Number of threads per job")
.default_value("1")
)
.arg(
Expand All @@ -94,7 +102,7 @@ pub fn parse_args() -> ArgMatches {
.short('q')
.long("queue")
.value_name("QUEUE")
.help("Bsub queue to submit to (default: normal)")
.help("Bsub queue to submit to")
.default_value("normal")
)
)
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn main() {
}

let command_template = sub_matches.get_one::<String>("command").unwrap();
let job_prefix = sub_matches.get_one::<String>("job_prefix").unwrap();
let log_dir = sub_matches.get_one::<String>("log").unwrap();
let memory_gb: u32 = sub_matches
.get_one::<String>("memory")
Expand Down Expand Up @@ -144,6 +145,7 @@ fn main() {
submission::submit_jobs(
input_path,
command_template,
job_prefix,
log_dir,
memory_gb,
threads,
Expand Down
8 changes: 6 additions & 2 deletions src/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ fn print_run_stats(num_jobs: usize, log_dir: &str, log_file_path: &str, job_id:
fn submit_jobs_to_scheduler(
job_file_path: &str,
log_dir: &str,
job_prefix: &str,
memory_mb: u32,
threads: u32,
queue: &str,
batch_size: usize,
) -> io::Result<String> {
// Count the number of lines in the file to determine the job array size
let num_jobs = count_lines_in_file(job_file_path)?;
let job_array = format!("arrayify_job_array[1-{}]%{}", num_jobs, batch_size);
let job_array = format!("{}_job_array[1-{}]%{}", job_prefix, num_jobs, batch_size);
let output_log = format!("{}/job_%J_%I.out", log_dir);
let error_log = format!("{}/job_%J_%I.err", log_dir);

Expand Down Expand Up @@ -99,6 +100,7 @@ $COMMAND
pub fn submit_jobs(
input_path: &str,
command_template: &str,
job_prefix: &str,
log_dir: &str,
memory_gb: u32,
threads: u32,
Expand Down Expand Up @@ -128,7 +130,7 @@ pub fn submit_jobs(

// Submit jobs to the scheduler
let batch_size = calculate_batch_size(jobs.len(), batch_size);
let job_id = submit_jobs_to_scheduler(&log_file_path, log_dir, memory_mb, threads, queue, batch_size)?;
let job_id = submit_jobs_to_scheduler(&log_file_path, log_dir, job_prefix, memory_mb, threads, queue, batch_size)?;

// Print run statistics
print_run_stats(jobs.len(), log_dir, &log_file_path, &job_id);
Expand Down Expand Up @@ -181,9 +183,11 @@ mod tests {
let result = submit_jobs(
csv_file.path().to_str().unwrap(),
"echo {header1}",
"arrayify",
"logs",
1,
1,
"normal",
None,
InputFormat::Csv,
);
Expand Down