Commit f562ba28 authored by Leo Gordon's avatar Leo Gordon
Browse files

bugfix: make sure -wait_for is working properly again (do not auto-initialize Cacheable)

parent ae3e65fd
......@@ -200,8 +200,11 @@ sub display_name {
sub stats {
my $self = shift @_;
return Bio::EnsEMBL::Hive::AnalysisStats->collection()->find_one_by('analysis', $self)
|| $self->adaptor->db->get_AnalysisStatsAdaptor->fetch_by_analysis_id( $self->dbID );
my $collection = Bio::EnsEMBL::Hive::AnalysisStats->collection();
return $collection
? $collection->find_one_by('analysis', $self)
: $self->adaptor->db->get_AnalysisStatsAdaptor->fetch_by_analysis_id( $self->dbID );
}
......@@ -217,17 +220,18 @@ sub jobs_collection {
sub control_rules_collection {
my $self = shift @_;
return Bio::EnsEMBL::Hive::AnalysisCtrlRule->collection()->find_all_by('ctrled_analysis', $self)
|| $self->adaptor->db->get_AnalysisCtrlRuleAdaptor->fetch_all_by_ctrled_analysis_id( $self->dbID );
my $collection = Bio::EnsEMBL::Hive::AnalysisCtrlRule->collection();
return $collection
? $collection->find_all_by('ctrled_analysis', $self)
: $self->adaptor->db->get_AnalysisCtrlRuleAdaptor->fetch_all_by_ctrled_analysis_id( $self->dbID );
}
sub dataflow_rules_collection {
my $self = shift @_;
$self->{'_dataflow_rules_collection'} = shift if(@_);
return $self->{'_dataflow_rules_collection'} || Bio::EnsEMBL::Hive::DataflowRule->collection()->find_all_by('from_analysis', $self);
return Bio::EnsEMBL::Hive::DataflowRule->collection()->find_all_by('from_analysis', $self);
}
......
......@@ -118,7 +118,9 @@ sub condition_analysis {
# lazy load the analysis object if I can
if( !$self->{'_condition_analysis'} and my $condition_analysis_url = $self->condition_analysis_url ) {
if( $self->{'_condition_analysis'} = Bio::EnsEMBL::Hive::Analysis->collection()->find_one_by('logic_name', $condition_analysis_url) ) {
my $collection = Bio::EnsEMBL::Hive::Analysis->collection();
if( $collection and $self->{'_condition_analysis'} = $collection->find_one_by('logic_name', $condition_analysis_url) ) {
# warn "Lazy-loading object from 'Analysis' collection\n";
} elsif(my $adaptor = $self->adaptor) {
# warn "Lazy-loading object from AnalysisAdaptor\n";
......
......@@ -13,7 +13,7 @@ sub collection {
$cache_by_class{$class} = shift @_;
}
return $cache_by_class{$class} ||= Bio::EnsEMBL::Hive::Utils::Collection->new();
return $cache_by_class{$class};
}
......
......@@ -41,6 +41,10 @@ use Bio::EnsEMBL::Hive::DBSQL::DBConnection;
use Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor;
use Bio::EnsEMBL::Hive::Utils ('throw');
use Bio::EnsEMBL::Hive::Utils::Collection;
use Bio::EnsEMBL::Hive::ResourceClass;
use Bio::EnsEMBL::Hive::ResourceDescription;
use Bio::EnsEMBL::Hive::Analysis;
use Bio::EnsEMBL::Hive::AnalysisStats;
sub new {
......@@ -256,6 +260,19 @@ sub AUTOLOAD {
}
sub init_collections { # should not really belong to DBAdaptor, temporarily squatting here...
foreach my $AdaptorType ('Meta', 'PipelineWideParameters') {
Bio::EnsEMBL::Hive->collection( $AdaptorType, {} );
}
foreach my $AdaptorType ('ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( Bio::EnsEMBL::Hive::Utils::Collection->new() );
}
}
sub load_collections {
my $self = shift @_;
......
......@@ -160,8 +160,9 @@ sub to_analysis {
# lazy load the analysis object if I can
if( !$self->{'_to_analysis'} and my $to_analysis_url = $self->to_analysis_url ) {
my $collection = Bio::EnsEMBL::Hive::Analysis->collection();
if( $self->{'_to_analysis'} = Bio::EnsEMBL::Hive::Analysis->collection()->find_one_by('logic_name', $to_analysis_url) ) {
if( $collection and $self->{'_to_analysis'} = $collection->find_one_by('logic_name', $to_analysis_url) ) {
# warn "Lazy-loading object from 'Analysis' collection\n";
} elsif(my $adaptor = $self->adaptor) {
# warn "Lazy-loading object from AnalysisAdaptor\n";
......
......@@ -156,7 +156,8 @@ sub AUTOLOAD {
# attempt to lazy-load:
} elsif( !$self->{$foo_obj_method_name} and my $foo_object_id = $self->{$foo_id_method_name}) {
my $foo_class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
if( $self->{$foo_obj_method_name} = $foo_class->collection()->find_one_by('dbID', $foo_object_id) ) { # careful: $AdaptorType may not be unique (aliases)
my $collection = $foo_class->collection();
if( $collection and $self->{$foo_obj_method_name} = $collection->find_one_by('dbID', $foo_object_id) ) { # careful: $AdaptorType may not be unique (aliases)
# warn "Lazy-loading object from $AdaptorType collection\n";
} elsif(my $adaptor = $self->adaptor) {
# warn "Lazy-loading object from $AdaptorType adaptor\n";
......
......@@ -72,6 +72,9 @@ sub main {
);
$self->{'dba'}->load_collections();
} else {
Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->init_collections();
}
if($self->{'pipeconfig'}) {
......
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