line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::submit_jobs::Plugin::Dummy; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1238
|
use File::Temp qw/ tempfile /; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
67
|
|
4
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
5
|
1
|
|
|
1
|
|
5
|
use IPC::Cmd qw[can_run]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
5
|
use Log::Log4perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
58
|
use File::Slurp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
110
|
|
8
|
1
|
|
|
1
|
|
6
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use Moose::Role; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
9
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 HPC::Runner::Command::submit_jobs::Plugin::Dummy; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This is just a dummy to use for testing |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
The first job is submitted as 1234, the next 1235, etc |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head3 template_file |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
actual template file |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
One is generated here for you, but you can always supply your own with --template_file /path/to/template |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#TODO add back PBS support and add SGE support |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'template_file' => ( |
31
|
|
|
|
|
|
|
is => 'rw', |
32
|
|
|
|
|
|
|
isa => 'Str', |
33
|
|
|
|
|
|
|
default => sub { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my ( $fh, $filename ) = tempfile(); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $tt = <<EOF; |
39
|
|
|
|
|
|
|
#!/bin/bash |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
#SBATCH --share |
42
|
|
|
|
|
|
|
#SBATCH --job-name=[% JOBNAME %] |
43
|
|
|
|
|
|
|
#SBATCH --output=[% OUT %] |
44
|
|
|
|
|
|
|
[% IF job.has_account %] |
45
|
|
|
|
|
|
|
#SBATCH --account=[% job.account %] |
46
|
|
|
|
|
|
|
[% END %] |
47
|
|
|
|
|
|
|
[% IF job.has_partition %] |
48
|
|
|
|
|
|
|
#SBATCH --partition=[% job.partition %] |
49
|
|
|
|
|
|
|
[% END %] |
50
|
|
|
|
|
|
|
[% IF job.has_nodes_count %] |
51
|
|
|
|
|
|
|
#SBATCH --nodes=[% job.nodes_count %] |
52
|
|
|
|
|
|
|
[% END %] |
53
|
|
|
|
|
|
|
[% IF job.has_ntasks %] |
54
|
|
|
|
|
|
|
#SBATCH --ntasks=[% job.ntasks %] |
55
|
|
|
|
|
|
|
[% END %] |
56
|
|
|
|
|
|
|
[% IF job.has_cpus_per_task %] |
57
|
|
|
|
|
|
|
#SBATCH --cpus-per-task=[% job.cpus_per_task %] |
58
|
|
|
|
|
|
|
[% END %] |
59
|
|
|
|
|
|
|
[% IF job.has_ntasks_per_node %] |
60
|
|
|
|
|
|
|
#SBATCH --ntasks-per-node=[% job.ntasks_per_node %] |
61
|
|
|
|
|
|
|
[% END %] |
62
|
|
|
|
|
|
|
[% IF job.has_mem %] |
63
|
|
|
|
|
|
|
#SBATCH --mem=[% job.mem %] |
64
|
|
|
|
|
|
|
[% END %] |
65
|
|
|
|
|
|
|
[% IF job.has_walltime %] |
66
|
|
|
|
|
|
|
#SBATCH --time=[% job.walltime %] |
67
|
|
|
|
|
|
|
[% END %] |
68
|
|
|
|
|
|
|
[% IF ARRAY_STR %] |
69
|
|
|
|
|
|
|
#SBATCH --array=[% ARRAY_STR %] |
70
|
|
|
|
|
|
|
[% END %] |
71
|
|
|
|
|
|
|
[% IF AFTEROK %] |
72
|
|
|
|
|
|
|
#SBATCH --dependency=afterok:[% AFTEROK %] |
73
|
|
|
|
|
|
|
[% END %] |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
[% IF MODULES %] |
76
|
|
|
|
|
|
|
module load [% MODULES %] |
77
|
|
|
|
|
|
|
[% END %] |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
[% IF job.has_conda_env %] |
80
|
|
|
|
|
|
|
source activate [% job.conda_env %] |
81
|
|
|
|
|
|
|
[% END %] |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
[% COMMAND %] |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
EOF |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
print $fh $tt; |
89
|
|
|
|
|
|
|
return $filename; |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
predicate => 'has_template_file', |
92
|
|
|
|
|
|
|
clearer => 'clear_template_file', |
93
|
|
|
|
|
|
|
documentation => |
94
|
|
|
|
|
|
|
q{Path to Slurm template file if you do not wish to use the default} |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 attributes |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
has 'sched_counter' => ( |
102
|
|
|
|
|
|
|
traits => ['Counter'], |
103
|
|
|
|
|
|
|
is => 'ro', |
104
|
|
|
|
|
|
|
isa => 'Num', |
105
|
|
|
|
|
|
|
required => 1, |
106
|
|
|
|
|
|
|
default => 1234, |
107
|
|
|
|
|
|
|
handles => { |
108
|
|
|
|
|
|
|
inc_sched_counter => 'inc', |
109
|
|
|
|
|
|
|
dec_sched_counter => 'dec', |
110
|
|
|
|
|
|
|
reset_sched_counter => 'reset', |
111
|
|
|
|
|
|
|
}, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 Subroutines |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head3 submit_jobs |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is a dummy for testing - just return a value as a placeholder in job_stats |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub submit_jobs { |
125
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $jobid = $self->sched_counter; |
128
|
0
|
|
|
|
|
|
$ENV{DUMMY_JOB_ID} = $jobid; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# my ( $exitcode, $stdout, $stderr ) = $self->submit_to_scheduler("echo \"sbatch ". $self->slurmfile . "\""); |
131
|
0
|
|
|
|
|
|
$self->app_log->warn( "SUBMITTING DUMMY JOB " |
132
|
|
|
|
|
|
|
. $self->slurmfile |
133
|
|
|
|
|
|
|
. "\n\tWith dummy jobid $jobid" ); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
$self->inc_sched_counter; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
return $jobid; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head3 update_job_deps |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Update the job dependencies if using job_array (not batches) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub update_job_deps { |
147
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
return unless $self->has_array_deps; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
my $array_deps_file = File::Spec->catdir( $self->logdir, 'array_deps.txt' ); |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
foreach my $current_task ( sort keys %{ $self->array_deps } ) { |
|
0
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my $v = $self->array_deps->{$current_task}; |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
my $dep_tasks = join( ':', @$v ); |
157
|
0
|
|
|
|
|
|
my $cmd = |
158
|
|
|
|
|
|
|
"scontrol update job=$current_task Dependency=afterok:$dep_tasks"; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# my ( $exitcode, $stdout, $stderr ) = $self->submit_to_scheduler('echo '.$cmd); |
161
|
0
|
|
|
|
|
|
write_file( |
162
|
|
|
|
|
|
|
$array_deps_file, |
163
|
|
|
|
|
|
|
{ append => 1 }, |
164
|
|
|
|
|
|
|
$current_task . "\t" . $dep_tasks . "\n" |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |