Skip to content
Snippets Groups Projects
Commit 2e275cd7 authored by Leo Gordon's avatar Leo Gordon
Browse files

API change: merged Q::get_num_failed_analyses +...

API change: merged Q::get_num_failed_analyses + Q::get_remaining_jobs_show_hive_progress -> Q::show_and_return_totals
parent 51d8bdbd
No related branches found
No related tags found
No related merge requests found
......@@ -61,13 +61,6 @@ sub object_class {
}
sub fetch_all_failed_analyses {
my $self = shift;
return $self->fetch_all( "JOIN analysis_stats s USING(analysis_id) WHERE s.status='FAILED'" );
}
=head2 fetch_by_logic_name_or_url
Description: given a URL gets the analysis from URLFactory, otherwise fetches it from the db
......
......@@ -647,73 +647,51 @@ sub check_nothing_to_run_but_semaphored { # make sure it is run after a recent
}
=head2 get_num_failed_analyses
=head2 show_and_return_totals
Arg [1] : $list_of_analyses
Example : my $num_failed_analyses = $self->get_num_failed_analyses( [ $analysis_A, $analysis_B ] );
Example : if( $self->get_num_failed_analyses( [ $analysis_A, $analysis_B, $analysis_C ] )) { do_something; }
Description: Reports all failed analyses and returns their number.
Returntype : int
Example : my ($failed_analyses_counter, $num_remaining_jobs) = $queen->show_and_return_totals( [ $analysis_A, $analysis_B ] );
Description: Runs through all analyses in the given list, reports failed analyses, computes some totals, prints a combined status line
and returns a pair of ($failed_analyses_counter, $total_jobs_to_do)
Exceptions : none
Caller : beekeeper.pl
=cut
sub get_num_failed_analyses {
sub show_and_return_totals {
my ($self, $list_of_analyses) = @_;
my $failed_analyses_counter = 0;
my ($failed_analyses_counter, $total_done_jobs, $total_failed_jobs, $total_jobs, $cpumsec_to_do) = (0) x 5;
foreach my $analysis (@$list_of_analyses) {
my $stats = $analysis->stats;
my $stats = $analysis->stats;
my $failed_job_count = $stats->failed_job_count;
if( $stats->status eq 'FAILED') {
my $logic_name = $analysis->logic_name;
my $failed_job_count = $stats->failed_job_count;
my $tolerance = $analysis->failed_job_tolerance;
warn "\t##################################################################################################\n";
warn "\t# Analysis '$logic_name' has FAILED (failed Jobs: $failed_job_count, tolerance: $tolerance\%) #\n";
warn "\t##################################################################################################\n";
$failed_analyses_counter++;
}
}
return $failed_analyses_counter;
}
=head2 get_remaining_jobs_show_hive_progress
Arg [1] : $list_of_analyses
Example : my $num_remaining_jobs = $queen->get_remaining_jobs_show_hive_progress( [ $analysis_A, $analysis_B ] );
Description: Runs through all analyses in the given list, computes the total number of remaining jobs and prints a combined status line.
Exceptions : none
Caller : beekeeper.pl
=cut
sub get_remaining_jobs_show_hive_progress {
my ($self, $list_of_analyses) = @_;
my ($done, $failed, $total, $cpumsec_to_do) = (0) x 4;
foreach my $analysis (@$list_of_analyses) {
my $stats = $analysis->stats;
$done += $stats->done_job_count;
$failed += $stats->failed_job_count;
$total += $stats->total_job_count;
$cpumsec_to_do += $stats->ready_job_count * $stats->avg_msec_per_job;
$total_done_jobs += $stats->done_job_count;
$total_failed_jobs += $failed_job_count;
$total_jobs += $stats->total_job_count;
$cpumsec_to_do += $stats->ready_job_count * $stats->avg_msec_per_job;
}
my $jobs_to_do = $total - $done - $failed; # includes SEMAPHORED, READY, CLAIMED, INPROGRESS
my $total_jobs_to_do = $total_jobs - $total_done_jobs - $total_failed_jobs; # includes SEMAPHORED, READY, CLAIMED, INPROGRESS
my $cpuhrs_to_do = $cpumsec_to_do / (1000.0*60*60);
my $percentage_completed = $total
? (($done+$failed)*100.0/$total)
my $percentage_completed = $total_jobs
? (($total_done_jobs+$total_failed_jobs)*100.0/$total_jobs)
: 0.0;
warn sprintf("total over %d analyses : %6.2f%% complete (< %.2f CPU_hrs) (%d to_do + %d done + %d failed = %d total)\n",
scalar(@$list_of_analyses), $percentage_completed, $cpuhrs_to_do, $jobs_to_do, $done, $failed, $total);
scalar(@$list_of_analyses), $percentage_completed, $cpuhrs_to_do, $total_jobs_to_do, $total_done_jobs, $total_failed_jobs, $total_jobs);
return $jobs_to_do;
return ($failed_analyses_counter, $total_jobs_to_do);
}
......
......@@ -272,7 +272,7 @@ sub main {
$self->{'dba'}->get_RoleAdaptor->print_active_role_counts;
Bio::EnsEMBL::Hive::Scheduler::schedule_workers_resync_if_necessary($queen, $valley, $list_of_analyses); # show what would be submitted, but do not actually submit
$queen->get_remaining_jobs_show_hive_progress( $list_of_analyses );
$queen->show_and_return_totals( $list_of_analyses );
if($show_failed_jobs) {
print("===== failed jobs\n");
......@@ -390,8 +390,7 @@ sub run_autonomously {
print "Not submitting any workers this iteration\n";
}
$failed_analyses = $queen->get_num_failed_analyses( $list_of_analyses );
$num_of_remaining_jobs = $queen->get_remaining_jobs_show_hive_progress( $list_of_analyses );
($failed_analyses, $num_of_remaining_jobs) = $queen->show_and_return_totals( $list_of_analyses );
} while( $keep_alive
or (!$failed_analyses and $num_of_remaining_jobs and $iteration!=$max_loops) );
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment