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 { ...@@ -49,12 +49,13 @@ sub min_batch_time {
return 2*60*1000; return 2*60*1000;
} }
## pre-settable storable object's getters/setters:
sub analysis_id { # an alias =head1 AUTOLOADED
my $self = shift;
return $self->dbID(@_); analysis_id / analysis
}
=cut
sub batch_size { sub batch_size {
my $self = shift; my $self = shift;
...@@ -220,16 +221,6 @@ sub update_status { ...@@ -220,16 +221,6 @@ sub update_status {
$self->status($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 { sub get_or_estimate_batch_size {
my $self = shift; my $self = shift;
...@@ -281,7 +272,7 @@ sub job_count_breakout { ...@@ -281,7 +272,7 @@ sub job_count_breakout {
sub toString { sub toString {
my $self = shift @_; 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) ", 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, $analysis->logic_name,
...@@ -358,7 +349,7 @@ sub determine_status { ...@@ -358,7 +349,7 @@ sub determine_status {
$self->status('EMPTY'); $self->status('EMPTY');
} elsif( $self->total_job_count == $self->done_job_count + $self->failed_job_count ) { # all jobs of the analysis have been finished } 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; my $absolute_tolerance = $analysis->failed_job_tolerance * $self->total_job_count / 100.0;
if ($self->failed_job_count > $absolute_tolerance) { if ($self->failed_job_count > $absolute_tolerance) {
$self->status('FAILED'); $self->status('FAILED');
......
...@@ -576,10 +576,9 @@ sub run { ...@@ -576,10 +576,9 @@ sub run {
'analysis_capacity' => $analysis_capacity, 'analysis_capacity' => $analysis_capacity,
); );
$analysis->get_compiled_module_name(); # check if it compiles and is named correctly $analysis->get_compiled_module_name(); # check if it compiles and is named correctly
$analysis_adaptor->store($analysis);
my $stats = Bio::EnsEMBL::Hive::AnalysisStats->new( my $stats = Bio::EnsEMBL::Hive::AnalysisStats->new(
'analysis_id' => $analysis->dbID, 'analysis' => $analysis,
'batch_size' => $batch_size, 'batch_size' => $batch_size,
'hive_capacity' => $hive_capacity, 'hive_capacity' => $hive_capacity,
'status' => $blocked ? 'BLOCKED' : 'EMPTY', # be careful, as this "soft" way of blocking may be accidentally unblocked by deep sync '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 { ...@@ -595,6 +594,8 @@ sub run {
'output_capacity' => 4, 'output_capacity' => 4,
'sync_lock' => 0, 'sync_lock' => 0,
); );
$analysis_adaptor->store($analysis);
$analysis_stats_adaptor->store($stats); $analysis_stats_adaptor->store($stats);
} }
...@@ -629,8 +630,9 @@ sub run { ...@@ -629,8 +630,9 @@ sub run {
# create control rules: # create control rules:
foreach my $condition_url (@$wait_for) { foreach my $condition_url (@$wait_for) {
unless ($condition_url =~ m{^\w*://}) { unless ($condition_url =~ m{^\w*://}) {
my $condition_analysis = $analysis_adaptor->fetch_by_logic_name($condition_url); # TODO: this should become a call to Pipeline_object:
die "Could not fetch analysis '$condition_url' to create a control rule (in '".($analysis->logic_name)."')\n" unless defined $condition_analysis; 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( my $c_rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new(
'condition_analysis_url' => $condition_url, 'condition_analysis_url' => $condition_url,
...@@ -680,8 +682,9 @@ sub run { ...@@ -680,8 +682,9 @@ sub run {
while(my ($heir_url, $input_id_template_list) = each %$heirs) { while(my ($heir_url, $input_id_template_list) = each %$heirs) {
unless ($heir_url =~ m{^\w*://}) { unless ($heir_url =~ m{^\w*://}) {
my $heir_analysis = $analysis_adaptor->fetch_by_logic_name($heir_url); # TODO: this should become a call to Pipeline_object:
die "No analysis named '$heir_url' (dataflow from analysis '".($analysis->logic_name)."')\n" unless defined $heir_analysis; 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 $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 { ...@@ -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) # 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 ) my $scheduling_allowed = ( !defined( $analysisStats->hive_capacity ) or $analysisStats->hive_capacity )
&& ( !defined( $analysis->analysis_capacity ) or $analysis->analysis_capacity ); && ( !defined( $analysis->analysis_capacity ) or $analysis->analysis_capacity );
my $required_workers = $scheduling_allowed my $required_workers = $scheduling_allowed
......
...@@ -116,11 +116,11 @@ sub suggest_analysis_to_specialize_by_rc_id_meadow_type { ...@@ -116,11 +116,11 @@ sub suggest_analysis_to_specialize_by_rc_id_meadow_type {
sub schedule_workers { 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 ($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 ) ? ( $filter_analysis->stats )
: @{ $queen->db->get_AnalysisStatsAdaptor->fetch_all_by_suitability_rc_id_meadow_type($filter_rc_id, $filter_meadow_type) }; : @{ $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 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 { ...@@ -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 $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() ); 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 ); 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; 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 ); 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