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.04';
6              
7 1     1   25870 use DateTime;
  1         128628  
  1         40  
8 1     1   655 use DateTime::Format::Duration;
  1         4828  
  1         66  
9              
10 1     1   617 use Moose;
  1         453649  
  1         10  
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/
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             =head2 go
83              
84             Initialize MCE things and use Runner::Init to parse and exec commands
85              
86             =cut
87              
88             sub go{
89 0     0     my $self = shift;
90              
91 0           my $dt1 = DateTime->now();
92              
93 0           $self->logname('gnuparallel');
94              
95             # $self->prepend_logfile("MAIN_");
96             # $self->log($self->init_log);
97              
98 0           $self->parse_file_gnuparallel;
99              
100 0           $DB::single=2;
101              
102 0           my $dt2 = DateTime->now();
103 0           my $duration = $dt2 - $dt1;
104 0           my $format = DateTime::Format::Duration->new(
105             pattern => '%Y years, %m months, %e days, %H hours, %M minutes, %S seconds'
106             );
107              
108             # $self->log->info("Total execution time ".$format->format_duration($duration));
109 0           return;
110             }
111              
112             =head2 parse_file_gnuparallel
113              
114             Parse the file of commands and send each command off to the queue.
115              
116             =cut
117              
118             sub parse_file_gnuparallel{
119 0     0     my $self = shift;
120              
121 0           $self->cmd($self->command);
122              
123 0           $DB::single=2;
124              
125             # $self->log->info("Enqueuing command:\n".$self->cmd);
126 0           $self->run_command_mce;
127 0           $self->clear_cmd;
128 0           $self->inc_counter;
129             }
130              
131              
132             1;
133              
134             __END__
135              
136              
137             =head1 Acknowledgements
138              
139             This module was originally developed at and for Weill Cornell Medical
140             College in Qatar within ITS Advanced Computing Team. With approval from
141             WCMC-Q, this information was generalized and put on github, for which
142             the authors would like to express their gratitude.
143              
144             =head1 AUTHOR
145              
146             Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt>
147              
148             =head1 COPYRIGHT
149              
150             Copyright 2015- Weill Cornell Medical College in Qatar
151              
152             =head1 LICENSE
153              
154             This library is free software; you can redistribute it and/or modify
155             it under the same terms as Perl itself.
156              
157             =head1 SEE ALSO
158              
159             =cut