File Coverage

blib/lib/HPC/Runner/GnuParallel.pm
Criterion Covered Total %
statement 9 24 37.5
branch n/a
condition n/a
subroutine 3 5 60.0
pod n/a
total 12 29 41.3


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2              
3             package HPC::Runner::GnuParallel;
4              
5             our $VERSION = '0.06';
6              
7 1     1   22015 use DateTime;
  1         124661  
  1         42  
8 1     1   1090 use DateTime::Format::Duration;
  1         6441  
  1         51  
9              
10 1     1   1011 use Moose;
  1         634651  
  1         7  
11             extends 'HPC::Runner';
12             extends 'HPC::Runner::MCE';
13              
14             #with 'MooseX::Getopt';
15             with 'MooseX::Getopt::Usage';
16             with 'MooseX::Getopt::Usage::Role::Man';
17              
18             =encoding utf-8
19              
20             =head1 NAME
21              
22             HPC::Runner::GnuParallel - Run arbitrary bash commands using GNU parallel. Can be used on its own or as a part of HPC::Runner::Slurm.
23              
24             =head1 SYNOPSIS
25              
26              
27             package Main;
28              
29             use Moose;
30              
31             extends 'HPC::Runner::GnuParallel';
32              
33             Main->new_with_options()->go;
34              
35             1;
36              
37             Run straight as :
38              
39             cat stuff.cmd | parallelparser.pl | parallel --joblog `pwd`/runtasks.log --gnu -N 1 -q gnuparallelrunner.pl --command `echo {}` --outdir `pwd`/gnulogs/ --seq {#}
40              
41             Where stuff.cmd is a file with the commands you need run.
42              
43             Or as a part or HPC::Runner::Slurm distro.
44              
45              
46             =head1 DESCRIPTION
47              
48             HPC::Runner::GnuParallel is a part of a suite of tools to make HPC easy.
49              
50             =head1 Attributes
51              
52             =head2 using_gnuparallel
53              
54             Indicate whether or not to use gnu parallel
55              
56             =cut
57              
58             has 'using_gnuparallel' => (
59             is => 'rw',
60             isa => 'Bool',
61             default => 1,
62             required => 0,
63             );
64              
65             =head2 infile
66              
67             disable infile and read directly from the stream
68              
69             =cut
70              
71             has '+infile' => (
72             required => 0,
73             );
74              
75             has 'command' => (
76             required => 1,
77             isa => 'Str',
78             is => 'rw',
79             );
80              
81              
82             has 'seq' => (
83             is => 'rw',
84             isa => 'Int',
85             default => 1,
86             );
87              
88             =head2 go
89              
90             Initialize MCE things and use HPC::Runner to parse and exec commands
91              
92             =cut
93              
94             sub go{
95 0     0     my $self = shift;
96              
97 0           my $dt1 = DateTime->now();
98              
99 0           $self->logname('gnuparallel');
100              
101             # $self->prepend_logfile("MAIN_");
102             # $self->log($self->init_log);
103              
104 0           $self->parse_file_gnuparallel;
105              
106 0           $DB::single=2;
107              
108 0           my $dt2 = DateTime->now();
109 0           my $duration = $dt2 - $dt1;
110 0           my $format = DateTime::Format::Duration->new(
111             pattern => '%Y years, %m months, %e days, %H hours, %M minutes, %S seconds'
112             );
113              
114             # $self->log->info("Total execution time ".$format->format_duration($duration));
115 0           return;
116             }
117              
118             =head2 parse_file_gnuparallel
119              
120             Parse the file of commands and send each command off to the queue.
121              
122             =cut
123              
124             sub parse_file_gnuparallel{
125 0     0     my $self = shift;
126              
127 0           $self->cmd($self->command);
128              
129 0           $DB::single=2;
130              
131 0           $self->counter($self->seq);
132 0           $self->run_command_mce;
133 0           $self->clear_cmd;
134             }
135              
136              
137             1;
138              
139             __END__
140              
141              
142             =head1 Acknowledgements
143              
144             Before version 0.05
145              
146             This module was originally developed at and for Weill Cornell Medical
147             College in Qatar within ITS Advanced Computing Team. With approval from
148             WCMC-Q, this information was generalized and put on github, for which
149             the authors would like to express their gratitude.
150              
151             As of version 0.05:
152              
153             This modules continuing development is supported by NYU Abu Dhabi in the Center for Genomics and Systems Biology.
154             With approval from NYUAD, this information was generalized and put on bitbucket, for which
155             the authors would like to express their gratitude.
156              
157             =head1 AUTHOR
158              
159             Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt>
160              
161             =head1 COPYRIGHT
162              
163             Copyright 2015- Weill Cornell Medical College in Qatar
164              
165             =head1 LICENSE
166              
167             This library is free software; you can redistribute it and/or modify
168             it under the same terms as Perl itself.
169              
170             =head1 SEE ALSO
171              
172             =cut