Commit 21eefd23 authored by Leo Gordon's avatar Leo Gordon
Browse files

switching the underlying mechanism of TheApiary from a simple hash to a Utils::Collection

parent 9babee5e
......@@ -7,6 +7,7 @@ use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Utils ('stringify', 'destringify', 'throw');
use Bio::EnsEMBL::Hive::Utils::Collection;
use Bio::EnsEMBL::Hive::Utils::PCL;
use Bio::EnsEMBL::Hive::Utils::URL;
# needed for offline graph generation:
use Bio::EnsEMBL::Hive::Accumulator;
......@@ -35,6 +36,17 @@ sub display_name {
}
sub unambig_key { # based on DBC's URL if present, otherwise on pipeline_name
my $self = shift @_;
if(my $dbc = $self->hive_dba && $self->hive_dba->dbc) {
return Bio::EnsEMBL::Hive::Utils::URL::hash_to_unambig_url( $dbc->to_url_hash );
} else {
return 'unstored:'.$self->hive_pipeline_name;
}
}
sub collection_of {
my $self = shift @_;
my $type = shift @_;
......
......@@ -41,28 +41,28 @@ use strict;
use warnings;
use Data::Dumper;
use Bio::EnsEMBL::Hive::Utils::Collection;
use Bio::EnsEMBL::Hive::Utils::URL;
use Bio::EnsEMBL::Hive::HivePipeline;
# global instance to cache HivePipeline objects:
my $_global_Apiary_hash;
my $_global_Apiary_collection;
sub pipelines_collection {
my $class = shift @_;
return $_global_Apiary_hash ||= {};
return $_global_Apiary_collection ||= Bio::EnsEMBL::Hive::Utils::Collection->new;
}
sub pipelines_except {
my ($class, $except_pipeline) = @_;
my $except_display_name = $except_pipeline->display_name;
my %collection_hash = %{ $class->pipelines_collection };
my $except_unambig_key = $except_pipeline->unambig_key;
return [ grep { $_->display_name ne $except_display_name } map { $collection_hash{$_} } sort keys %collection_hash ];
return [ grep { $_->unambig_key ne $except_unambig_key } $class->pipelines_collection->list ];
}
......@@ -86,17 +86,19 @@ sub find_by_url {
$hive_pipeline = $default_pipeline;
} elsif( not ($hive_pipeline = $class->pipelines_collection->{ $unambig_key }) ) {
} elsif( not ($hive_pipeline = $class->pipelines_collection->find_one_by( 'unambig_key', $unambig_key ) ) ) {
if($query_params and ($query_params->{'object_type'} eq 'NakedTable') ) { # do not check schema version when performing table dataflow:
$no_sql_schema_version_check = 1;
}
$class->pipelines_collection->{ $unambig_key } = $hive_pipeline = Bio::EnsEMBL::Hive::HivePipeline->new(
$hive_pipeline = Bio::EnsEMBL::Hive::HivePipeline->new(
-url => $parsed_url->{'dbconn_part'},
-disconnect_when_inactive => $disconnect_when_inactive,
-no_sql_schema_version_check=> $no_sql_schema_version_check,
);
$class->pipelines_collection->add( $hive_pipeline );
}
return $query_params
......@@ -118,7 +120,7 @@ sub fetch_remote_semaphores_controlling_this_one { # NB! This method has a
my @remote_controlling_semaphores = ();
foreach my $remote_pipeline (values %{ $class->pipelines_collection }, @extra_pipelines ) {
foreach my $remote_pipeline ($class->pipelines_collection->list, @extra_pipelines ) {
push @remote_controlling_semaphores, @{ $remote_pipeline->hive_dba->get_SemaphoreAdaptor->fetch_all_by_dependent_semaphore_url( $this_semaphore_url ) };
}
......
......@@ -241,8 +241,7 @@ sub build {
$self->graph->cluster_2_nodes( \%cluster_2_nodes );
if( $self->config_get('DisplayDetails') ) {
my %foreign_pipelines = %{ Bio::EnsEMBL::Hive::TheApiary->pipelines_collection };
foreach my $pipeline ( $main_pipeline, @foreign_pipelines{sort keys %foreign_pipelines} ) {
foreach my $pipeline ( $main_pipeline, Bio::EnsEMBL::Hive::TheApiary->pipelines_collection->list ) {
my $pipeline_cluster_name = _cluster_name( $pipeline->hive_pipeline_name );
$self->graph->cluster_2_attributes->{ $pipeline_cluster_name }{ 'display_cluster_name' } = 1;
$self->graph->cluster_2_attributes->{ $pipeline_cluster_name }{ 'style' } = 'bold,filled';
......
......@@ -34,7 +34,7 @@ my $client_url = get_test_url_or_die(-tag => 'client');
init_pipeline('Bio::EnsEMBL::Hive::Examples::LongMult::PipeConfig::LongMultWfServer_conf', $server_url, [], ['pipeline.param[take_time]=0']);
init_pipeline('Bio::EnsEMBL::Hive::Examples::LongMult::PipeConfig::LongMultWfClient_conf', $client_url, [-server_url => $server_url], ['pipeline.param[take_time]=0']);
foreach my $p (values %{ Bio::EnsEMBL::Hive::TheApiary->pipelines_collection } ) {
foreach my $p ( Bio::EnsEMBL::Hive::TheApiary->pipelines_collection->list ) {
$p->hive_dba->dbc->disconnect_if_idle;
}
......
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