| 1 | package TaskPipe::Task; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 40 | our $VERSION = 0.06; | |||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use Module::Runtime qw(require_module); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use Encode qw(encode); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 40 | ▶ | use Digest::MD5 qw(md5_base64); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 40 | ▶ | use Log::Log4perl; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 40 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 40 | ▶ | use TaskPipe::Task::Settings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 40 | ▶ | use TaskPipe::Task::ModuleMap; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 40 | ▶ | use MooseX::ClassAttribute; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 40 | ▶ | use TaskPipe::InterpParam; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 40 | ▶ | use TaskPipe::LoggerManager; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 40 | ▶ | use TaskPipe::ThreadManager; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 40 | ▶ | use TaskPipe::Iterator_Array; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 40 | ▶ | use TaskPipe::RunInfo; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 40 | ▶ | use TaskPipe::TaskUtils; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 40 | ▶ | use TryCatch; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 40 | ▶ | use Clone 'clone'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 40 | with 'MooseX::ConfigCascade'; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | has sm => (is => 'rw', isa => 'TaskPipe::SchemaManager', default => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my $sm = TaskPipe::SchemaManager->new( scope => 'project' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $sm->connect_schema; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return $sm; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | has gm => (is => 'rw', isa => 'TaskPipe::SchemaManager', default => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $gm = TaskPipe::SchemaManager->new( scope => 'global' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $gm->connect_schema; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $gm; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | has run_info => (is => 'ro', isa => 'TaskPipe::RunInfo', default => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 319 | ▶ | TaskPipe::RunInfo->new; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 320 | ▶ | has settings => (is => 'ro', isa => 'TaskPipe::Task::Settings', default => sub{ TaskPipe::Task::Settings->new }); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | has utils => (is => 'ro', isa => 'TaskPipe::TaskUtils', lazy => 1, default => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 315 | ▶ | TaskPipe::TaskUtils->new( | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | sm => $_[0]->sm, | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | gm => $_[0]->gm | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 40 | has plan => (is => 'rw', isa => 'ArrayRef|HashRef'); | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 40 | has plan_dd => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 40 | has plan_md5 => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 40 | has plan_key => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 320 | ▶ | has input => (is => 'rw', isa => 'HashRef', default => sub{{}}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 40 | has input_dd => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 40 | has input_md5 => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 40 | has input_id => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 40 | has input_key => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 320 | ▶ | has input_history => (is => 'rw', isa => 'ArrayRef', default => sub{[]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 320 | ▶ | has param => (is => 'rw', isa => 'HashRef', default => sub{{}}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 40 | has param_dd => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | #has param_md5 => (is => 'rw', isa => 'Str'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 320 | ▶ | has param_history => (is => 'rw', isa => 'ArrayRef', default => sub{[]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 40 | has branch_id => (is => 'rw', isa => 'Str', default => '1-0' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 320 | ▶ | has xbranch_ids => (is => 'rw', isa => 'ArrayRef', default => sub{[]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 320 | ▶ | has pinterp => (is => 'rw', isa => 'HashRef', default => sub{{}}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 40 | has pinterp_dd => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 40 | has pinterp_md5 => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 40 | has results => (is => 'rw', isa => 'ArrayRef'); | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 40 | has results_pointer => (is => 'rw', isa => 'Int', default => 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | has thread_manager => (is => 'rw', isa => 'TaskPipe::ThreadManager', lazy => 1, default => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 315 | ▶ | TaskPipe::ThreadManager->new( | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | gm => $_[0]->gm, | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | sm => $_[0]->sm, | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | utils => $_[0]->utils, | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | logger_manager => $_[0]->logger_manager | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | has logger_manager => (is => 'ro', isa => 'TaskPipe::LoggerManager', default => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 320 | ▶ | TaskPipe::LoggerManager->new; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 40 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ####### Attributes related to testing ############# | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 40 | has test_label => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | isa => 'Str' | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | has test_pinterp => ( # override to make | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | is => 'ro', # task testable | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | isa => 'ArrayRef[HashRef]', # | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 320 | ▶ | default => sub{[{}]} # | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 40 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | has test_settings => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | isa => __PACKAGE__.'::TestSettings', | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $module = __PACKAGE__.'::TestSettings'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | require_module( $module ); | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $module->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 40 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | ################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub name{ my ($n) = ref($_[0]) =~ /^${\__PACKAGE__}_(\w+)$/; $n; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | sub test{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $output = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | foreach my $test_pinterp ( @{$self->test_data} ){ | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->pinterp( $test_pinterp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $results = $self->action; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $self->results( $results ) if $results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $output.= "\n\n" if $output; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $output.= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $output.= "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $output.= "\nTesting ".ref($self).":\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $output.= "Test Pinterp: ".Dumper( $test_pinterp )."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $max = $self->settings->test_result_limit; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | for my $i (1..$max){ | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $result = $self->next_result; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | last unless $result; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $output .= "RESULT $i:\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $output .= Dumper( $result )."\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $output.= $self->add_test_output if $self->can('add_test_output'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $output.= "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $logger->info( $output ); | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | sub test_data{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_data: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $pinterp = $self->test_pinterp; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ( ! $pinterp ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $logger->warn("No test_pinterp defined. Assuming this task does not need it"); | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return [{}]; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( ! @$pinterp ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $logger->warn("test_pinterp defined but empty. Attempting to proceed without test data"); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return [{}] | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ( ref $pinterp eq ref [] ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if ( $self->test_label ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | confess "test data is labelled by numeric index, but label supplied (".$self->test_label.") was not numeric" unless $self->test_label =~ /^\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $di = $pinterp->[ $self->test_label ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | confess "No data found at test index ".$self->test_label unless defined $di; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return [ $di ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return $pinterp; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } elsif( ref $pinterp eq ref {} ){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( $self->test_label ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $di = $pinterp->{ $self->test_label }; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | confess "Could not find a test named ".$self->test_label unless defined $di; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return [ $di ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return +values %$pinterp; | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub execute{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 315 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 315 | ▶ | if ( $self->is_manager ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 315 | $self->execute_as_manager; | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->execute_as_task; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | sub set_input_md5{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_input_md5: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $full = [ $self->input, @{$self->input_history} ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $serialized = $self->utils->serialize( $full ); | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->input_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->input_md5( md5_base64( encode("utf8",$serialized) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | sub set_param_md5{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_param_md5: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $full = [ $self->param, @{$self->param_history} ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $serialized = $self->utils->serialize( $full ); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->param_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | sub set_plan_md5{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_plan_md5: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $serialized = $self->utils->serialize( $self->plan ); | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $self->plan_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->plan_md5( md5_base64( encode("utf8",$serialized) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | sub seen_xbranch{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seen_xbranch: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $parent_xbranch_id = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $parent_xbranch_id = $self->xbranch_ids->[0] if defined $self->xbranch_ids->[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $xbranch; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | my $input_key; | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $plan_key; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ( $self->settings->xbranch_key_mode eq 'md5' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->set_input_md5; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $self->set_plan_md5; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $input_key = $self->input_md5; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $plan_key = $self->plan_md5; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $input_key = $self->input_id, | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | $plan_key = $self->branch_id | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $logger->trace("Recording plan_key $plan_key input_key $input_key"); | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | #$self->show_xbranches("before find_or_create"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | eval{ | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $xbranch = $self->sm->table('xbranch')->find_or_create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | plan_key => $plan_key, | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | input_key => $input_key, | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | #param_md5 => $self->param_md5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | branch_id => $self->branch_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | input_id => $self->input_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | parent_id => $parent_xbranch_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | plan_dd => $self->plan_dd, | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | input_dd => $self->input_dd, | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | param_dd => $self->param_dd, | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | thread_id => $self->run_info->thread_id | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | {key => 'plan_key'}); | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # if ($@ && $@ =~ /duplicate\sentry/i){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # die "duplicate entry: $@"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } while ($@); | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # } while ($@ && $@ =~ /duplicate\sentry/i); | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | confess $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | unshift @{$self->xbranch_ids}, $xbranch->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $seen = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if ( $xbranch->status && $xbranch->status eq 'seen' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xbranch->status and $xbranch->status eq "seen"
MC/DC0%0/2
$xbranch->status and $xbranch->status eq "seen"
$xbranch->status
$xbranch->status eq "seen"
Truth table0%0/3
A and B
A= $xbranch->statusB= $xbranch->status eq "seen"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $seen = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return $seen; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ############################# TEST ###################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | sub show_xbranches{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | my ($self,$msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_xbranches: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $xbrancheschk = $self->sm->table('xbranch')->search({}); | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $chk = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | while( my $xbranchchk = $xbrancheschk->next ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $chk.=$self->utils->serialize( { $xbranchchk->get_columns })."\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $logger->trace("xbranches $msg:\n$chk"); | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ######################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub clear_xbranch_error{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_xbranch_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->sm->table('xbranch_error')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | xbranch_id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | })->delete_all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | sub execute_as_task{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_as_task: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $self->run_info->task_name( $self->name ); | |||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->run_info->task_details(''); | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $self->logger_manager->init_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $logger->trace("Starting execute_as_task subroutine"); | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # if ( $self->seen_xbranch ){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # $logger->info("Already seen xbranch ".$self->xbranch_ids->[0]." - skipping"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # $logger->trace("After seen_xbranch check"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $self->clear_xbranch_error; | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my %to_interp = %{$self->param}; | |||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | foreach my $key (keys %to_interp){ | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | delete $to_interp{$key} if $key =~ /^\_/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $interp = TaskPipe::InterpParam->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | input => $self->input, | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | input_history => $self->input_history, | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | param => $self->param, | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | param_history => $self->param_history | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $logger->trace("After interp"); | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $self->pinterp( $interp->interp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # my $results; | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # my $from_cache = 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # my $should_cache = $self->settings->cache_results; | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # if ( $should_cache ){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # $results = $self->get_cached_results; | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # $from_cache = 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | #my $results; | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $results = $self->get_cached_xresults; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $logger->trace("Before action"); | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $logger->debug("Plan: ".Dumper( $self->plan )); | |||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $from_cache = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ( $results ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $logger->debug("Results (from cache): ".Dumper( $results )); | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $from_cache = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $results = $self->action; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $logger->debug("Results (from actioning): ".Dumper( $results )); | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | $self->results( $results ) if $results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | #$self->cache_results if $should_cache && ! $from_cache && $self->results; | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $self->cache_xresults if $results && ! $from_cache; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$results and not $from_cache
MC/DC0%0/2
$results and not $from_cache
$results
not $from_cache
Truth table0%0/3
A and not(B)
A= $resultsB= not $from_cache
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | #$logger->debug("After cache_results"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $to_pipe = $self->get_plan_to_pipe; | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $self->pipe_to( $to_pipe ) if $to_pipe; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if ( $self->xbranch_has_error ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $self->set_xbranch_status( 'errors were encountered on xbranch' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | } #else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # $self->mark_seen; # if ! $from_cache; | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | #$self->show_xbranches("at end of task"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $logger->trace("Ending task"); | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | Log::Log4perl->remove_logger( $logger ); | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | sub get_cached_results{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cached_results: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $serialized = $self->utils->serialize( $self->pinterp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->pinterp_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $self->pinterp_md5( md5_base64( encode("utf8",$serialized ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $cached = $self->sm->table('pinterp')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 443 | task_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | pinterp_md5 => $self->pinterp_md5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | })->first; | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $results; | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | if ( $cached ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $results_rs = $self->sm->table('result')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | pinterp_id => $cached->id | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ( $results_rs ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $results = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | while( my $serialized = $results_rs->next ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | push @$results, +$self->utils->deserialize( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $logger->debug("Got cached results - pinterp id ".$cached->id); | |||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $logger->debug("Pinterp not cached"); | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | return $results; | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | sub cache_results{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | #my ($self,$results) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_results: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $results = $self->all_results; | |||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my $serialized = $self->utils->serialize( $self->pinterp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->pinterp_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $self->pinterp_md5( md5_base64( encode("utf8",$serialized ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $guard = $self->sm->schema->txn_scope_guard; | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $pinterp = $self->sm->table('pinterp')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 483 | task_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 484 | pinterp_md5 => $self->pinterp_md5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | pinterp_dd => $self->pinterp_dd | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | foreach my $result (@$results){ | |||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $self->sm->table('result')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 491 | pinterp_id => $pinterp->id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 492 | result => +$self->utils->serialize( $result ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $guard->commit; | |||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | sub cache_xresults{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_xresults: not called CC=7 SCAR=38.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if ( @{$self->results} ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 40 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=4.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $self->sm->table('xresult')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | xbranch_id => +$self->xbranch_ids->[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 508 | thread_id => +$self->run_info->thread_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | result => +$self->utils->serialize( $self->results->[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 40 | ▶ | } catch ( DBIx::Error $err where { $_->state =~ /^23/ }){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=5.9
Branch: 2 branches
Condition0%0/3
"TryCatch"->check_tc("DBIx::Error") and do {
MC/DC0%0/2
"TryCatch"->check_tc("DBIx::Error") and do {
local $_ = $TryCatch::Error;
$_->state =~ /^23/
}
"TryCatch"->check_tc("DBIx::Error")
do {
local $_ = $TryCatch::Error;
$_->state =~ /^23/
}
Truth table0%0/3
A and B
A= "TryCatch"->check_tc("DBIx::Error")B= do {
local $_ = $TryCatch::Error;
$_->state =~ /^23/
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $parent_xbranch_id = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | $parent_xbranch_id = $self->xbranch_ids->[1] if @{$self->xbranch_ids} > 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $self->sm->table('xbranch')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 518 | id => +$self->xbranch_ids->[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 519 | plan_key => +$self->plan_key, | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | input_key => +$self->input_key, | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | thread_id => +$self->run_info->thread_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | branch_id => +$self->branch_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 523 | input_id => +$self->input_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | parent_id => $parent_xbranch_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 525 | status => undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $self->sm->table('xresult')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | xbranch_id => +$self->xbranch_ids->[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | thread_id => +$self->run_info->thread_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | result => +$self->utils->serialize( $self->results->[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 532 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | for my $i (1..$#{$self->results}){ | |||||||||||||||||||||||||||||||||||||||||||||
| 537 | # foreach my $result (@{$self->results}){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $result = $self->results->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $self->sm->table('xresult')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 541 | xbranch_id => +$self->xbranch_ids->[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | thread_id => +$self->run_info->thread_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | result => +$self->utils->serialize( $result ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | sub get_cached_xresults{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cached_xresults: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $results_rs = $self->sm->table('xresult')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | xbranch_id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my $results = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | while( my $result_row = $results_rs->next ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | push @$results, +$self->utils->deserialize( $result_row->result ); | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | return undef unless @$results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | return $results; | |||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||
| 568 | #sub delete_cached_xresults{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # my $results_rs = $self->sm->table('xresult')->search({ | ||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # xbranch_id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # $results_rs->delete_all if $results_rs; | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | #} | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||
| 582 | sub get_plan_to_pipe{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_plan_to_pipe: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $to_pipe; | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | if ( $self->settings->plan_mode eq 'tree' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $orig_pipe_to = $self->plan->{pipe_to}; | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | if ( $orig_pipe_to ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my $clone = clone $orig_pipe_to; | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if ( ref( $clone ) =~ /hash/i ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $to_pipe = [ $clone ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $to_pipe = $clone; | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $clone = clone $self->plan; | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | shift @$clone; | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | $to_pipe = [ $clone ] if @$clone; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | return $to_pipe; | |||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | sub execute_as_manager{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 315 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_as_manager: called CC=10 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 315 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | 315 | $logger->debug( "Executing as manager"); | |||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 315 | ▶ | confess "Cannot execute: No plan to execute was provided" unless defined $self->plan; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 315 | ▶ | if ( $self->settings->plan_mode eq 'branch' && ref($self->plan) eq ref {} ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->settings->plan_mode eq "branch" and ref $self->plan eq ref {}
MC/DC0%0/2
$self->settings->plan_mode eq "branch" and ref $self->plan eq ref {}
$self->settings->plan_mode eq "branch"
ref $self->plan eq ref {}
Truth table66%2/3
A and B
A= $self->settings->plan_mode eq "branch"B= ref $self->plan eq ref {}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | confess "B<You have set> C<plan_mode=branch> B<but you appear to be attempting to pass a hash to ".__PACKAGE__." (ie it looks like your plan is in> C<tree> B<format.) Either you need to change> C<plan_mode> to C<tree>B<, or you may have a syntax error in your plan>"; | |||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | confess "Cannot execute: Plan is empty" if ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 5 | ▶ | $self->settings->plan_mode eq 'tree' && ! %{$self->plan} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->settings->plan_mode eq "branch" and not @{$self->plan;}
MC/DC0%0/2
$self->settings->plan_mode eq "branch" and not @{$self->plan;}
$self->settings->plan_mode eq "branch"
not @{$self->plan;}
Truth table66%2/3
A and not(B)
A= $self->settings->plan_mode eq "branch"B= not @{$self->plan;}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 315 | ▶ | || $self->settings->plan_mode eq 'branch' && ! @{$self->plan} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->settings->plan_mode eq "tree" and not %{$self->plan;} or $self->settings->plan_mode eq "branch" and not @{$self->plan;}
$self->settings->plan_mode eq "tree" and not %{$self->plan;}
MC/DC0%0/3
$self->settings->plan_mode eq "tree" and not %{$self->plan;} or $self->settings->plan_mode eq "branch" and not @{$self->plan;}
$self->settings->plan_mode eq "tree"
not %{$self->plan;}
$self->settings->plan_mode eq "branch" and not @{$self->plan;}
Truth table20%1/5
A and not(B) or C
A= $self->settings->plan_mode eq "tree"B= not %{$self->plan;}C= $self->settings->plan_mode eq "branch" and not @{$self->plan;}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 622 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 315 | my $status = $self->thread_manager->init; | |||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 315 | ▶ | if ( $status eq 'stop' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 77 | $logger->warn("It looks like a previous completed run exists for this project, so I won't continue. If you want to start a fresh run, you should first clear the cache tables (type \"help clear tables\")"); | |||||||||||||||||||||||||||||||||||||||||||||
| 628 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 238 | ▶ | if ( $status eq 'start' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 121 | my $plan = clone +$self->plan; | |||||||||||||||||||||||||||||||||||||||||||||
| 632 | 121 | my $data = $self->prep_child_task_data( $plan, {},0, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 633 | 121 | $self->thread_manager->execute( $data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 238 | $self->thread_manager->manage; | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 639 | #$self->show_xbranches("at very end"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 290 | $logger->info("Manager: Finished run"); | |||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | sub get_cached_pinterp{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cached_pinterp: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $serialized = $self->utils->serialize( $self->pinterp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $self->pinterp_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $self->pinterp_md5( md5_base64( encode("utf8",$serialized ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $cached = $self->sm->table('pinterp')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | task_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | pinterp_md5 => $self->pinterp_md5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | })->first; | ||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | if ( ! $cached ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $logger->debug( "pinterp is not cached"); | |||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $self->cached_pinterp( undef ); | |||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if ( ! $cached->status || $cached->status ne 'fully-cached'){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $cached->status or $cached->status ne "fully-cached"
MC/DC0%0/2
not $cached->status or $cached->status ne "fully-cached"
not $cached->status
$cached->status ne "fully-cached"
Truth table0%0/3
not(A) or B
A= not $cached->statusB= $cached->status ne "fully-cached"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $self->cached_pinterp( undef ); | |||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $logger->debug( "pinterp is cached"); | |||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $self->cached_pinterp( $cached ); | |||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | sub clear_partially_cached{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | my ($self,$cached) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_partially_cached: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $guard = $self->sm->schema->txn_scope_guard; | |||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $groups = $self->sm->table('result_group')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 684 | pinterp_id => $cached->id | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | while( my $group = $groups->next ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my $results = $self->sm->table('result')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 690 | group_id => $group->id | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | })->delete_all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $groups->delete_all; | |||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $cached->delete; | |||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $guard->commit; | |||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | sub cache_pinterp{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_pinterp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | my $serialized = $self->utils->serialize( $self->pinterp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | $self->pinterp_dd( $serialized ); | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $self->pinterp_md5( md5_base64($self->pinterp_dd) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | my $cached = $self->sm->table('pinterp')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 711 | task_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | pinterp_md5 => $self->pinterp_md5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | pinterp_dd => $self->pinterp_dd, | ||||||||||||||||||||||||||||||||||||||||||||||
| 714 | status => 'partially-cached' | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | $self->cached_pinterp( $cached ); | |||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||
| 724 | sub next_result{# override in child | ||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_result: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | if ( $self->is_manager ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | return +$self->next_result_as_manager; | |||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | return +$self->next_result_as_task; | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | sub next_result_as_manager{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_result_as_manager: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my %input = %{$self->input}; | |||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $self->input({}); | |||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | return +%input?\%input:undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||
| 750 | sub next_result_as_task{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_result_as_task: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | confess "next_result called in TaskPipe::Task but ->results is not defined. Did you forget to define a next_result method in your task?" unless $self->results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | return undef if $self->results_pointer > $#{$self->results}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $result = $self->results->[ $self->results_pointer ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $self->results_pointer( $self->results_pointer + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | sub count_results{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_results: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | return -1 unless $self->results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | $logger->debug("results: ".Dumper( $self->results )) if $self->name eq 'Scrape_SearchSuggestions'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | return +scalar(@{$self->results}); | |||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||
| 778 | sub reset_results{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | my ($self,$index) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_results: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | confess "reset_results called in TaskPipe::Task but ->results is not defined. Did you forget to define a count_results method in your task?" unless $self->results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | $index ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$index ||= 0
MC/DC0%0/1
$index ||= 0
$index
Truth table0%0/2
A
A= $index
| |||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | $self->results_pointer( $index ); | |||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||
| 788 | sub is_manager{ #it's a manager if it is the root task | ||||||||||||||||||||||||||||||||||||||||||||||
| 789 | #ie it doesn't have a type, so it's class | ||||||||||||||||||||||||||||||||||||||||||||||
| 790 | #should be just 'Task' | ||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 315 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_manager: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 315 | ▶ | return ref($self) eq __PACKAGE__?1:0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | sub pipe_through{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pipe_through: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my %input = %{$self->input}; | |||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $plan = clone $self->plan; | |||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $task = $self->task_from_plan( $plan ); | |||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $task->input( \%input ); | |||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | if ( $self->settings->plan_mode eq 'tree' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | $task->param( clone $plan->{task} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 807 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | $task->param( clone $plan->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | eval{ $task->execute }; | |||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | $task->handle_error($@) if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | sub pipe_to{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | my ($self,$plan) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pipe_to: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | my $tm = $self->thread_manager; | |||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | my $ni = $self->count_results; | |||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | my ($i0, $p0, $last_result ) = $self->get_resume_info; | |||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $logger->trace("xbranch_id ".$self->xbranch_ids->[0]." plan id ".$self->branch_id." input id ".$self->input_id." Got resume info i0 $i0 p0 $p0 last_result ".Dumper($last_result)); | |||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | my $input_item; | |||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | $logger->trace("Results: ".Dumper( $self->results )); | |||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | for my $pi ($p0..$#$plan){ | |||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | $logger->trace("in loop, pi $pi"); | |||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | $self->reset_results( $i0, $last_result ); | |||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | my $ii = $i0; | |||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | while(1){ | |||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | $input_item = $self->next_result; | |||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | $logger->trace("input item: ".Dumper( $input_item )); | |||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | last unless $input_item; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | $ii++; | |||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $data = $self->prep_child_task_data( | |||||||||||||||||||||||||||||||||||||||||||||
| 851 | $plan->[$pi], | ||||||||||||||||||||||||||||||||||||||||||||||
| 852 | $input_item, | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | $ii, | ||||||||||||||||||||||||||||||||||||||||||||||
| 854 | $pi | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $tm->execute( $data ); | |||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $self->utils->record_resume_info( | |||||||||||||||||||||||||||||||||||||||||||||
| 859 | $self->xbranch_ids->[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 860 | $ii, | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | $pi, | ||||||||||||||||||||||||||||||||||||||||||||||
| 862 | $input_item | ||||||||||||||||||||||||||||||||||||||||||||||
| 863 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | $i0 = 0; # make sure to start inputs from scratch on the next plan iteration | |||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | sub get_resume_info{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_resume_info: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my $xbranch = $self->sm->table('xbranch')->find({ | |||||||||||||||||||||||||||||||||||||||||||||
| 881 | id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 882 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my $plan_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $input_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | my $last_result; | |||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | if ( $xbranch ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | $plan_index = $xbranch->last_plan_index || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$xbranch->last_plan_index || 0
MC/DC0%0/1
$xbranch->last_plan_index || 0
$xbranch->last_plan_index
Truth table0%0/2
A
A= $xbranch->last_plan_index
| |||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | $input_index = $xbranch->last_input_index || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$xbranch->last_input_index || 0
MC/DC0%0/1
$xbranch->last_input_index || 0
$xbranch->last_input_index
Truth table0%0/2
A
A= $xbranch->last_input_index
| |||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | $last_result = $xbranch->last_result || undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$xbranch->last_result || undef
MC/DC0%0/1
$xbranch->last_result || undef
$xbranch->last_result
Truth table0%0/2
A
A= $xbranch->last_result
| |||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | $last_result = $self->utils->deserialize( $last_result ) if $last_result; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||
| 896 | #$logger->debug("GOT RESUME INFO: xid ".$self->xbranch_ids->[0]." ii $input_index pi $plan_index last_result ".Dumper( $last_result ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | return ($input_index,$plan_index,$last_result); | |||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||
| 903 | #sub execute_child_task{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # my ($self,$plan,$input) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # my $logger = Log::Log4perl->get_logger; | ||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||
| 908 | # my $task = $self->task_from_plan($plan); | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||
| 910 | # $task->input($input); | ||||||||||||||||||||||||||||||||||||||||||||||
| 911 | # $self->add_history( $task ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # my $param; | ||||||||||||||||||||||||||||||||||||||||||||||
| 914 | # if ( $self->settings->plan_mode eq 'tree' ){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 915 | # $task->param( clone $plan->{task} ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 916 | # } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 917 | # $task->param( clone $plan->[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 918 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||
| 920 | # my $err; | ||||||||||||||||||||||||||||||||||||||||||||||
| 921 | # try { | ||||||||||||||||||||||||||||||||||||||||||||||
| 922 | # $task->execute; | ||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # } catch( $err ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 924 | # $task->handle_error($err); | ||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||
| 927 | # Log::Log4perl->remove_logger( $logger ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 928 | # $task->sm->schema->storage->disconnect; | ||||||||||||||||||||||||||||||||||||||||||||||
| 929 | # $task->gm->schema->storage->disconnect; | ||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | #} | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||
| 935 | sub prep_child_task_data{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 121 | ▶ | my ($self,$plan,$input,$ii,$pi) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prep_child_task_data: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 121 | my $i_current = clone $self->input; | |||||||||||||||||||||||||||||||||||||||||||||
| 939 | 121 | my $i_history = clone $self->input_history; | |||||||||||||||||||||||||||||||||||||||||||||
| 940 | 121 | unshift @$i_history, $i_current; | |||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 121 | my $p_current = clone $self->param; | |||||||||||||||||||||||||||||||||||||||||||||
| 943 | 121 | my $p_history = clone $self->param_history; | |||||||||||||||||||||||||||||||||||||||||||||
| 944 | 121 | unshift @$p_history, $p_current; | |||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 121 | my $xbranches = clone $self->xbranch_ids; | |||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 121 | my $param; | |||||||||||||||||||||||||||||||||||||||||||||
| 949 | 121 | ▶ | if ( $self->settings->plan_mode eq 'tree' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 5 | $param = clone $plan->{task}; | |||||||||||||||||||||||||||||||||||||||||||||
| 951 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 116 | $param = clone $plan->[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 121 | my ($branch_id) = $self->branch_id =~ /^(\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 956 | 121 | $branch_id++; | |||||||||||||||||||||||||||||||||||||||||||||
| 957 | 121 | $branch_id.='-'.$pi; | |||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 121 | my $input_id; | |||||||||||||||||||||||||||||||||||||||||||||
| 960 | 121 | ▶ | if ( ! $self->input_id ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 121 | $input_id = $ii; | |||||||||||||||||||||||||||||||||||||||||||||
| 962 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $input_id = $self->input_id.'-'.$ii; | |||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 121 | my $plan_key = $branch_id; | |||||||||||||||||||||||||||||||||||||||||||||
| 967 | 121 | my $input_key = $input_id; | |||||||||||||||||||||||||||||||||||||||||||||
| 968 | 121 | ▶ | if ( $self->settings->xbranch_key_mode eq 'md5' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 121 | my $full = [ $input, @$i_history ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 970 | 121 | $input_key = md5_base64( encode("utf8",+$self->utils->serialize( $full ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 971 | 121 | $plan_key = md5_base64( encode("utf8",+$self->utils->serialize( $plan ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 974 | return { | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 121 | plan_key => $plan_key, | |||||||||||||||||||||||||||||||||||||||||||||
| 976 | input_key => $input_key, | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | plan => $plan, | ||||||||||||||||||||||||||||||||||||||||||||||
| 978 | input => $input, | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | ii => $ii, | ||||||||||||||||||||||||||||||||||||||||||||||
| 980 | pi => $pi, | ||||||||||||||||||||||||||||||||||||||||||||||
| 981 | branch_id => $branch_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 982 | input_id => $input_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 983 | input_history => $i_history, | ||||||||||||||||||||||||||||||||||||||||||||||
| 984 | param_history => $p_history, | ||||||||||||||||||||||||||||||||||||||||||||||
| 985 | xbranch_ids => $xbranches, | ||||||||||||||||||||||||||||||||||||||||||||||
| 986 | param => $param, | ||||||||||||||||||||||||||||||||||||||||||||||
| 987 | plan_mode => +$self->settings->plan_mode | ||||||||||||||||||||||||||||||||||||||||||||||
| 988 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 995 | sub mark_seen{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_seen: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | my $xbranch = $self->sm->table('xbranch')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1001 | id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | my $child_xbranches = $self->sm->table('xbranch')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1004 | parent_id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | # if ( $self->branch_id !~ /^2/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | if ( $self->settings->seen_xbranch_policy eq 'skip' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | $logger->debug("Updating xbranch status to 'seen'"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | if ( $xbranch ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | $xbranch->update({ status => 'seen' }); | |||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } elsif ( $self->settings->seen_xbranch_policy eq 'delete' ){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $logger->debug("Deleting xbranch record"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | $xbranch->update({ status => 'seen' }); | |||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | while( my $child_xbranch = $child_xbranches->next ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | $self->sm->table('xresult')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1022 | xbranch_id => $child_xbranch->id | ||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | })->delete_all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $child_xbranches->delete_all; | |||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | $self->sm->table('xresult')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1027 | xbranch_id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | })->delete_all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | confess "Unrecognised seen_xbranch_policy: ".$self->settings->seen_xbranch_policy; | |||||||||||||||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | sub add_history{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | ▶ | my ($self,$task) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_history: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | my $i_current = clone $self->input; | |||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | my $i_history = clone $self->input_history; | |||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | unshift @$i_history, $i_current; | |||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | $task->input_history( $i_history ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my $p_current = clone $self->param; | |||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | my $p_history = clone $self->param_history; | |||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | unshift @$p_history, $p_current; | |||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | $task->param_history( $p_history ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my $xbranches = clone $self->xbranch_ids; | |||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $task->xbranch_ids( $xbranches ); | |||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | sub task_from_plan{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | ▶ | my ($self,$plan) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
task_from_plan: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | my $spec; | |||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | ▶ | if ( $self->settings->plan_mode eq 'tree' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $spec = $plan->{task}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | $spec = $plan->[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | my $name = $spec->{_name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | confess "No name. spec was ".Dumper($spec)." plan was ".Dumper( $plan ) unless $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | ▶ | confess "task spec should be a hash" unless $spec && ref($spec) =~ /hash/i; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$spec and ref($spec) =~ /hash/i
MC/DC0%0/2
$spec and ref($spec) =~ /hash/i
$spec
ref($spec) =~ /hash/i
Truth table0%0/3
A and B
A= $specB= ref($spec) =~ /hash/i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | my $mod_map = TaskPipe::Task::ModuleMap->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 1074 | task_name => $name | ||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | my $mod_name = $mod_map->load_module; | |||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | my $task = $mod_name->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 1080 | sm => $self->sm, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | gm => $self->gm, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | thread_manager => $self->thread_manager, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | logger_manager => $self->logger_manager, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | plan => $plan | ||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | return $task; | |||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | sub set_xbranch_status{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | ▶ | my ($self,$status) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_xbranch_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $xbranch = $self->sm->table('xbranch')->find({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1097 | id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | if ( $xbranch ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | $xbranch->update({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1102 | status => $status | ||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | sub handle_error{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | my ($self,$error_msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_error: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | $logger->error($error_msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | my $guard = $self->sm->schema->txn_scope_guard; | |||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | my $error = $self->sm->table('error')->create({ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | job_id => $self->run_info->job_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | history_index => scalar( @{$self->input_history} ), | |||||||||||||||||||||||||||||||||||||||||||||
| 1122 | tag => $self->param->{_tag}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | task_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | input_dd => Dumper( $self->input ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | param_dd => Dumper( $self->param ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | pinterp_dd => Dumper( $self->pinterp ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | xbranch_ids => join(',',@{$self->xbranch_ids}), | |||||||||||||||||||||||||||||||||||||||||||||
| 1128 | thread_id => $self->run_info->thread_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | message => $error_msg | ||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | foreach my $xbranch_id ( @{$self->xbranch_ids} ){ | |||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | $self->sm->table('xbranch_error')->create({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1135 | xbranch_id => $xbranch_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | error_id => $error->id | ||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | $guard->commit; | |||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | $self->thread_manager->stop_threads if $self->settings->on_task_error eq 'stop'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | sub xbranch_has_error{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xbranch_has_error: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | my $has_error = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | my $num_errors = $self->sm->table('xbranch_error')->search({ | |||||||||||||||||||||||||||||||||||||||||||||
| 1152 | xbranch_id => $self->xbranch_ids->[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | })->count; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | $has_error = 1 if $num_errors > 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | return $has_error; | |||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | sub action{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
action: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | confess "action in ".__PACKAGE__." should NOT be called. Override this method in child class"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | TaskPipe::Task - the class which all TaskPipe tasks should inherit from | ||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | Inherit from this class when creating new tasks. Your child task should contain an C<action> subroutine, which returns either: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | =item 1. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | An arrayref of results | ||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | =item 2. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | A L<TaskPipe::Iterator> of results. (See the L<TaskPipe::Iterator> manpage for more information | ||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | You should write your task in the following format: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | package TaskPipe::Task_MyTaskName | ||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | extends 'TaskPipe::Task'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | sub action { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | # access plan parameters in here | ||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | # via $self->param | ||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | my $some_val = $self->param->{some_param}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | # ... do something with $some_val ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | return \@results; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | __PACKAGE__->meta->make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | Then you reference it in your plan via something like: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # (in tree format): | ||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | task: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | _name: MyTaskName | ||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | some_param: 46 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | pipe_to: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | Note that if you are creating a task to scrape a website, it is recommended to inherit from L<TaskPipe::Task_Scrape> instead of inheriting from L<TaskPipe::Task> directly. See L<TaskPipe::Task_Scrape> for more information | ||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | See the other tasks that are provided to make sure you are not creating a task that exists already: | ||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | L<TaskPipe::Task_Scrape> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | L<TaskPipe::Task_Record> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | L<TaskPipe::Task_SourceFromDB> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | L<TaskPipe::Task_SourceFromFile> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | Tom Gracey <tomgracey@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | Copyright (c) Tom Gracey 2018 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | TaskPipe is free software, licensed under | ||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | The GNU Public License Version 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 40 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||||||