line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::Utils::Base; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
660033
|
use Cwd; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
392
|
|
4
|
1
|
|
|
1
|
|
12
|
use File::Path qw(make_path remove_tree); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
84
|
|
5
|
1
|
|
|
1
|
|
474
|
use List::Uniq ':all'; |
|
1
|
|
|
|
|
862
|
|
|
1
|
|
|
|
|
170
|
|
6
|
1
|
|
|
1
|
|
10
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
10
|
use MooseX::App::Role; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
15
|
|
9
|
1
|
|
|
1
|
|
13408
|
use MooseX::Types::Path::Tiny qw/Path Paths AbsPath AbsFile/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 HPC::Runner::Command::Utils::Base |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Base class for HPC::Runner::Command libraries. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This is a Moose Role. To use in any another applications or plugins call as |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package MyApp; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Moose; |
20
|
|
|
|
|
|
|
with 'HPC::Runner::Command::Utils::Base'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 Command Line Options |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head3 infile |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
File of commands separated by newline. The command 'wait' indicates all previous commands should finish before starting the next one. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
option 'infile' => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
documentation => |
35
|
|
|
|
|
|
|
q{File of commands separated by newline. The command 'wait' indicates all previous commands should finish before starting the next one.}, |
36
|
|
|
|
|
|
|
isa => AbsFile, |
37
|
|
|
|
|
|
|
coerce => 1, |
38
|
|
|
|
|
|
|
cmd_aliases => ['i'], |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head3 outdir |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Directory to write out files and optionally, logs. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
option 'outdir' => ( |
48
|
|
|
|
|
|
|
is => 'rw', |
49
|
|
|
|
|
|
|
isa => AbsPath, |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
coerce => 1, |
52
|
|
|
|
|
|
|
required => 1, |
53
|
|
|
|
|
|
|
default => \&set_outdir, |
54
|
|
|
|
|
|
|
documentation => q{Directory to write out files.}, |
55
|
|
|
|
|
|
|
trigger => \&_make_the_dirs, |
56
|
|
|
|
|
|
|
predicate => 'has_outdir', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#These two should both be in execute_jobs |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 procs |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Total number of concurrent running tasks. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Analagous to parallel --jobs i |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
option 'procs' => ( |
70
|
|
|
|
|
|
|
is => 'rw', |
71
|
|
|
|
|
|
|
isa => 'Int', |
72
|
|
|
|
|
|
|
default => 1, |
73
|
|
|
|
|
|
|
required => 0, |
74
|
|
|
|
|
|
|
documentation => |
75
|
|
|
|
|
|
|
q{Total number of concurrently running jobs allowed at any time.} |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
option 'poll_time' => ( |
79
|
|
|
|
|
|
|
is => 'rw', |
80
|
|
|
|
|
|
|
isa => 'Num', |
81
|
|
|
|
|
|
|
documentation => |
82
|
|
|
|
|
|
|
'Time in seconds to poll the process for memory profiling.', |
83
|
|
|
|
|
|
|
default => 5, |
84
|
|
|
|
|
|
|
cmd_aliases => ['pt'], |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
option 'memory_diff' => ( |
88
|
|
|
|
|
|
|
is => 'rw', |
89
|
|
|
|
|
|
|
isa => 'Num', |
90
|
|
|
|
|
|
|
documentation => 'Difference from last memory profile in order to record.', |
91
|
|
|
|
|
|
|
default => 0.10, |
92
|
|
|
|
|
|
|
cmd_aliases => ['md'], |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 Attributes |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has 'cmd' => ( |
100
|
|
|
|
|
|
|
traits => ['String'], |
101
|
|
|
|
|
|
|
is => 'rw', |
102
|
|
|
|
|
|
|
isa => 'Str', |
103
|
|
|
|
|
|
|
required => 0, |
104
|
|
|
|
|
|
|
handles => { |
105
|
|
|
|
|
|
|
add_cmd => 'append', |
106
|
|
|
|
|
|
|
match_cmd => 'match', |
107
|
|
|
|
|
|
|
}, |
108
|
|
|
|
|
|
|
predicate => 'has_cmd', |
109
|
|
|
|
|
|
|
clearer => 'clear_cmd', |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head3 set_outdir |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Internal variable |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
##Why is this different from set logdir? |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub set_outdir { |
121
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
0
|
if ( $self->has_outdir ) { |
124
|
0
|
|
|
|
|
0
|
$self->_make_the_dirs( $self->outdir ); |
125
|
0
|
|
|
|
|
0
|
return; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
my $outdir; |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
0
|
|
|
0
|
if ( $self->has_version && $self->has_git ) { |
131
|
0
|
0
|
|
|
|
0
|
if ( $self->has_project ) { |
132
|
0
|
|
|
|
|
0
|
$outdir = |
133
|
|
|
|
|
|
|
File::Spec->catdir( 'hpc-runner', $self->project, $self->version, |
134
|
|
|
|
|
|
|
'scratch' ); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
0
|
|
|
|
|
0
|
$outdir = |
138
|
|
|
|
|
|
|
File::Spec->catdir( 'hpc-runner', $self->version, 'scratch' ); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
else { |
142
|
0
|
0
|
|
|
|
0
|
if ( $self->has_project ) { |
143
|
0
|
|
|
|
|
0
|
$outdir = |
144
|
|
|
|
|
|
|
File::Spec->catdir( 'hpc-runner', $self->project, 'scratch' ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
else { |
147
|
0
|
|
|
|
|
0
|
$outdir = File::Spec->catdir( 'hpc-runner', 'scratch' ); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
0
|
$self->_make_the_dirs($outdir); |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
0
|
return $outdir; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head3 make_the_dirs |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Make any necessary directories |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _make_the_dirs { |
163
|
4
|
|
|
4
|
|
66
|
my ( $self, $outdir ) = @_; |
164
|
|
|
|
|
|
|
|
165
|
4
|
100
|
|
|
|
747
|
make_path($outdir) unless -d $outdir; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head3 datetime_now |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub datetime_now { |
173
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my $dt = DateTime->now( time_zone => 'local' ); |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my $ymd = $dt->ymd(); |
178
|
0
|
|
|
|
|
|
my $hms = $dt->hms(); |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return ( $dt, $ymd, $hms ); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head3 git_things |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Get git versions, branch, and tags |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub git_things { |
190
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
$self->init_git; |
193
|
0
|
|
|
|
|
|
$self->dirty_run; |
194
|
0
|
|
|
|
|
|
$self->git_info; |
195
|
|
|
|
|
|
|
|
196
|
0
|
0
|
|
|
|
|
return unless $self->has_git; |
197
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
|
return unless $self->has_version; |
199
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
if ( $self->tags ) { |
201
|
0
|
0
|
|
|
|
|
push( @{ $self->tags }, "$self->{version}" ) if $self->has_version; |
|
0
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
else { |
204
|
0
|
|
|
|
|
|
$self->tags( [ $self->version ] ); |
205
|
|
|
|
|
|
|
} |
206
|
0
|
|
|
|
|
|
my @tmp = uniq( @{ $self->tags } ); |
|
0
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
$self->tags( \@tmp ); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
1; |