Commit 636b5963 authored by Leo Gordon's avatar Leo Gordon
Browse files

AnalysisStats.get_analysis/analysis_id are substituted by an autoloaded analysis/analysis_id pair

parent 5bb15879
......@@ -49,12 +49,13 @@ sub min_batch_time {
return 2*60*1000;
}
## pre-settable storable object's getters/setters:
sub analysis_id { # an alias
my $self = shift;
return $self->dbID(@_);
}
=head1 AUTOLOADED
analysis_id / analysis
=cut
sub batch_size {
my $self = shift;
......@@ -220,16 +221,6 @@ sub update_status {
$self->status($status);
}
sub get_analysis {
my $self = shift;
unless($self->{'_analysis'}) {
unless($self->analysis_id) {
throw("self->analysis_id undefined, please investigate");
}
$self->{'_analysis'} = $self->adaptor->db->get_AnalysisAdaptor->fetch_by_dbID($self->analysis_id);
}
return $self->{'_analysis'};
}
sub get_or_estimate_batch_size {
my $self = shift;
......@@ -281,7 +272,7 @@ sub job_count_breakout {
sub toString {
my $self = shift @_;
my $analysis = $self->get_analysis;
my $analysis = $self->analysis;
my $output .= sprintf("%-27s(%2d) %11s jobs(Sem:%d, Rdy:%d, InProg:%d, Done+Pass:%d, Fail:%d)=%d Ave_msec:%d, workers(Running:%d, Reqired:%d) ",
$analysis->logic_name,
......@@ -358,7 +349,7 @@ sub determine_status {
$self->status('EMPTY');
} elsif( $self->total_job_count == $self->done_job_count + $self->failed_job_count ) { # all jobs of the analysis have been finished
my $analysis = $self->get_analysis;
my $analysis = $self->analysis;
my $absolute_tolerance = $analysis->failed_job_tolerance * $self->total_job_count / 100.0;
if ($self->failed_job_count > $absolute_tolerance) {
$self->status('FAILED');
......
......@@ -576,10 +576,9 @@ sub run {
'analysis_capacity' => $analysis_capacity,
);
$analysis->get_compiled_module_name(); # check if it compiles and is named correctly
$analysis_adaptor->store($analysis);
my $stats = Bio::EnsEMBL::Hive::AnalysisStats->new(
'analysis_id' => $analysis->dbID,
'analysis' => $analysis,
'batch_size' => $batch_size,
'hive_capacity' => $hive_capacity,
'status' => $blocked ? 'BLOCKED' : 'EMPTY', # be careful, as this "soft" way of blocking may be accidentally unblocked by deep sync
......@@ -595,6 +594,8 @@ sub run {
'output_capacity' => 4,
'sync_lock' => 0,
);
$analysis_adaptor->store($analysis);
$analysis_stats_adaptor->store($stats);
}
......@@ -629,8 +630,9 @@ sub run {
# create control rules:
foreach my $condition_url (@$wait_for) {
unless ($condition_url =~ m{^\w*://}) {
my $condition_analysis = $analysis_adaptor->fetch_by_logic_name($condition_url);
die "Could not fetch analysis '$condition_url' to create a control rule (in '".($analysis->logic_name)."')\n" unless defined $condition_analysis;
# TODO: this should become a call to Pipeline_object:
my $condition_analysis = $analysis_adaptor->fetch_by_logic_name($condition_url)
or die "Could not fetch analysis '$condition_url' to create a control rule (in '".($analysis->logic_name)."')\n";
}
my $c_rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new(
'condition_analysis_url' => $condition_url,
......@@ -680,8 +682,9 @@ sub run {
while(my ($heir_url, $input_id_template_list) = each %$heirs) {
unless ($heir_url =~ m{^\w*://}) {
my $heir_analysis = $analysis_adaptor->fetch_by_logic_name($heir_url);
die "No analysis named '$heir_url' (dataflow from analysis '".($analysis->logic_name)."')\n" unless defined $heir_analysis;
# TODO: this should become a call to Pipeline_object:
my $heir_analysis = $analysis_adaptor->fetch_by_logic_name($heir_url)
or die "No analysis named '$heir_url' (dataflow from analysis '".($analysis->logic_name)."')\n";
}
$input_id_template_list = [ $input_id_template_list ] unless(ref($input_id_template_list) eq 'ARRAY'); # allow for more than one template per analysis
......
......@@ -634,7 +634,7 @@ sub synchronize_AnalysisStats {
# compute the number of total required workers for this analysis (taking into account the jobs that are already running)
my $analysis = $analysisStats->get_analysis();
my $analysis = $analysisStats->analysis();
my $scheduling_allowed = ( !defined( $analysisStats->hive_capacity ) or $analysisStats->hive_capacity )
&& ( !defined( $analysis->analysis_capacity ) or $analysis->analysis_capacity );
my $required_workers = $scheduling_allowed
......
......@@ -116,11 +116,11 @@ sub suggest_analysis_to_specialize_by_rc_id_meadow_type {
sub schedule_workers {
my ($queen, $submit_capacity, $default_meadow_type, $filter_rc_id, $filter_meadow_type, $filter_analysis, $meadow_capacity_limiter_hashed_by_type, $analysis_id2rc_name) = @_;
my @suitable_analyses = $filter_analysis
my @suitable_analyses_stats = $filter_analysis
? ( $filter_analysis->stats )
: @{ $queen->db->get_AnalysisStatsAdaptor->fetch_all_by_suitability_rc_id_meadow_type($filter_rc_id, $filter_meadow_type) };
unless(@suitable_analyses) {
unless(@suitable_analyses_stats) {
return $analysis_id2rc_name ? ({}, 0, "Scheduler could not find any suitable analyses to start with\n") : undef; # FIXME: returns data in different format in "suggest analysis" mode
}
......@@ -132,10 +132,10 @@ sub schedule_workers {
my $submit_capacity_limiter = Bio::EnsEMBL::Hive::Limiter->new( 'Max number of Workers scheduled this time', $submit_capacity );
my $queen_capacity_limiter = Bio::EnsEMBL::Hive::Limiter->new( 'Total reciprocal capacity of the Hive', 1.0 - $queen->get_hive_current_load() );
foreach my $analysis_stats (@suitable_analyses) {
foreach my $analysis_stats (@suitable_analyses_stats) {
last if( $submit_capacity_limiter->reached );
my $analysis = $analysis_stats->get_analysis; # FIXME: if it proves too expensive we may need to consider caching
my $analysis = $analysis_stats->analysis(); # FIXME: if it proves too expensive we may need to consider caching
my $this_meadow_type = $analysis->meadow_type || $default_meadow_type;
next if( $meadow_capacity_limiter_hashed_by_type && $meadow_capacity_limiter_hashed_by_type->{$this_meadow_type}->reached );
......
Markdown is supported
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