« lib/BioX/Workflow/Command/run/Rules/Directives/Inspect.pm
↑ Summary
lib/BioX/Workflow/Command/inspect/Utils/ParsePlainText.pm »
| 1 | package BioX::Workflow::Command::run::Utils::Files::ResolveDeps; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use MooseX::App::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use String::Approx 'amatch'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Algorithm::Dependency::Source::HoA; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Algorithm::Dependency::Ordered; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Text::ASCIITable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | option 'auto_deps' => ( | |||||||||
| 17 | is => 'rw', | ||||||||||
| 18 | isa => 'Bool', | ||||||||||
| 19 | default => 0, | ||||||||||
| 20 | documentation => | ||||||||||
| 21 | 'Create a dependency tree using the INPUT/OUTPUTs of a rule', | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | has 'rule_deps' => ( | ||||||||||
| 25 | traits => ['Hash'], | ||||||||||
| 26 | is => 'rw', | ||||||||||
| 27 | isa => 'HashRef', | ||||||||||
| 28 | 0 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 29 | 1 | handles => { | |||||||||
| 30 | seen_rule_deps_pairs => 'kv', | ||||||||||
| 31 | clear_seen_rule_deps => 'clear', | ||||||||||
| 32 | }, | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | has 'graph' => ( | ||||||||||
| 36 | traits => ['Hash'], | ||||||||||
| 37 | is => 'rw', | ||||||||||
| 38 | isa => 'HashRef', | ||||||||||
| 39 | 0 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 40 | 1 | handles => { | |||||||||
| 41 | seen_graph_pairs => 'kv', | ||||||||||
| 42 | clear_seen_graph => 'clear', | ||||||||||
| 43 | }, | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub add_graph { | ||||||||
|
Subroutine
add_graph: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 47 | 0 | my $self = shift; | |||||||||
| 48 | 0 | my $cond = shift; | |||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | return unless $self->files; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | ▶ | return unless $self->has_files; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | for my $file ( $self->all_files ) { | |||||||||
| 54 | 0 | ▶ | if ( !exists $self->rule_deps->{ $self->rule_name }->{$cond}->{$file} ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | { | ||||||||||
| 56 | 0 | $self->rule_deps->{ $self->rule_name }->{$cond}->{$file} = 1; | |||||||||
| 57 | } | ||||||||||
| 58 | } | ||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub post_process_rules { | ||||||||
|
Subroutine
post_process_rules: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 62 | 0 | my $self = shift; | |||||||||
| 63 | |||||||||||
| 64 | #Create flags for outputs that have a similar input | ||||||||||
| 65 | 0 | $self->app_log->info(); | |||||||||
| 66 | |||||||||||
| 67 | 0 | $self->dedeps; | |||||||||
| 68 | 0 | $self->process_auto_deps; | |||||||||
| 69 | |||||||||||
| 70 | 0 | $self->print_process_workflow; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub print_stats_rules { | ||||||||
|
Subroutine
print_stats_rules: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 74 | 0 | my $self = shift; | |||||||||
| 75 | 0 | my $rule = shift; | |||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | return unless $self->process_obj->{$rule}->{run_stats}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | $self->fh->say(""); | |||||||||
| 79 | |||||||||||
| 80 | 0 | $self->fh->say( $self->comment_char ); | |||||||||
| 81 | 0 | $self->fh->say( | |||||||||
| 82 | $self->comment_char . " Starting " . $rule . "_biox_stats" ); | ||||||||||
| 83 | 0 | $self->fh->say( $self->comment_char ); | |||||||||
| 84 | 0 | $self->fh->say(""); | |||||||||
| 85 | |||||||||||
| 86 | 0 | $self->fh->say( $self->comment_char ); | |||||||||
| 87 | 0 | $self->fh->say( '### HPC Directives' . "\n" ); | |||||||||
| 88 | 0 | $self->fh->say( $self->comment_char ); | |||||||||
| 89 | 0 | $self->fh->say( '#HPC jobname=' . $rule . "_biox_stats" ); | |||||||||
| 90 | 0 | $self->fh->say( '#HPC deps=' . $rule ); | |||||||||
| 91 | 0 | $self->fh->say('#HPC mem=2GB'); | |||||||||
| 92 | 0 | $self->fh->say('#HPC cpus_per_task=1'); | |||||||||
| 93 | 0 | $self->fh->say('#HPC commands_per_node=1000'); | |||||||||
| 94 | 0 | $self->fh->say( $self->comment_char ); | |||||||||
| 95 | 0 | $self->fh->say(""); | |||||||||
| 96 | |||||||||||
| 97 | 0 | foreach my $sample ($self->all_samples){ | |||||||||
| 98 | 0 | $self->fh->say(""); | |||||||||
| 99 | 0 | $self->fh->say( | |||||||||
| 100 | "biox stats --samples " . $sample . " \\" ); | ||||||||||
| 101 | 0 | $self->fh->say( "--select_rules " . $rule . " \\" ); | |||||||||
| 102 | 0 | $self->fh->say( "-w " . $self->cached_workflow ); | |||||||||
| 103 | 0 | $self->fh->say(""); | |||||||||
| 104 | } | ||||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | =head3 dedeps | ||||||||||
| 108 | |||||||||||
| 109 | If using select_rules comment out the #HPC deps portion on the first rule | ||||||||||
| 110 | |||||||||||
| 111 | #TODO add this in to iter_hash_hpc instead of here, account for select_btwn | ||||||||||
| 112 | |||||||||||
| 113 | =cut | ||||||||||
| 114 | |||||||||||
| 115 | 0 | ▶ | sub dedeps { | ||||||||
|
Subroutine
dedeps: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 116 | 0 | my $self = shift; | |||||||||
| 117 | |||||||||||
| 118 | 0 | ▶ | return unless $self->has_select_rule_keys; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | 0 | ▶ | return unless $self->select_effect; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 120 | |||||||||||
| 121 | 0 | my $first_rule = $self->select_rule_keys->[0]; | |||||||||
| 122 | |||||||||||
| 123 | 0 | my $meta = $self->process_obj->{$first_rule}->{meta}; | |||||||||
| 124 | 0 | ▶ | $meta = [] unless $meta; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 125 | 0 | my $before_meta = join( "\n", @{$meta} ); | |||||||||
| 126 | |||||||||||
| 127 | 0 | $before_meta =~ s/#HPC deps=/##HPC deps=/g; | |||||||||
| 128 | 0 | my @text = split( "\n", $before_meta ); | |||||||||
| 129 | 0 | $self->process_obj->{$first_rule}->{meta} = \@text; | |||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | =head3 | ||||||||||
| 133 | |||||||||||
| 134 | Iterate over rule_names | ||||||||||
| 135 | If they are in select_rules use those also | ||||||||||
| 136 | Otherwise only use the schedule | ||||||||||
| 137 | If using timestamps we have a timestamp, but in no particular order | ||||||||||
| 138 | If select rules we have select_rules, but also in no particular Ordered | ||||||||||
| 139 | for $s @schedule { if print_rule (print the process_obj)} | ||||||||||
| 140 | We also need to update the #HPC meta to include deps | ||||||||||
| 141 | |||||||||||
| 142 | =cut | ||||||||||
| 143 | |||||||||||
| 144 | 0 | ▶ | sub process_auto_deps { | ||||||||
|
Subroutine
process_auto_deps: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||
| 145 | 0 | my $self = shift; | |||||||||
| 146 | |||||||||||
| 147 | 0 | ▶ | return unless $self->auto_deps; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | |||||||||||
| 149 | 0 | foreach my $rule ( $self->all_select_rule_keys ) { | |||||||||
| 150 | |||||||||||
| 151 | 0 | ▶ | $self->graph->{$rule} = [] if !exists $self->graph->{$rule}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 152 | 0 | my $meta = $self->process_obj->{$rule}->{meta}; | |||||||||
| 153 | 0 | ▶ | $meta = [] unless $meta; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 154 | 0 | my $before_meta = join( "\n", @{$meta} ); | |||||||||
| 155 | |||||||||||
| 156 | 0 | ▶ | if ( $before_meta =~ m/#HPC deps=/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 157 | 0 | next; | |||||||||
| 158 | } | ||||||||||
| 159 | 0 | my @deps = @{ $self->graph->{$rule} }; | |||||||||
| 160 | 0 | ▶ | if (@deps) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 161 | 0 | chomp($before_meta); | |||||||||
| 162 | 0 | $before_meta .= "\n#HPC deps=" . join( ',', @deps ) . "\n\n"; | |||||||||
| 163 | } | ||||||||||
| 164 | 0 | my @text = split( "\n", $before_meta ); | |||||||||
| 165 | 0 | $self->process_obj->{$rule}->{meta} = \@text; | |||||||||
| 166 | } | ||||||||||
| 167 | } | ||||||||||
| 168 | |||||||||||
| 169 | 1 | 1; | |||||||||