| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | #ABSTRACT: Run a job in the cluster using NBI::Slurm | ||||||||||||||||||||||||||||||||||||||||||
| 3 | #PODNAME: runjob | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use v5.12; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use FindBin qw($RealBin); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Term::ANSIColor qw(:constants); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Cwd qw(abs_path getcwd); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | my $BIN = basename($0); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | if (-e "$RealBin/../dist.ini") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | say STDERR "[dev mode] Using local lib" if ($ENV{"DEBUG"}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use lib "$RealBin/../lib"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use NBI::Slurm; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use NBI::EcoScheduler; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | my $user_home_dir = $ENV{HOME}; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | my @afterok; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | my $user_current_dir = getcwd(); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | my $username = $ENV{USER}; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | my $config = NBI::Slurm::load_config("$user_home_dir/.nbislurm.config"); | |||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | my $version = $NBI::Slurm::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | my $queue = $config->{'queue'} // 'qib-short'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"queue"} // "qib-short"
MC/DC0%0/1
$config->{"queue"} // "qib-short"
$config->{"queue"}
Truth table50%1/2
A
A= $config->{"queue"}
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | my $gpuqueue = $config->{'gpuqueue'} // 'qib-gpu'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"gpuqueue"} // "qib-gpu"
MC/DC0%0/1
$config->{"gpuqueue"} // "qib-gpu"
$config->{"gpuqueue"}
Truth table50%1/2
A
A= $config->{"gpuqueue"}
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | my $threads = $config->{'threads'} // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"threads"} // 1
MC/DC0%0/1
$config->{"threads"} // 1
$config->{"threads"}
Truth table50%1/2
A
A= $config->{"threads"}
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | my $memory = $config->{'memory'} // 8000; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"memory"} // 8000
MC/DC0%0/1
$config->{"memory"} // 8000
$config->{"memory"}
Truth table50%1/2
A
A= $config->{"memory"}
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | my $time = $config->{'time'} // "2h"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"time"} // "2h"
MC/DC0%0/1
$config->{"time"} // "2h"
$config->{"time"}
Truth table50%1/2
A
A= $config->{"time"}
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | my $tmpdir = $config->{'tmpdir'} // "/tmp"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"tmpdir"} // "/tmp"
MC/DC0%0/1
$config->{"tmpdir"} // "/tmp"
$config->{"tmpdir"}
Truth table50%1/2
A
A= $config->{"tmpdir"}
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | my $name; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | my $email_address = $config->{'email'} // undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"email"} // undef
MC/DC0%0/1
$config->{"email"} // undef
$config->{"email"}
Truth table50%1/2
A
A= $config->{"email"}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | my $mail_type = $config->{'email_type'} // "none"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"email_type"} // "none"
MC/DC0%0/1
$config->{"email_type"} // "none"
$config->{"email_type"}
Truth table50%1/2
A
A= $config->{"email_type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | my $opt_placeholder = $config->{'placeholder'} // "#FILE#"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"placeholder"} // "#FILE#"
MC/DC0%0/1
$config->{"placeholder"} // "#FILE#"
$config->{"placeholder"}
Truth table50%1/2
A
A= $config->{"placeholder"}
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | my $params_array_file; | |||||||||||||||||||||||||||||||||||||||||
| 44 | my $command; | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | my $verbose; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | my $debug; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | my $run; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | my $gpu; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | my $opt_eco; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | my $opt_no_eco; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | my @slurm_options; | |||||||||||||||||||||||||||||||||||||||||
| 52 | GetOptions( | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'm|memory=s' => \$memory, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 'c|cores|threads=i' => \$threads, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 'q|queue=s' => \$queue, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 'T|time=s' => \$time, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 'w|tmpdir=s' => \$tmpdir, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 'n|name=s' => \$name, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 'r|run' => \$run, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 'a|email-address=s' => \$email_address, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 'e|mail-type=s' => \$mail_type, # 'BEGIN,END,FAIL,REQUEUE,ALL' | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 'after=s' => \@afterok, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 'f|files=s' => \my @files, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 'p|params-array=s' => \$params_array_file, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 'placeholder=s' => \$opt_placeholder, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 'gpu' => \$gpu, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 'option=s' => \@slurm_options, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 'eco' => \$opt_eco, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 'no-eco' => \$opt_no_eco, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 'verbose' => \$verbose, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | 'version' => sub { say "runjob v", $NBI::Slurm::VERSION; exit }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 'debug' => \$debug, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | 'help' => sub { usage(1) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | ) or usage(1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | if ($opt_eco && $opt_no_eco) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt_eco and $opt_no_eco
MC/DC0%0/2
$opt_eco and $opt_no_eco
$opt_eco
$opt_no_eco
Truth table33%1/3
A and B
A= $opt_ecoB= $opt_no_eco
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " --eco and --no-eco are mutually exclusive"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | $debug = 1 if ($ENV{"DEBUG"}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | $verbose = 1 if ($debug); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | # Update queue based on time | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | my $time_hours = NBI::Opts::_time_to_hour($time); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | $queue = update_queue($queue, $time_hours); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | $command = join(" ", @ARGV); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | usage(1) unless ($command); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ▶ | if (@files and defined $params_array_file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@files and defined $params_array_file
MC/DC50%1/2
@files and defined $params_array_file
@files
defined $params_array_file
Truth table66%2/3
A and B
A= @filesB= defined $params_array_file
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | say STDERR RED, BOLD, "ERROR:", RESET, " --files and --params-array are mutually exclusive"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | my @abs_files = get_abs_files(@files); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | my ($params_array_abs, $params_rows) = get_params_array_info($params_array_file, $command); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | my $total_array_tasks = @abs_files ? scalar(@abs_files) : $params_rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | my $array_task_limit = get_array_task_limit($config); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my @array_chunks = build_array_chunks($total_array_tasks, $array_task_limit); | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | say STDERR YELLOW, BOLD, "PARAMETERS:",RESET; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | say STDERR YELLOW, "Queue: ", RESET, $queue // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$queue // "(not set)"
MC/DC0%0/1
$queue // "(not set)"
$queue
Truth table0%0/2
A
A= $queue
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | say STDERR YELLOW, "Memory: ", RESET, $memory // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$memory // "(not set)"
MC/DC0%0/1
$memory // "(not set)"
$memory
Truth table0%0/2
A
A= $memory
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | say STDERR YELLOW, "Threads: ", RESET, $threads // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$threads // "(not set)"
MC/DC0%0/1
$threads // "(not set)"
$threads
Truth table0%0/2
A
A= $threads
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | say STDERR YELLOW, "Time: ", RESET, $time // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$time // "(not set)"
MC/DC0%0/1
$time // "(not set)"
$time
Truth table0%0/2
A
A= $time
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | say STDERR YELLOW, "Tmpdir: ", RESET, $tmpdir // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tmpdir // "(not set)"
MC/DC0%0/1
$tmpdir // "(not set)"
$tmpdir
Truth table0%0/2
A
A= $tmpdir
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | say STDERR YELLOW, "Name: ", RESET, $name // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name // "(not set)"
MC/DC0%0/1
$name // "(not set)"
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | say STDERR YELLOW, "Command: ", RESET, $command // "(not set)"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$command // "(not set)"
MC/DC0%0/1
$command // "(not set)"
$command
Truth table0%0/2
A
A= $command
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | say STDERR YELLOW, "Params TSV: ", RESET, $params_array_abs if defined $params_array_abs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | say STDERR YELLOW, "Array size: ", RESET, $total_array_tasks if $total_array_tasks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | say STDERR YELLOW, "Array cap: ", RESET, $array_task_limit if defined $array_task_limit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # Check threadshours | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | if (-d $time) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " did you mean \"--tmpdir $time\" instead of $threads threads?"; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | usage(); | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | # Sanitize tempdir | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | if (-d $tmpdir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | $tmpdir = File::Spec->rel2abs($tmpdir); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | say STDERR "[DEBUG] Using $tmpdir as temporary directory" if ($debug); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | # Check if it was meant to be a TIME instead | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ($tmpdir =~/ / or $tmpdir =~/(\d+)[dh]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tmpdir =~ / /u or $tmpdir =~ /(\d+)[dh]/u
MC/DC0%0/2
$tmpdir =~ / /u or $tmpdir =~ /(\d+)[dh]/u
$tmpdir =~ / /u
$tmpdir =~ /(\d+)[dh]/u
Truth table0%0/3
A or B
A= $tmpdir =~ / /uB= $tmpdir =~ /(\d+)[dh]/u
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | say STDERR RED, BOLD, "WARNING:", RESET, " $tmpdir looks like a time string, not a directory!"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | mkdir($tmpdir) or die "Cannot create $tmpdir: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " Cannot create $tmpdir: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 136 | ▶ | } elsif ($verbose or $debug) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$verbose or $debug
MC/DC0%0/2
$verbose or $debug
$verbose
$debug
Truth table0%0/3
A or B
A= $verboseB= $debug
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | say STDERR "[INFO] Created $tmpdir"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | # Sanitize memory | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | if ($memory =~/^(\d+)$/ and $1 < 200) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$memory =~ /^(\d+)$/u and $1 < 200
MC/DC0%0/2
$memory =~ /^(\d+)$/u and $1 < 200
$memory =~ /^(\d+)$/u
$1 < 200
Truth table33%1/3
A and B
A= $memory =~ /^(\d+)$/uB= $1 < 200
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | say STDERR RED, BOLD, "WARNING:", RESET, " $memory is in Mb but <200, autoscaling to $memory GB"; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $memory = $1 * 1000; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | ▶ | $name = autoname($command) unless (defined $name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | say STDERR "[DEBUG] Using $name as job name" if ($debug); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | my $afterok_string = defined $afterok[0] ? "-d afterok:" . join(":", @afterok) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # Prepare additional SLURM options | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | my @additional_opts = (); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | ▶ | push @additional_opts, $afterok_string if defined $afterok_string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | push @additional_opts, "--gres=gpu:1" if $gpu; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | push @additional_opts, @slurm_options if @slurm_options; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | $queue = $gpuqueue if $gpu; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | if (not NBI::Slurm::valid_queue($queue)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | my @valid_queues = NBI::Slurm::queues('CAN FAIL'); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | if (scalar @valid_queues) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | say STDERR RED, BOLD, "WARNING:", RESET, " $queue is not a valid queue: ", join(", ", @valid_queues); | |||||||||||||||||||||||||||||||||||||||||
| 165 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | if ($run) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " You might be outside a slurm cluster. Run without --run to see the script", join(", ", @valid_queues); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | say STDERR RED, BOLD, "WARNING:", RESET, " You might be outside a slurm cluster", join(", ", @valid_queues); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | # Eco scheduling | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # eco_default from config defaults to 1 (on) if not explicitly set | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | my $eco_default = defined $config->{eco_default} ? $config->{eco_default} : $NBI::EcoScheduler::DEFAULTS{eco_default}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | my $use_eco = $opt_no_eco ? 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | : $opt_eco ? 1 | ||||||||||||||||||||||||||||||||||||||||||
| 183 | : $eco_default; | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | if ($use_eco) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | if (defined $config->{start_time} || defined $config->{start_date}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $config->{"start_time"} or defined $config->{"start_date"}
MC/DC0%0/2
defined $config->{"start_time"} or defined $config->{"start_date"}
defined $config->{"start_time"}
defined $config->{"start_date"}
Truth table33%1/3
A or B
A= defined $config->{"start_time"}B= defined $config->{"start_date"}
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | say STDERR YELLOW, "[eco] --begin already set explicitly, ignoring eco scheduling", RESET; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub xdump { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xdump: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my ($hash_of_hashes, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $indent //= ' '; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$indent //= " "
MC/DC0%0/1
$indent //= " "
$indent
Truth table0%0/2
A
A= $indent
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | while (my ($key, $value) = each %$hash_of_hashes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if (ref $value eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | print STDERR BOLD, "$indent$key :\n", RESET; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | xdump($value, "$indent "); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | print "$indent\n"; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | print STDERR "$indent$key = $value\n"; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | if (@array_chunks > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | say STDERR YELLOW, "[array] Splitting $total_array_tasks tasks into ", scalar(@array_chunks), " jobs", RESET; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | my @jobs; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | my $name_width = scalar(@array_chunks) > 1 ? length(scalar(@array_chunks)) : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | for my $chunk_idx (0 .. $#array_chunks) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | my ($array_offset, $chunk_tasks) = @{$array_chunks[$chunk_idx]}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | my @job_files = @abs_files; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | my $job_params_array = $params_array_abs; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | my $job_params_rows = $params_rows; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | my $job_array_offset = 0; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | ▶ | if (@abs_files && @array_chunks > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
@abs_files and @array_chunks > 1
MC/DC0%0/2
@abs_files and @array_chunks > 1
@abs_files
@array_chunks > 1
Truth table33%1/3
A and B
A= @abs_filesB= @array_chunks > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | @job_files = @abs_files[$array_offset .. ($array_offset + $chunk_tasks - 1)]; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } elsif (defined $params_array_abs) { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | $job_array_offset = $array_offset; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | my $job_name = $name; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 4 | ▶ | if (@array_chunks > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | $job_name = sprintf("%s.part%0*d", $name, $name_width, $chunk_idx + 1); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | my $opts = NBI::Opts->new( | |||||||||||||||||||||||||||||||||||||||||
| 231 | -queue => $queue, | ||||||||||||||||||||||||||||||||||||||||||
| 232 | -threads => $threads, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | -memory => $memory, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | -time => $time, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | -tmpdir => $tmpdir, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | -email_address => $email_address, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | -email_type => $mail_type, | ||||||||||||||||||||||||||||||||||||||||||
| 238 | -opts => \@additional_opts, | ||||||||||||||||||||||||||||||||||||||||||
| 239 | -files => \@job_files, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | -params_array => $job_params_array, | ||||||||||||||||||||||||||||||||||||||||||
| 241 | -params_rows => $job_params_rows, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | -placeholder => $opt_placeholder, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | -array_offset => $job_array_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | -array_tasks => $chunk_tasks, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | ▶ | if ($use_eco) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | my ($begin_epoch, $tier) = NBI::EcoScheduler::find_eco_begin($opts->hours, $config); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ▶ | if (defined $begin_epoch) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | my $begin_str = NBI::EcoScheduler::epoch_to_slurm($begin_epoch); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | my $delay = NBI::EcoScheduler::format_delay($begin_epoch); | |||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ($opts->{start_date}, $opts->{start_time}) = split /T/, $begin_str; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | my $tier_warn = $tier == 2 ? " (job may overrun eco window)" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | : $tier == 3 ? " (job may overlap peak hours — best available)" | ||||||||||||||||||||||||||||||||||||||||||
| 255 | : ""; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | say STDERR GREEN, "[eco] Job scheduled for $begin_str (in $delay)$tier_warn", RESET if $chunk_idx == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | say STDERR YELLOW, "[eco] No eco slot found in lookahead period, submitting immediately", RESET if $chunk_idx == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | say STDERR GREEN, "CONFIG:\n", RESET if $chunk_idx == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | xdump($config) if $chunk_idx == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | print STDERR "\n" if $chunk_idx == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | say STDERR $opts->view(); | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | my $job = NBI::Job->new( | |||||||||||||||||||||||||||||||||||||||||
| 270 | -name => $job_name, | ||||||||||||||||||||||||||||||||||||||||||
| 271 | -command => "cd \"$user_current_dir\"", | ||||||||||||||||||||||||||||||||||||||||||
| 272 | -opts => $opts, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | ▶ | if ($debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | say STDERR YELLOW, "JOB:\n", RESET, Dumper($job); | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 4 | $job->append_command($command); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | push @jobs, $job; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | my $err = 0; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | ▶ | if ($run) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | my @job_ids; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | for my $job (@jobs) { | |||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | my $j = $job->run(); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | if ($j) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 3 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | say STDERR $job->view(); | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | push @job_ids, $j; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | say STDERR RED, "Job not submitted: $j", RESET; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | say STDERR $job->view(); | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $err = 1; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | ▶ | if (!$err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | say $_ for @job_ids; | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | for my $idx (0 .. $#jobs) { | |||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | say STDERR GREEN, "JOB SCRIPT\n", RESET if @jobs == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ▶ | say STDERR GREEN, "JOB SCRIPT ", ($idx + 1), "/", scalar(@jobs), "\n", RESET if @jobs > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | say $jobs[$idx]->script(); | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } elsif ($run) { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my @submitted = map { $_->jobid } @jobs; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | say STDERR GREEN, "Jobs submitted: ", join(",", @submitted), RESET; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub usage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | say STDERR <<END; | |||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | Options: | ||||||||||||||||||||||||||||||||||||||||||
| 323 | -n, --name Job name [optional] | ||||||||||||||||||||||||||||||||||||||||||
| 324 | -q, --queue Queue name [default: nbi-short] | ||||||||||||||||||||||||||||||||||||||||||
| 325 | -m, --memory Memory to use [default: 8Gb] | ||||||||||||||||||||||||||||||||||||||||||
| 326 | -c, --cores Number of threads [default: 1] | ||||||||||||||||||||||||||||||||||||||||||
| 327 | -T, --time Time string [default: "0d 8h"] | ||||||||||||||||||||||||||||||||||||||||||
| 328 | --after INT Job ID to wait for [can be used multiple times] | ||||||||||||||||||||||||||||||||||||||||||
| 329 | -w, --tmpdir Temporary directory [default: /tmp] | ||||||||||||||||||||||||||||||||||||||||||
| 330 | -r, --run Run the job (otherwise, just print the script) | ||||||||||||||||||||||||||||||||||||||||||
| 331 | -f, --files Input files for array (either specify -f as many times as needed or | ||||||||||||||||||||||||||||||||||||||||||
| 332 | use a _quoted_ pattern like "*.fasta" to include multiple files) | ||||||||||||||||||||||||||||||||||||||||||
| 333 | -p, --params-array | ||||||||||||||||||||||||||||||||||||||||||
| 334 | TSV file for array jobs; refer to columns as ##1##, ##2##, ... | ||||||||||||||||||||||||||||||||||||||||||
| 335 | Mutually exclusive with --files | ||||||||||||||||||||||||||||||||||||||||||
| 336 | --placeholder Placeholder for array input files [default: #FILE#] | ||||||||||||||||||||||||||||||||||||||||||
| 337 | Ignored when --params-array is used | ||||||||||||||||||||||||||||||||||||||||||
| 338 | --gpu Request GPU resources (adds --gres=gpu:1) | ||||||||||||||||||||||||||||||||||||||||||
| 339 | --option VALUE Additional SLURM options (can be used multiple times) | ||||||||||||||||||||||||||||||||||||||||||
| 340 | --eco Schedule job in next low-energy window (overrides eco_default=0) | ||||||||||||||||||||||||||||||||||||||||||
| 341 | --no-eco Submit immediately, ignoring eco scheduling (overrides eco_default=1) | ||||||||||||||||||||||||||||||||||||||||||
| 342 | --verbose Verbose output | ||||||||||||||||||||||||||||||||||||||||||
| 343 | --help This help message | ||||||||||||||||||||||||||||||||||||||||||
| 344 | ---------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 345 | END | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | exit() if ($_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | ▶ | sub autoname { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autoname: called CC=6 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | my @parts = split(/\s+/, $string); | |||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | my @ints = ("bash", "perl", "python", "python3", "R", "Rscript", "sh", "zsh"); | |||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | my @subs = ("bwa", "samtools", "seqfu", "seqkit", "bedtools", "taxonkit", "kmcp", "seqtk", "usearch", "vsearch"); | |||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # From each @parts, replace it with the first [A-Za-z0-9]+ part | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | for my $i (0..$#parts) { | |||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | $parts[$i] =~ /^([A-Za-z0-9]+)/; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 4 | $parts[$i] = $1; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | # check if $fisrt is part of the @int array of strings | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | ▶ | if (grep {$_ eq $parts[0]} @ints and defined $parts[1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
grep {$_ eq $parts[0];} @ints and defined $parts[1]
MC/DC0%0/2
grep {$_ eq $parts[0];} @ints and defined $parts[1]
grep {$_ eq $parts[0];} @ints
defined $parts[1]
Truth table33%1/3
A and B
A= grep {$_ eq $parts[0];} @intsB= defined $parts[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $parts[1]; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 10 | ▶ | } elsif (grep {$_ eq $parts[0]} @subs and defined $parts[1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
grep {$_ eq $parts[0];} @subs and defined $parts[1]
MC/DC0%0/2
grep {$_ eq $parts[0];} @subs and defined $parts[1]
grep {$_ eq $parts[0];} @subs
defined $parts[1]
Truth table33%1/3
A and B
A= grep {$_ eq $parts[0];} @subsB= defined $parts[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | return $parts[0] . "-" . $parts[1]; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | return $parts[0]; | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 4 | ▶ | sub update_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_queue: called CC=4 SCAR=23.7
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | my ($queue, $time) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 374 | # If the queue has a star, it can be updated | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | ▶ | if ($queue !~ /\*/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | return $queue; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | # Get time in hours | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $mock_opt = NBI::Opts->new(-time => $time); | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $time_h = $mock_opt->hours; | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if ($time <= 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | # Replace * with short | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $queue =~ s/\*/short/g; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } elsif ($time_h <= 48) { | ||||||||||||||||||||||||||||||||||||||||||
| 386 | # Replace * with medium | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $queue =~ s/\*/medium/g; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 389 | # Replace * with long | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $queue =~ s/\*/long/g; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | return $queue; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | sub expand_pattern_to_abs_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_pattern_to_abs_paths: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my ($pattern) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | # Get the current working directory | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $current_dir = getcwd(); | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | # Expand the pattern | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | my @files = glob($pattern); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | # Convert to absolute paths | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my @abs_paths = map { File::Spec->rel2abs($_, $current_dir) } @files; | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | return @abs_paths; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 3 | ▶ | sub get_abs_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_abs_files: called CC=4 SCAR=25.3
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | my @files = @_; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | for my $file (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if (-e $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | push @abs_files, abs_path($file); | |||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 418 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my @tmpfiles = (); | |||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | push @tmpfiles, expand_pattern_to_abs_paths($file); | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if (scalar @tmpfiles) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | push @abs_files, @tmpfiles; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " $file does not exist!"; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | return @abs_files; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | ▶ | sub get_params_array_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_params_array_info: called CC=13 SCAR=27.2
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | my ($file, $command) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | ▶ | return (undef, 0) unless defined $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | ▶ | unless (-e $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " $file does not exist!"; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | my $abs_file = abs_path($file); | |||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | open(my $fh, "<", $abs_file) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " Cannot read $abs_file: $!"; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 446 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | my %placeholders; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | ▶ | while ($command =~ /##(\d+)##/g) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 5 | $placeholders{$1} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 3 | my $max_placeholder = 0; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | for my $n (keys %placeholders) { | |||||||||||||||||||||||||||||||||||||||||
| 454 | 5 | ▶ | $max_placeholder = $n if $n > $max_placeholder; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 3 | ▶ | if ($max_placeholder == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " --params-array requires placeholders like ##1## in the command"; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | my $rows = 0; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 12 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 12 | $line =~ s/\r$//; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 12 | ▶ | next if $line =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 11 | ▶ | next if $line =~ /^\s*#/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 10 | my @fields = split /\t/, $line, -1; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 10 | ▶ | if (scalar(@fields) < $max_placeholder) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | say STDERR RED, BOLD, "ERROR:", RESET, " $abs_file row ", ($rows + 1), " has ", scalar(@fields), " columns but the command requires ##$max_placeholder##"; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 9 | $rows++; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | ▶ | if ($rows == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | say STDERR RED, BOLD, "ERROR:", RESET, " $abs_file does not contain any usable TSV rows"; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 2 | return ($abs_file, $rows); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 2 | ▶ | sub build_array_chunks { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_array_chunks: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 2 | my ($total_tasks, $task_limit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | ▶ | return ([0, 0]) unless $total_tasks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 2 | ▶ | return ([0, $total_tasks]) unless defined $task_limit && $task_limit > 0 && $total_tasks > $task_limit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $task_limit and $task_limit > 0 and $total_tasks > $task_limit
defined $task_limit and $task_limit > 0
MC/DC33%1/3
defined $task_limit and $task_limit > 0 and $total_tasks > $task_limit
defined $task_limit
$task_limit > 0
$total_tasks > $task_limit
Truth table50%2/4
A and B and C
A= defined $task_limitB= $task_limit > 0C= $total_tasks > $task_limit
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | my @chunks; | |||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | ▶ | for (my $offset = 0; $offset < $total_tasks; $offset += $task_limit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 3 | my $chunk_tasks = $task_limit; | |||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | my $remaining = $total_tasks - $offset; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 3 | ▶ | $chunk_tasks = $remaining if $remaining < $chunk_tasks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 3 | push @chunks, [$offset, $chunk_tasks]; | |||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | return @chunks; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 2 | ▶ | sub get_array_task_limit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_array_task_limit: called CC=16 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | my ($config) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | ▶ | if (defined $ENV{NBI_MAX_ARRAY_SIZE} && $ENV{NBI_MAX_ARRAY_SIZE} =~ /^\d+$/ && $ENV{NBI_MAX_ARRAY_SIZE} > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $ENV{"NBI_MAX_ARRAY_SIZE"} and $ENV{"NBI_MAX_ARRAY_SIZE"} =~ /^\d+$/u and $ENV{"NBI_MAX_ARRAY_SIZE"} > 0
defined $ENV{"NBI_MAX_ARRAY_SIZE"} and $ENV{"NBI_MAX_ARRAY_SIZE"} =~ /^\d+$/u
MC/DC33%1/3
defined $ENV{"NBI_MAX_ARRAY_SIZE"} and $ENV{"NBI_MAX_ARRAY_SIZE"} =~ /^\d+$/u and $ENV{"NBI_MAX_ARRAY_SIZE"} > 0
defined $ENV{"NBI_MAX_ARRAY_SIZE"}
$ENV{"NBI_MAX_ARRAY_SIZE"} =~ /^\d+$/u
$ENV{"NBI_MAX_ARRAY_SIZE"} > 0
Truth table50%2/4
A and B and C
A= defined $ENV{"NBI_MAX_ARRAY_SIZE"}B= $ENV{"NBI_MAX_ARRAY_SIZE"} =~ /^\d+$/uC= $ENV{"NBI_MAX_ARRAY_SIZE"} > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | return $ENV{NBI_MAX_ARRAY_SIZE}; | |||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | ▶ | if (defined $config->{max_array_size} && $config->{max_array_size} =~ /^\d+$/ && $config->{max_array_size} > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $config->{"max_array_size"} and $config->{"max_array_size"} =~ /^\d+$/u and $config->{"max_array_size"} > 0
defined $config->{"max_array_size"} and $config->{"max_array_size"} =~ /^\d+$/u
MC/DC0%0/3
defined $config->{"max_array_size"} and $config->{"max_array_size"} =~ /^\d+$/u and $config->{"max_array_size"} > 0
defined $config->{"max_array_size"}
$config->{"max_array_size"} =~ /^\d+$/u
$config->{"max_array_size"} > 0
Truth table25%1/4
A and B and C
A= defined $config->{"max_array_size"}B= $config->{"max_array_size"} =~ /^\d+$/uC= $config->{"max_array_size"} > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return $config->{max_array_size}; | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | my $output = `scontrol show config 2>/dev/null`; | |||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | ▶ | return undef if $? != 0 || !$output; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$? != 0 or not $output
MC/DC0%0/2
$? != 0 or not $output
$? != 0
not $output
Truth table33%1/3
A or not(B)
A= $? != 0B= not $output
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my @limits; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | if ($output =~ /^MaxArraySize\s*=\s*(\d+)/m) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | push @limits, $1 if $1 > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | if ($output =~ /max_array_tasks=(\d+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | push @limits, $1 if $1 > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | return undef unless @limits; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $limit = shift @limits; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | for my $candidate (@limits) { | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | $limit = $candidate if $candidate < $limit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | return $limit; | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | __END__ | ||||||||||||||||||||||||||||||||||||||||||