File Coverage

blib/lib/HPC/Runner/Command/execute_array.pm
Criterion Covered Total %
statement 12 15 80.0
branch n/a
condition n/a
subroutine 4 5 80.0
pod n/a
total 16 20 80.0


line stmt bran cond sub pod time code
1             package HPC::Runner::Command::execute_array;
2              
3 1     1   2505 use MooseX::App::Command;
  1         4  
  1         17  
4 1     1   20092 use MooseX::Types::Path::Tiny qw/Path Paths AbsPath AbsFile/;
  1         5  
  1         21  
5 1     1   4952 use JSON::XS;
  1         2  
  1         76  
6 1     1   6 use Try::Tiny;
  1         2  
  1         289  
7              
8             extends 'HPC::Runner::Command';
9              
10             with 'HPC::Runner::Command::Logger::JSON';
11             with 'HPC::Runner::Command::Utils::Base';
12             with 'HPC::Runner::Command::Utils::Log';
13             with 'HPC::Runner::Command::Utils::Git';
14             with 'HPC::Runner::Command::execute_job::Utils::MCE';
15              
16             command_short_description 'Execute commands';
17             command_long_description
18             'Take the parsed files from hpcrunner.pl submit_jobs and executes the code';
19              
20             option 'batch_index_start' => (
21             is => 'rw',
22             isa => 'Num',
23             required => 1,
24             predicate => 'has_batch_index_start',
25             documentation => 'Counter to tell execute_array where to start reading in the infile'
26             );
27              
28             ## For the scheduler we get this from the environment
29             has 'task_id' => (
30             is => 'rw',
31             default => sub {
32             return
33             $ENV{'SLURM_ARRAY_TASK_ID'}
34             || $ENV{'SBATCH_ARRAY_TASK_ID'}
35             || $ENV{'PBS_ARRAYID'}
36             || $ENV{'SGE_TASK_ID'}
37             || 0;
38             },
39             required => 0,
40             );
41              
42             sub BUILD { }
43              
44             after 'BUILD' => sub {
45             my $self = shift;
46              
47             if ( !$self->task_id && !$self->infile ) {
48             $self->app_log->fatal(
49             'There is no infile and this does not seem to be an array job. Aborting mission!'
50             );
51             exit 1;
52             }
53              
54              
55             # $self->get_infile;
56             ##The Task ID is the initial value for the job array that is caught by an environmental variable
57             ##Once we get it we use the counter for both execute_job and execute_array
58             ##Except for the read_command, which uses the task_id
59             $self->counter( $self->task_id );
60              
61             $self->gen_load_plugins;
62             $self->job_load_plugins;
63              
64             # my $tar = $self->set_archive;
65             # $self->archive($tar);
66             };
67              
68             sub execute {
69 0     0     my $self = shift;
70              
71 0           $self->git_things;
72 0           $self->run_mce;
73             }
74              
75             1;