line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::submit_jobs::Plugin::SGE; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1066
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
4794
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
61
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
6
|
use Log::Log4perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
106
|
use File::Temp qw/ tempfile /; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
550
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'HPC::Runner::Command::submit_jobs::Plugin::Role::Log'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 HPC::Runner::Command::Plugin::Scheduler::Slurm; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'submit_command' => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => 'Str', |
19
|
|
|
|
|
|
|
default => 'qsub', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'template_file' => ( |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
isa => 'Str', |
25
|
|
|
|
|
|
|
default => sub { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my ( $fh, $filename ) = tempfile(); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $tt = <<EOF; |
31
|
|
|
|
|
|
|
#!/usr/bin/env bash |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
#$ -N [% JOBNAME %] |
34
|
|
|
|
|
|
|
#$ -S /bin/bash |
35
|
|
|
|
|
|
|
#$ -cwd |
36
|
|
|
|
|
|
|
[% IF job.has_queue %] |
37
|
|
|
|
|
|
|
#$-q [% job.queue %] |
38
|
|
|
|
|
|
|
[% END %] |
39
|
|
|
|
|
|
|
#$ -pe smp [% job.cpus_per_task %] |
40
|
|
|
|
|
|
|
[% IF job.has_walltime %] |
41
|
|
|
|
|
|
|
#$ -l h_rt=[% job.walltime %] |
42
|
|
|
|
|
|
|
[% END %] |
43
|
|
|
|
|
|
|
#$ -j y |
44
|
|
|
|
|
|
|
#$ -o [% OUT %] |
45
|
|
|
|
|
|
|
[% IF job.has_mem %] |
46
|
|
|
|
|
|
|
#$ -l mh_vem=[% job.mem %] |
47
|
|
|
|
|
|
|
[% END %] |
48
|
|
|
|
|
|
|
[% IF ARRAY_STR %] |
49
|
|
|
|
|
|
|
#$ -t=[% ARRAY_STR %] |
50
|
|
|
|
|
|
|
[% END %] |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
[% IF AFTEROK %] |
53
|
|
|
|
|
|
|
#$ -hold_jid=[% AFTEROK %] |
54
|
|
|
|
|
|
|
[% END %] |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
[% IF MODULES %] |
57
|
|
|
|
|
|
|
module load [% MODULES %] |
58
|
|
|
|
|
|
|
[% END %] |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
[% IF job.has_conda_env %] |
61
|
|
|
|
|
|
|
source activate [% job.conda_env %] |
62
|
|
|
|
|
|
|
[% END %] |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
[% COMMAND %] |
66
|
|
|
|
|
|
|
EOF |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
print $fh $tt; |
69
|
|
|
|
|
|
|
return $filename; |
70
|
|
|
|
|
|
|
}, |
71
|
|
|
|
|
|
|
predicate => 'has_template_file', |
72
|
|
|
|
|
|
|
clearer => 'clear_template_file', |
73
|
|
|
|
|
|
|
documentation => |
74
|
|
|
|
|
|
|
q{Path to Slurm template file if you do not wish to use the default} |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 Subroutines |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 submit_jobs |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Submit jobs to slurm queue using PBS. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Format is |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
"Your job <job_id> ("<job_name>") has been submitted" |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub submit_jobs { |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my ( $exitcode, $stdout, $stderr ) = |
95
|
|
|
|
|
|
|
$self->submit_to_scheduler( |
96
|
|
|
|
|
|
|
$self->submit_command . " " . $self->slurmfile ); |
97
|
0
|
|
|
|
|
|
sleep(5); |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
if ( $exitcode != 0 ) { |
100
|
0
|
|
|
|
|
|
$self->log->fatal("Job was not submitted successfully"); |
101
|
0
|
0
|
|
|
|
|
$self->log->warn( "STDERR: " . $stderr ) if $stderr; |
102
|
0
|
0
|
|
|
|
|
$self->log->warn( "STDOUT: " . $stdout ) if $stdout; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# my $jobid = $stdout; |
106
|
0
|
|
|
|
|
|
my $jobid; |
107
|
0
|
|
|
|
|
|
($jobid) = $stdout =~ m/Your job (\d.*) \(/; |
108
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if ( !$jobid ) { |
110
|
0
|
|
|
|
|
|
$self->job_failure; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
else { |
113
|
0
|
|
|
|
|
|
$self->log->debug( |
114
|
|
|
|
|
|
|
"Submited job " . $self->slurmfile . "\n\tWith SGE jobid $jobid" ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return $jobid; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head3 update_job_deps |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Update the job dependencies if using job_array (not batches) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
NOTE - Task dependencies may not be supported. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub update_job_deps { |
130
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
return unless $self->has_array_deps; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$self->log->warn('Task dependencies in SGE is still very experimental!'); |
135
|
0
|
|
|
|
|
|
$self->log->warn( 'Please raise any problems as an issue at github.' . "\n" |
136
|
|
|
|
|
|
|
. "\thttp://github.com/biosails/HPC-Runner-Command" ); |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
while ( my ( $current_task, $v ) = each %{ $self->array_deps } ) { |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
my $cmd; |
141
|
0
|
0
|
|
|
|
|
if ( $self->use_batches ) { |
142
|
0
|
|
|
|
|
|
my $dep_tasks = join( ':', @$v ); |
143
|
0
|
|
|
|
|
|
$cmd = "qalter -hold_jid \"$dep_tasks\" $current_task "; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else { |
146
|
0
|
|
|
|
|
|
foreach my $tv ( @{$v} ) { |
|
0
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my @tmp = split( '_', $tv ); |
148
|
0
|
|
|
|
|
|
$tv = $tmp[0] . '[' . $tmp[1] . ']'; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
my @tmp = split( '_', $current_task ); |
152
|
0
|
|
|
|
|
|
$current_task = $tmp[0] . '[' . $tmp[1] . ']'; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my $dep_tasks = join( ':', @$v ); |
155
|
0
|
|
|
|
|
|
$cmd = "qalter -hold_jid \"$dep_tasks\" \"$current_task\" "; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$self->submit_to_scheduler($cmd); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |