Commit 513dfa4e authored by Leo Gordon's avatar Leo Gordon
Browse files

switch PipelineWideParameters to the common cache (from a simple hash)

parent 2e01559e
......@@ -266,12 +266,7 @@ sub AUTOLOAD {
sub init_collections { # should not really belong to DBAdaptor, temporarily squatting here...
foreach my $AdaptorType ('PipelineWideParameters') {
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( {} );
}
foreach my $AdaptorType ('MetaParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
foreach my $AdaptorType ('MetaParameters', 'PipelineWideParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( Bio::EnsEMBL::Hive::Utils::Collection->new() );
}
......@@ -281,13 +276,7 @@ sub init_collections { # should not really belong to DBAdaptor, temporarily squ
sub load_collections {
my $self = shift @_;
foreach my $AdaptorType ('PipelineWideParameters') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( $adaptor->fetch_param_hash() );
}
foreach my $AdaptorType ('MetaParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
foreach my $AdaptorType ('MetaParameters', 'PipelineWideParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( Bio::EnsEMBL::Hive::Utils::Collection->new( $adaptor->fetch_all ) );
......@@ -298,16 +287,7 @@ sub load_collections {
sub save_collections {
my $self = shift @_;
foreach my $AdaptorType ('PipelineWideParameters') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
while( my ($hash_key,$hash_value) = each %{ $class->collection() } ) {
$adaptor->replace_pair( $hash_key, $hash_value );
# warn "Stored/updated '$hash_key' => '$hash_value'\n";
}
}
foreach my $AdaptorType ('MetaParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
foreach my $AdaptorType ('MetaParameters', 'PipelineWideParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
foreach my $storable_object ( $class->collection()->list ) {
......
......@@ -52,7 +52,7 @@ sub get_value_by_key {
return $collection->find_one_by( 'meta_key', $meta_key );
} else {
} else { # TODO: to be removed when beekeeper.pl/runWorker.pl become collection-aware
my $pair = $self->fetch_by_meta_key( $meta_key );
return $pair && $pair->{'meta_value'};
......
......@@ -45,27 +45,26 @@ sub default_table_name {
}
sub replace_pair {
my ($self, $param_name, $param_value) = @_;
$self->remove_all_by_param_name($param_name); # make sure the previous values are gone
return $self->store( { 'param_name' => $param_name, 'param_value' => stringify( $param_value ) } );
}
=head2 fetch_param_hash
Description: returns the content of the 'meta' table as a hash
Description: returns the contents of the 'pipeline_wide_parameters' table as a hash
=cut
sub fetch_param_hash {
my $self = shift @_;
if( my $collection = Bio::EnsEMBL::Hive::PipelineWideParameters->collection() ) {
return { map { $_->{'param_name'} => destringify($->{'param_value'}) } $collection->list() };
} else { # TODO: to be removed when beekeeper.pl/runWorker.pl become collection-aware
my $original_value = $self->fetch_HASHED_FROM_param_name_TO_param_value();
my %destringified_hash = map { $_, destringify($original_value->{$_}) } keys %$original_value;
return \%destringified_hash;
}
}
1;
......@@ -465,8 +465,13 @@ sub add_objects_from_config {
warn "Done.\n\n";
warn "Adding pipeline-wide parameters ...\n";
my $mc_coll = Bio::EnsEMBL::Hive::PipelineWideParameters->collection();
%$mc_coll = (%$mc_coll, %{$self->pipeline_wide_parameters()} );
my $new_pwp_entries = $self->pipeline_wide_parameters();
while( my ($param_name, $param_value) = each %$new_pwp_entries ) {
Bio::EnsEMBL::Hive::PipelineWideParameters->add_new_or_update(
'param_name' => $param_name,
'param_value' => $param_value,
);
}
warn "Done.\n\n";
warn "Adding Resources ...\n";
......
......@@ -34,5 +34,10 @@ use strict;
use base ( 'Bio::EnsEMBL::Hive::Cacheable' );
sub unikey { # override the default from Cacheable parent
return [ 'param_name' ];
}
1;
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