| 1 | package BioX::Workflow::Debug; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Storable qw(dclone); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | =head1 BioX::Workflow::Debug | ||||||||||
| 8 | |||||||||||
| 9 | Options for debugging. Stick your whole environment in memory, and figure out what went wrong. | ||||||||||
| 10 | |||||||||||
| 11 | =head2 Variables | ||||||||||
| 12 | |||||||||||
| 13 | =head3 save_object_env | ||||||||||
| 14 | |||||||||||
| 15 | Save object env. This will save all the variables. Useful for debugging, but gets unweildly for larger workflows. | ||||||||||
| 16 | |||||||||||
| 17 | =cut | ||||||||||
| 18 | |||||||||||
| 19 | 2 | has 'save_object_env' => ( | |||||||||
| 20 | is => 'rw', | ||||||||||
| 21 | isa => 'Bool', | ||||||||||
| 22 | default => 0, | ||||||||||
| 23 | predicate => 'has_save_object_env', | ||||||||||
| 24 | clearer => 'clear_save_object_env', | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | =head2 _classes | ||||||||||
| 28 | |||||||||||
| 29 | Saves a snapshot of the entire namespace for the initial environment, and each rule. | ||||||||||
| 30 | |||||||||||
| 31 | =cut | ||||||||||
| 32 | |||||||||||
| 33 | has '_classes' => ( | ||||||||||
| 34 | traits => ['NoGetopt'], | ||||||||||
| 35 | is => 'rw', | ||||||||||
| 36 | isa => 'HashRef', | ||||||||||
| 37 | 6 | ▶ | default => sub { return {} }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 2 | required => 0, | |||||||||
| 39 | predicate => 'has_classes', | ||||||||||
| 40 | clearer => 'clear_classes', | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | =head2 save_env | ||||||||||
| 44 | |||||||||||
| 45 | At each rule save the env for debugging purposes. | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | |||||||||||
| 49 | 15 | ▶ | sub save_env { | ||||||||
|
Subroutine
save_env: called CC=2 SCAR=10.9
Pod
documented
| |||||||||||
| 50 | 15 | my $self = shift; | |||||||||
| 51 | |||||||||||
| 52 | 15 | ▶ | return unless $self->save_object_env; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | $DB::single = 2; | |||||||||
| 55 | 0 | $self->_classes->{ $self->key } = dclone($self); | |||||||||
| 56 | 0 | return; | |||||||||
| 57 | 0 | $DB::single = 2; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 2 | 1; | |||||||||