File Coverage

blib/lib/HPC/Runner/Command/execute_job/Base.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package HPC::Runner::Command::execute_job::Base;
2              
3 1     1   513 use MooseX::App::Role;
  1         2  
  1         12  
4 1     1   6398 use MooseX::Types::Path::Tiny qw/Path Paths AbsPath AbsFile/;
  1         3  
  1         10  
5              
6             with 'HPC::Runner::Command::execute_job::Utils::Plugin';
7             with 'HPC::Runner::Command::execute_job::Utils::Log';
8             with 'HPC::Runner::Command::execute_job::Logger::JSON';
9              
10 1     1   3251 use Sys::Hostname;
  1         3  
  1         52  
11 1     1   5 use Archive::Tar;
  1         1  
  1         229  
12              
13             =head2 Command Line Options
14              
15             =cut
16              
17              
18             =head2 Internal Attriutes
19              
20             =cut
21              
22             =head3 job_scheduler_id
23              
24             Job Scheduler ID running the script. Passed to slurm for mail information
25              
26             =cut
27              
28             has 'job_scheduler_id' => (
29             is => 'rw',
30             isa => 'Str|Undef',
31             default => sub {
32             my $self = shift;
33             my $scheduler_id =
34             $ENV{SLURM_ARRAY_JOB_ID}
35             || $ENV{SLURM_JOB_ID}
36             || $ENV{SBATCH_JOB_ID}
37             || $ENV{PBS_JOBID}
38             || $ENV{JOB_ID}
39             || '';
40             if ( $self->can('task_id') && $self->task_id ) {
41             $scheduler_id = $scheduler_id . '_' . $self->task_id;
42             }
43             return $scheduler_id;
44             },
45             lazy => 1,
46             documentation =>
47             q{This defaults to your current Job Scheduler ID. Ignore this if running on a single node},
48             predicate => 'has_job_scheduler_id',
49             clearer => 'clear_job_scheduler_id',
50             );
51              
52             has 'hostname' => (
53             is => 'rw',
54             isa => 'Str|Undef',
55             default => sub {
56             return hostname;
57             },
58             );
59              
60             has 'wait' => (
61             is => 'rw',
62             isa => 'Bool',
63             default => 0,
64             );
65              
66             =head3 counter
67              
68             This is task_id counter. Batch index start and/or array_id get passed in on the command line
69             But for instances where we are creating a threadpool of more than 1 task
70             The counter keeps track
71              
72             =cut
73              
74             has 'counter' => (
75             traits => ['Counter'],
76             is => 'rw',
77             isa => 'Num',
78             required => 1,
79             default => 1,
80             handles => {
81             inc_counter => 'inc',
82             dec_counter => 'dec',
83             reset_counter => 'reset',
84             },
85             );
86              
87             has 'jobref' => (
88             is => 'rw',
89             isa => 'ArrayRef',
90             default => sub { [ [] ] },
91             );
92              
93             1;