From e38de2d91f0fcfab8e165dd992e8e6a7cc99c9f5 Mon Sep 17 00:00:00 2001 From: Leo Gordon <lg4@ebi.ac.uk> Date: Tue, 4 Feb 2014 13:03:02 +0000 Subject: [PATCH] Storable->new() now performs setting of all parameters without the use of rearrange (NB: change of call format!) --- modules/Bio/EnsEMBL/Hive/Accumulator.pm | 19 +---- modules/Bio/EnsEMBL/Hive/Analysis.pm | 28 +------ modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm | 30 +------ modules/Bio/EnsEMBL/Hive/AnalysisJob.pm | 68 +++++---------- modules/Bio/EnsEMBL/Hive/AnalysisStats.pm | 42 +--------- .../Bio/EnsEMBL/Hive/DBSQL/ObjectAdaptor.pm | 4 +- modules/Bio/EnsEMBL/Hive/DataflowRule.pm | 36 +------- modules/Bio/EnsEMBL/Hive/NakedTable.pm | 18 +--- .../Hive/PipeConfig/HiveGeneric_conf.pm | 84 +++++++++---------- modules/Bio/EnsEMBL/Hive/ResourceClass.pm | 19 +---- .../Bio/EnsEMBL/Hive/ResourceDescription.pm | 20 +---- modules/Bio/EnsEMBL/Hive/Storable.pm | 17 ++-- modules/Bio/EnsEMBL/Hive/URLFactory.pm | 12 +-- modules/Bio/EnsEMBL/Hive/Worker.pm | 31 +------ scripts/seed_pipeline.pl | 6 +- scripts/standaloneJob.pl | 6 +- 16 files changed, 95 insertions(+), 345 deletions(-) diff --git a/modules/Bio/EnsEMBL/Hive/Accumulator.pm b/modules/Bio/EnsEMBL/Hive/Accumulator.pm index dfad3f988..2e3935cd9 100644 --- a/modules/Bio/EnsEMBL/Hive/Accumulator.pm +++ b/modules/Bio/EnsEMBL/Hive/Accumulator.pm @@ -32,25 +32,10 @@ package Bio::EnsEMBL::Hive::Accumulator; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); -use Bio::EnsEMBL::Hive::Utils ('stringify'); - -use base ( 'Bio::EnsEMBL::Hive::Storable' ); # inherit dbID(), adaptor() and new() methods - - -sub new { - my $class = shift @_; - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ($struct_name, $signature_template) = - rearrange([qw(struct_name signature_template) ], @_); - - $self->struct_name($struct_name) if(defined($struct_name)); - $self->signature_template($signature_template) if(defined($signature_template)); +use Bio::EnsEMBL::Hive::Utils ('stringify'); - return $self; -} +use base ( 'Bio::EnsEMBL::Hive::Storable' ); sub struct_name { diff --git a/modules/Bio/EnsEMBL/Hive/Analysis.pm b/modules/Bio/EnsEMBL/Hive/Analysis.pm index 740b98cd3..70180898c 100644 --- a/modules/Bio/EnsEMBL/Hive/Analysis.pm +++ b/modules/Bio/EnsEMBL/Hive/Analysis.pm @@ -37,37 +37,11 @@ package Bio::EnsEMBL::Hive::Analysis; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); - use Bio::EnsEMBL::Hive::Utils ('stringify'); -use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods - ); +use base ( 'Bio::EnsEMBL::Hive::Storable' ); -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ($logic_name, $module, $parameters, $resource_class_id, $failed_job_tolerance, $max_retry_count, $can_be_empty, $priority, $meadow_type, $analysis_capacity) = - rearrange([qw(logic_name module parameters resource_class_id failed_job_tolerance max_retry_count can_be_empty priority meadow_type analysis_capacity) ], @_); - - $self->logic_name($logic_name) if($logic_name); - $self->module($module) if($module); - $self->parameters($parameters) if($parameters); - $self->resource_class_id($resource_class_id) if($resource_class_id); - $self->failed_job_tolerance($failed_job_tolerance) if($failed_job_tolerance); - $self->max_retry_count($max_retry_count) if($max_retry_count); - $self->can_be_empty($can_be_empty) if($can_be_empty); - $self->priority($priority) if($priority); - $self->meadow_type($meadow_type) if($meadow_type); - $self->analysis_capacity($analysis_capacity) if( defined($analysis_capacity) ); - - return $self; -} - - sub logic_name { my $self = shift; $self->{'_logic_name'} = shift if(@_); diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm b/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm index 0e0cafb7f..72839cb74 100644 --- a/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm +++ b/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm @@ -42,39 +42,13 @@ package Bio::EnsEMBL::Hive::AnalysisCtrlRule; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); + use Bio::EnsEMBL::Utils::Exception ('throw'); use Bio::EnsEMBL::Hive::URLFactory; use Bio::EnsEMBL::Hive::Extensions; -use base ( 'Bio::EnsEMBL::Hive::Storable' ); # inherit dbID(), adaptor() and new() methods - - -=head2 new - - Title : new - Usage : ...AnalysisCtrlRule->new; - Function: Constructor for empty AnalysisCtrlRule object - Returns : Bio::EnsEMBL::Hive::AnalysisCtrlRule - Args : none - -=cut - -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ( $condition_analysis_url, $ctrled_analysis_id ) = - rearrange( [ qw (CONDITION_ANALYSIS_URL CTRLED_ANALYSIS_ID) ], @_ ); - - # simple scalars: - $self->condition_analysis_url( $condition_analysis_url ) if(defined($condition_analysis_url)); - $self->ctrled_analysis_id( $ctrled_analysis_id ) if(defined($ctrled_analysis_id)); - - return $self; -} +use base ( 'Bio::EnsEMBL::Hive::Storable' ); =head2 ctrled_analysis_id diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm b/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm index 43f186860..e19a6fd17 100644 --- a/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm +++ b/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm @@ -38,43 +38,15 @@ package Bio::EnsEMBL::Hive::AnalysisJob; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); - use Bio::EnsEMBL::Hive::Utils ('stringify', 'destringify'); use Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor; use Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor; -use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods +use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods 'Bio::EnsEMBL::Hive::Params', # inherit param management functionality ); -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my($prev_job_id, $analysis_id, $input_id, $param_id_stack, $accu_id_stack, $worker_id, $status, $retry_count, $completed, $runtime_msec, $query_count, $semaphore_count, $semaphored_job_id) = - rearrange([qw(prev_job_id analysis_id input_id param_id_stack accu_id_stack worker_id status retry_count completed runtime_msec query_count semaphore_count semaphored_job_id) ], @_); - - $self->prev_job_id($prev_job_id) if(defined($prev_job_id)); - $self->analysis_id($analysis_id) if(defined($analysis_id)); - $self->input_id($input_id) if(defined($input_id)); - $self->param_id_stack($param_id_stack) if(defined($param_id_stack)); - $self->accu_id_stack($accu_id_stack) if(defined($accu_id_stack)); - $self->worker_id($worker_id) if(defined($worker_id)); - $self->status($status) if(defined($status)); - $self->retry_count($retry_count) if(defined($retry_count)); - $self->completed($completed) if(defined($completed)); - $self->runtime_msec($runtime_msec) if(defined($runtime_msec)); - $self->query_count($query_count) if(defined($query_count)); - $self->semaphore_count($semaphore_count) if(defined($semaphore_count)); - $self->semaphored_job_id($semaphored_job_id) if(defined($semaphored_job_id)); - - return $self; -} - - sub prev_job_id { my $self = shift; $self->{'_prev_job_id'} = shift if(@_); @@ -352,12 +324,12 @@ sub dataflow_output_id { my $fan_cache_this_branch = $self->fan_cache()->{$funnel_dataflow_rule_id} ||= []; push @$fan_cache_this_branch, map { Bio::EnsEMBL::Hive::AnalysisJob->new( - -prev_job_id => $self->dbID, - -analysis_id => $target_analysis_or_table->dbID, # expecting an Analysis - -input_id => $_, - -param_id_stack => $param_id_stack, - -accu_id_stack => $accu_id_stack, - # -semaphored_job_id => to be set when the $funnel_job has been stored + 'prev_job_id' => $self->dbID, + 'analysis_id' => $target_analysis_or_table->dbID, # expecting an Analysis + 'input_id' => $_, + 'param_id_stack' => $param_id_stack, + 'accu_id_stack' => $accu_id_stack, + # semaphored_job_id => to be set when the $funnel_job has been stored ) } @$output_ids_for_this_rule; } else { # either a semaphored funnel or a non-semaphored dataflow: @@ -373,13 +345,13 @@ sub dataflow_output_id { } else { my $funnel_job = Bio::EnsEMBL::Hive::AnalysisJob->new( - -prev_job_id => $self->dbID, - -analysis_id => $target_analysis_or_table->dbID, # expecting an Analysis - -input_id => $output_ids_for_this_rule->[0], - -param_id_stack => $param_id_stack, - -accu_id_stack => $accu_id_stack, - -semaphore_count => scalar(@$fan_jobs), # "pre-increase" the semaphore count before creating the dependent jobs - -semaphored_job_id => $self->semaphored_job_id(), # propagate parent's semaphore if any + 'prev_job_id' => $self->dbID, + 'analysis_id' => $target_analysis_or_table->dbID, # expecting an Analysis + 'input_id' => $output_ids_for_this_rule->[0], + 'param_id_stack' => $param_id_stack, + 'accu_id_stack' => $accu_id_stack, + 'semaphore_count' => scalar(@$fan_jobs), # "pre-increase" the semaphore count before creating the dependent jobs + 'semaphored_job_id' => $self->semaphored_job_id(), # propagate parent's semaphore if any ); my ($funnel_job_id) = @{ $job_adaptor->store_jobs_and_adjust_counters( [ $funnel_job ], 0) }; @@ -393,12 +365,12 @@ sub dataflow_output_id { } } else { # non-semaphored dataflow (but potentially propagating any existing semaphores) my @non_semaphored_jobs = map { Bio::EnsEMBL::Hive::AnalysisJob->new( - -prev_job_id => $self->dbID, - -analysis_id => $target_analysis_or_table->dbID, # expecting an Analysis - -input_id => $_, - -param_id_stack => $param_id_stack, - -accu_id_stack => $accu_id_stack, - -semaphored_job_id => $self->semaphored_job_id(), # propagate parent's semaphore if any + 'prev_job_id' => $self->dbID, + 'analysis_id' => $target_analysis_or_table->dbID, # expecting an Analysis + 'input_id' => $_, + 'param_id_stack' => $param_id_stack, + 'accu_id_stack' => $accu_id_stack, + 'semaphored_job_id' => $self->semaphored_job_id(), # propagate parent's semaphore if any ) } @$output_ids_for_this_rule; push @output_job_ids, @{ $job_adaptor->store_jobs_and_adjust_counters( \@non_semaphored_jobs, 0) }; diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm b/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm index fe3103c88..3843afbc6 100644 --- a/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm +++ b/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm @@ -37,11 +37,10 @@ package Bio::EnsEMBL::Hive::AnalysisStats; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); use Bio::EnsEMBL::Utils::Exception ('throw'); use Bio::EnsEMBL::Hive::Analysis; -use base ( 'Bio::EnsEMBL::Hive::Storable' ); # inherit dbID(), adaptor() and new() methods +use base ( 'Bio::EnsEMBL::Hive::Storable' ); ## Minimum amount of time in msec that a worker should run before reporting @@ -50,45 +49,6 @@ sub min_batch_time { return 2*60*1000; } - -sub new { - my $class = shift; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ( $analysis_id, $batch_size, $hive_capacity, $status, - $total_job_count, $semaphored_job_count, $ready_job_count, $done_job_count, $failed_job_count, $num_running_workers, $num_required_workers, - $behaviour, $input_capacity, $output_capacity, $avg_msec_per_job, $avg_input_msec_per_job, $avg_run_msec_per_job, $avg_output_msec_per_job, - $seconds_since_last_update, $sync_lock) = - rearrange([qw(analysis_id batch_size hive_capacity status - total_job_count semaphored_job_count ready_job_count done_job_count failed_job_count num_running_workers num_required_workers - behaviour input_capacity output_capacity avg_msec_per_job avg_input_msec_per_job avg_run_msec_per_job avg_output_msec_per_job - seconds_since_last_update sync_lock ) ], @_); - $self->analysis_id($analysis_id) if(defined($analysis_id)); - $self->batch_size($batch_size) if(defined($batch_size)); - $self->hive_capacity($hive_capacity) if(defined($hive_capacity)); - $self->status($status) if(defined($status)); - $self->total_job_count($total_job_count) if(defined($total_job_count)); - $self->semaphored_job_count($semaphored_job_count) if(defined($semaphored_job_count)); - $self->ready_job_count($ready_job_count) if(defined($ready_job_count)); - $self->done_job_count($done_job_count) if(defined($done_job_count)); - $self->failed_job_count($failed_job_count) if(defined($failed_job_count)); - $self->num_running_workers($num_running_workers) if(defined($num_running_workers)); - $self->num_required_workers($num_required_workers) if(defined($num_required_workers)); - $self->behaviour($behaviour) if(defined($behaviour)); - $self->input_capacity($input_capacity) if(defined($input_capacity)); - $self->output_capacity($output_capacity) if(defined($output_capacity)); - $self->avg_msec_per_job($avg_msec_per_job) if(defined($avg_msec_per_job)); - $self->avg_input_msec_per_job($avg_input_msec_per_job) if(defined($avg_input_msec_per_job)); - $self->avg_run_msec_per_job($avg_run_msec_per_job) if(defined($avg_run_msec_per_job)); - $self->avg_output_msec_per_job($avg_output_msec_per_job) if(defined($avg_output_msec_per_job)); - $self->seconds_since_last_update($seconds_since_last_update)if(defined($seconds_since_last_update)); # NB: this is an input_column_mapped field - $self->sync_lock($sync_lock) if(defined($sync_lock)); - - return $self; -} - - ## pre-settable storable object's getters/setters: sub analysis_id { # an alias diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/ObjectAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/ObjectAdaptor.pm index 75c16822a..c93bb1016 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/ObjectAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/ObjectAdaptor.pm @@ -69,7 +69,7 @@ sub objectify { # turn the hashref into an object (if only we could inline in Pe my $autoinc_id = $self->autoinc_id(); - return $self->object_class()->new( -adaptor => $self, map { ('-'.uc( ($_ eq $autoinc_id) ? 'dbID' : $_ ) => $hashref->{$_}) } keys %$hashref ); + return $self->object_class()->new( 'adaptor' => $self, map { ( ($_ eq $autoinc_id) ? 'dbID' : $_ ) => $hashref->{$_} } keys %$hashref ); } @@ -90,7 +90,7 @@ sub create_new { ? pop @_ # extra 'odd' parameter that would disrupt the hash integrity anyway : 0; # do not check by default - my $object = $self->object_class()->new( -adaptor => $self, @_ ); + my $object = $self->object_class()->new( 'adaptor' => $self, @_ ); return $self->store( $object, $check_presence_in_db_first ); } diff --git a/modules/Bio/EnsEMBL/Hive/DataflowRule.pm b/modules/Bio/EnsEMBL/Hive/DataflowRule.pm index 48e809b98..4c95dfc41 100644 --- a/modules/Bio/EnsEMBL/Hive/DataflowRule.pm +++ b/modules/Bio/EnsEMBL/Hive/DataflowRule.pm @@ -53,46 +53,12 @@ package Bio::EnsEMBL::Hive::DataflowRule; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); use Bio::EnsEMBL::Utils::Exception ('throw'); use Bio::EnsEMBL::Hive::Utils ('stringify'); use Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor; -use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods - ); - - -=head2 new - - Usage : Bio::EnsEMBL::Hive::DataflowRule->new(-from_analysis => $fromAnalysis, -to_analysis => $toAnalysis, -branch_code => $branch_code); - Function: Constructor for DataflowRule object - Returns : Bio::EnsEMBL::Hive::DataflowRule - Args : a rearrange-compatible hash - -=cut - -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ($fromAnalysis, $toAnalysis, $from_analysis_id, $branch_code, $funnel_dataflow_rule_id, $to_analysis_url, $input_id_template ) = - rearrange( [ qw (FROM_ANALYSIS TO_ANALYSIS FROM_ANALYSIS_ID BRANCH_CODE FUNNEL_DATAFLOW_RULE_ID TO_ANALYSIS_URL INPUT_ID_TEMPLATE) ], @_ ); - - # from objects: - $self->from_analysis( $fromAnalysis ) if(defined($fromAnalysis)); - $self->to_analysis( $toAnalysis ) if(defined($toAnalysis)); - - # simple scalars: - $self->from_analysis_id($from_analysis_id) if(defined($from_analysis_id)); - $self->to_analysis_url($to_analysis_url) if(defined($to_analysis_url)); - $self->branch_code($branch_code) if(defined($branch_code)); - $self->funnel_dataflow_rule_id($funnel_dataflow_rule_id) if(defined($funnel_dataflow_rule_id)); - $self->input_id_template($input_id_template) if(defined($input_id_template)); - - return $self; -} +use base ( 'Bio::EnsEMBL::Hive::Storable' ); =head2 branch_code diff --git a/modules/Bio/EnsEMBL/Hive/NakedTable.pm b/modules/Bio/EnsEMBL/Hive/NakedTable.pm index ca6b36737..a267e1a9a 100644 --- a/modules/Bio/EnsEMBL/Hive/NakedTable.pm +++ b/modules/Bio/EnsEMBL/Hive/NakedTable.pm @@ -32,24 +32,8 @@ package Bio::EnsEMBL::Hive::NakedTable; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); -use base ( 'Bio::EnsEMBL::Hive::Storable' ); # inherit dbID(), adaptor() and new() methods - - -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ($table_name, $insertion_method) = - rearrange([qw(table_name insertion_method) ], @_); - - $self->table_name($table_name) if(defined($table_name)); - $self->insertion_method($insertion_method) if(defined($insertion_method)); - - return $self; -} +use base ( 'Bio::EnsEMBL::Hive::Storable' ); sub table_name { diff --git a/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm b/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm index 5b0c2e48a..a26f62ebd 100644 --- a/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm +++ b/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm @@ -495,8 +495,8 @@ sub run { } my ($rc, $rc_newly_created) = $resource_class_adaptor->create_new( - defined($rc_id) ? (-DBID => $rc_id) : (), - -NAME => $rc_name, + defined($rc_id) ? ('dbID' => $rc_id) : (), + 'name' => $rc_name, 1 # check whether this ResourceClass was already present in the database ); $rc_id = $rc->dbID(); @@ -511,16 +511,16 @@ sub run { $resource_param_list = [ $resource_param_list ] unless(ref($resource_param_list)); # expecting either a scalar or a 2-element array $resource_description_adaptor->create_new( - -resource_class_id => $rc_id, - -meadow_type => $meadow_type, - -submission_cmd_args => $resource_param_list->[0], - -worker_cmd_args => $resource_param_list->[1], + resource_class_id => $rc_id, + meadow_type => $meadow_type, + submission_cmd_args => $resource_param_list->[0], + worker_cmd_args => $resource_param_list->[1], ); } } unless(my $default_rc = $resource_class_adaptor->fetch_by_name('default')) { warn "\tNB:'default' resource class is not in the database (did you forget to inherit from SUPER::resource_classes ?) - creating it for you\n"; - $resource_class_adaptor->create_new(-NAME => 'default'); + $resource_class_adaptor->create_new('name' => 'default'); } warn "Done.\n\n"; } @@ -579,36 +579,36 @@ sub run { die "'-parameters' has to be a hash" unless(ref($parameters_hash) eq 'HASH'); $analysis = Bio::EnsEMBL::Hive::Analysis->new( - -logic_name => $logic_name, - -module => $module, - -parameters => $parameters_hash, - -resource_class_id => $rc_id, - -failed_job_tolerance => $failed_job_tolerance, - -max_retry_count => $max_retry_count, - -can_be_empty => $can_be_empty, - -priority => $priority, - -meadow_type => $meadow_type, - -analysis_capacity => $analysis_capacity, + 'logic_name' => $logic_name, + 'module' => $module, + 'parameters' => $parameters_hash, + 'resource_class_id' => $rc_id, + 'failed_job_tolerance' => $failed_job_tolerance, + 'max_retry_count' => $max_retry_count, + 'can_be_empty' => $can_be_empty, + 'priority' => $priority, + 'meadow_type' => $meadow_type, + '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, - -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 - -total_job_count => 0, - -semaphored_job_count => 0, - -ready_job_count => 0, - -done_job_count => 0, - -failed_job_count => 0, - -num_running_workers => 0, - -num_required_workers => 0, - -behaviour => 'STATIC', - -input_capacity => 4, - -output_capacity => 4, - -sync_lock => 0, + 'analysis_id' => $analysis->dbID, + '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 + 'total_job_count' => 0, + 'semaphored_job_count' => 0, + 'ready_job_count' => 0, + 'done_job_count' => 0, + 'failed_job_count' => 0, + 'num_running_workers' => 0, + 'num_required_workers' => 0, + 'behaviour' => 'STATIC', + 'input_capacity' => 4, + 'output_capacity' => 4, + 'sync_lock' => 0, ); $analysis_stats_adaptor->store($stats); } @@ -616,9 +616,9 @@ sub run { # now create the corresponding jobs (if there are any): if($input_ids) { my @jobs = map { Bio::EnsEMBL::Hive::AnalysisJob->new( - -prev_job_id => undef, # these jobs are created by the initialization script, not by another job - -analysis_id => $analysis->dbID, - -input_id => $_, # input_ids are now centrally stringified in the AnalysisJob itself + 'prev_job_id' => undef, # these jobs are created by the initialization script, not by another job + 'analysis_id' => $analysis->dbID, + 'input_id' => $_, # input_ids are now centrally stringified in the AnalysisJob itself ) } @$input_ids; $job_adaptor->store_jobs_and_adjust_counters( \@jobs ); @@ -648,8 +648,8 @@ sub run { die "Could not fetch analysis '$condition_url' to create a control rule (in '".($analysis->logic_name)."')\n" unless defined $condition_analysis; } my $c_rule = Bio::EnsEMBL::Hive::AnalysisCtrlRule->new( - -condition_analysis_url => $condition_url, - -ctrled_analysis_id => $analysis->dbID, + 'condition_analysis_url' => $condition_url, + 'ctrled_analysis_id' => $analysis->dbID, ); $ctrl_rule_adaptor->store( $c_rule, 1 ); @@ -704,11 +704,11 @@ sub run { foreach my $input_id_template (@$input_id_template_list) { my $df_rule = Bio::EnsEMBL::Hive::DataflowRule->new( - -from_analysis => $analysis, - -to_analysis_url => $heir_url, - -branch_code => $branch_name_or_code, - -input_id_template => $input_id_template, - -funnel_dataflow_rule_id => $funnel_dataflow_rule_id, + 'from_analysis' => $analysis, + 'to_analysis_url' => $heir_url, + 'branch_code' => $branch_name_or_code, + 'input_id_template' => $input_id_template, + 'funnel_dataflow_rule_id' => $funnel_dataflow_rule_id, ); $dataflow_rule_adaptor->store( $df_rule, 1 ); diff --git a/modules/Bio/EnsEMBL/Hive/ResourceClass.pm b/modules/Bio/EnsEMBL/Hive/ResourceClass.pm index 4756ef78a..69603215b 100644 --- a/modules/Bio/EnsEMBL/Hive/ResourceClass.pm +++ b/modules/Bio/EnsEMBL/Hive/ResourceClass.pm @@ -39,26 +39,9 @@ package Bio::EnsEMBL::Hive::ResourceClass; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); - -use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods - ); +use base ( 'Bio::EnsEMBL::Hive::Storable' ); -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ($name) = - rearrange([qw(name) ], @_); - - $self->name($name) if($name); - - return $self; -} - - sub name { my $self = shift @_; diff --git a/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm b/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm index 0bc99694c..cc247607f 100644 --- a/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm +++ b/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm @@ -40,26 +40,8 @@ package Bio::EnsEMBL::Hive::ResourceDescription; use strict; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); -use base ( 'Bio::EnsEMBL::Hive::Storable' ); # inherit dbID(), adaptor() and new() methods - - -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my ($resource_class_id, $meadow_type, $submission_cmd_args, $worker_cmd_args) = - rearrange([qw(resource_class_id meadow_type submission_cmd_args worker_cmd_args) ], @_); - - $self->resource_class_id($resource_class_id); - $self->meadow_type($meadow_type); - $self->submission_cmd_args($submission_cmd_args); - $self->worker_cmd_args($worker_cmd_args); - - return $self; -} +use base ( 'Bio::EnsEMBL::Hive::Storable' ); sub resource_class_id { diff --git a/modules/Bio/EnsEMBL/Hive/Storable.pm b/modules/Bio/EnsEMBL/Hive/Storable.pm index f08d088d3..3d19da53f 100644 --- a/modules/Bio/EnsEMBL/Hive/Storable.pm +++ b/modules/Bio/EnsEMBL/Hive/Storable.pm @@ -44,15 +44,13 @@ package Bio::EnsEMBL::Hive::Storable; use strict; use warnings; -use Bio::EnsEMBL::Utils::Argument qw(rearrange); use Scalar::Util qw(weaken); =head2 new - Arg [-ADAPTOR] : Bio::EnsEMBL::Hive::DBSQL::BaseAdaptor - Arg [-dbID] : database internal id - Caller : internal calls + Args : pairs of ($method_name, $value) + Caller : ObjectAdaptor, AnalysisJob, URLFactory.pm, HiveGeneric_conf, seed_pipeline.pl, standaloneJob.pl Description : create a new Storable object Returntype : Bio::EnsEMBL::Hive::Storable Exceptions : Adaptor not a Bio::EnsEMBL::DBSQL::BaseAdaptor @@ -61,14 +59,15 @@ use Scalar::Util qw(weaken); =cut sub new { - my $caller = shift; - my $class = ref($caller) || $caller; + my $class = shift @_; my $self = bless {}, $class; - my ($adaptor, $dbID) = rearrange(['ADAPTOR', 'dbID'], @_); - $self->dbID( $dbID ) if defined( $dbID ); - $self->adaptor($adaptor) if defined( $adaptor ); + while(my ($method,$value) = splice(@_,0,2)) { + if(defined($value)) { + $self->$method($value); + } + } return $self; } diff --git a/modules/Bio/EnsEMBL/Hive/URLFactory.pm b/modules/Bio/EnsEMBL/Hive/URLFactory.pm index 3d096186a..bf8466e7a 100644 --- a/modules/Bio/EnsEMBL/Hive/URLFactory.pm +++ b/modules/Bio/EnsEMBL/Hive/URLFactory.pm @@ -118,17 +118,17 @@ sub fetch { } elsif($table_name eq 'accu') { return Bio::EnsEMBL::Hive::Accumulator->new( - -adaptor => $dba->get_AccumulatorAdaptor, - -struct_name => $tparam_name, - -signature_template => $tparam_value, + adaptor => $dba->get_AccumulatorAdaptor, + struct_name => $tparam_name, + signature_template => $tparam_value, ); } else { return Bio::EnsEMBL::Hive::NakedTable->new( - -adaptor => $dba->get_NakedTableAdaptor, - -table_name => $table_name, - $tparam_value ? (-insertion_method => $tparam_value) : () + adaptor => $dba->get_NakedTableAdaptor, + table_name => $table_name, + $tparam_value ? (insertion_method => $tparam_value) : () ); } } diff --git a/modules/Bio/EnsEMBL/Hive/Worker.pm b/modules/Bio/EnsEMBL/Hive/Worker.pm index 11ef740a1..f5e1f1b47 100644 --- a/modules/Bio/EnsEMBL/Hive/Worker.pm +++ b/modules/Bio/EnsEMBL/Hive/Worker.pm @@ -74,8 +74,6 @@ package Bio::EnsEMBL::Hive::Worker; use strict; use POSIX; -use Bio::EnsEMBL::Utils::Argument ('rearrange'); - use Bio::EnsEMBL::Hive::Analysis; use Bio::EnsEMBL::Hive::AnalysisStats; use Bio::EnsEMBL::Hive::Extensions; @@ -89,34 +87,7 @@ use Bio::EnsEMBL::Hive::Utils::RedirectStack; use Bio::EnsEMBL::Hive::Utils::Stopwatch; use Bio::EnsEMBL::Hive::Utils ('stringify'); -use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods - ); - - -sub new { - my $class = shift @_; - - my $self = $class->SUPER::new( @_ ); # deal with Storable stuff - - my($analysis_id, $meadow_type, $meadow_name, $host, $process_id, $resource_class_id, $work_done, $status, $born, $last_check_in, $died, $cause_of_death, $log_dir) = - rearrange([qw(analysis_id meadow_type meadow_name host process_id resource_class_id work_done status born last_check_in died cause_of_death log_dir) ], @_); - - $self->analysis_id($analysis_id) if(defined($analysis_id)); - $self->meadow_type($meadow_type) if(defined($meadow_type)); - $self->meadow_name($meadow_name) if(defined($meadow_name)); - $self->host($host) if(defined($host)); - $self->process_id($process_id) if(defined($process_id)); - $self->resource_class_id($resource_class_id) if(defined($resource_class_id)); - $self->work_done($work_done) if(defined($work_done)); - $self->status($status) if(defined($status)); - $self->born($born) if(defined($born)); - $self->last_check_in($last_check_in) if(defined($last_check_in)); - $self->died($died) if(defined($died)); - $self->cause_of_death($cause_of_death) if(defined($cause_of_death)); - $self->log_dir($log_dir) if(defined($log_dir)); - - return $self; -} +use base ( 'Bio::EnsEMBL::Hive::Storable' ); sub init { diff --git a/scripts/seed_pipeline.pl b/scripts/seed_pipeline.pl index 108a1ea9b..51b14d378 100755 --- a/scripts/seed_pipeline.pl +++ b/scripts/seed_pipeline.pl @@ -91,9 +91,9 @@ sub main { } my $job = Bio::EnsEMBL::Hive::AnalysisJob->new( - -prev_job_id => undef, # this job has been created by the initialization script, not by another job - -analysis_id => $analysis->dbID, - -input_id => destringify( $input_id ), # Make sure all job creations undergo re-stringification to avoid alternative "spellings" of the same input_id hash + 'prev_job_id' => undef, # this job has been created by the initialization script, not by another job + 'analysis_id' => $analysis->dbID, + 'input_id' => destringify( $input_id ), # Make sure all job creations undergo re-stringification to avoid alternative "spellings" of the same input_id hash ); my ($job_id) = @{ $hive_dba->get_AnalysisJobAdaptor->store_jobs_and_adjust_counters( [ $job ] ) }; diff --git a/scripts/standaloneJob.pl b/scripts/standaloneJob.pl index bfa766767..99038c82f 100755 --- a/scripts/standaloneJob.pl +++ b/scripts/standaloneJob.pl @@ -47,7 +47,7 @@ $runnable_object->debug($debug) if($debug); $runnable_object->execute_writes(not $no_write); -my $job = Bio::EnsEMBL::Hive::AnalysisJob->new( -dbID => -1 ); +my $job = Bio::EnsEMBL::Hive::AnalysisJob->new( 'dbID' => -1 ); unless($input_id) { my ($param_hash, $param_list) = parse_cmdline_options(); $input_id = stringify($param_hash); @@ -74,8 +74,8 @@ foreach my $branch_code (keys %$flow_into) { foreach my $input_id_template (@$input_id_template_list) { push @dataflow_rules, Bio::EnsEMBL::Hive::DataflowRule->new( - -to_analysis_url => $heir_url, - -input_id_template => $input_id_template, + 'to_analysis_url' => $heir_url, + 'input_id_template' => $input_id_template, ); } } -- GitLab