Commit 9b187b1b authored by Leo Gordon's avatar Leo Gordon
Browse files

AnalysisJob.analysis_id is substituted by autoloaded version that also...

AnalysisJob.analysis_id is substituted by autoloaded version that also provides .analysis() ; also dropped print_job() method
parent 05026db0
......@@ -47,18 +47,19 @@ use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new(
);
=head1 AUTOLOADED
analysis_id / analysis
=cut
sub prev_job_id {
my $self = shift;
$self->{'_prev_job_id'} = shift if(@_);
return $self->{'_prev_job_id'};
}
sub analysis_id {
my $self = shift;
$self->{'_analysis_id'} = shift if(@_);
return $self->{'_analysis_id'};
}
sub input_id {
my $self = shift;
if(@_) {
......@@ -325,7 +326,7 @@ 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
'analysis' => $target_analysis_or_table, # expecting an Analysis
'input_id' => $_,
'param_id_stack' => $param_id_stack,
'accu_id_stack' => $accu_id_stack,
......@@ -346,7 +347,7 @@ 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
'analysis' => $target_analysis_or_table, # expecting an Analysis
'input_id' => $output_ids_for_this_rule->[0],
'param_id_stack' => $param_id_stack,
'accu_id_stack' => $accu_id_stack,
......@@ -366,7 +367,7 @@ 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
'analysis' => $target_analysis_or_table, # expecting an Analysis
'input_id' => $_,
'param_id_stack' => $param_id_stack,
'accu_id_stack' => $accu_id_stack,
......@@ -385,22 +386,13 @@ sub dataflow_output_id {
sub toString {
my $self = shift @_;
return 'Job '.$self->dbID." input_id='".$self->input_id."', retry=".$self->retry_count;
}
my $analysis_label = $self->analysis
? ( $self->analysis->logic_name.'('.$self->analysis_id.')' )
: '(NULL)';
sub print_job {
my $self = shift;
my $logic_name = $self->adaptor()
? $self->adaptor->db->get_AnalysisAdaptor->fetch_by_dbID($self->analysis_id)->logic_name()
: '';
printf("job_id=%d %35s(%5d) retry=%d input_id='%s'\n",
$self->dbID,
$logic_name,
$self->analysis_id,
$self->retry_count,
$self->input_id);
return 'Job '.$self->dbID." analysis=$analysis_label, input_id='".$self->input_id."', status=".$self->status.", retry_count=".$self->retry_count;
}
1;
......@@ -602,7 +602,7 @@ sub run {
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,
'analysis' => $analysis,
'input_id' => $_, # input_ids are now centrally stringified in the AnalysisJob itself
) } @$input_ids;
......
......@@ -206,7 +206,7 @@ sub main {
if($job_id_for_output) {
printf("===== job output\n");
my $job = $self->{'dba'}->get_AnalysisJobAdaptor->fetch_by_dbID($job_id_for_output);
$job->print_job();
print $job->toString. "\n";
}
if(my $reset_logic_name = $reset_all_jobs_for_analysis || $reset_failed_jobs_for_analysis) {
......@@ -280,7 +280,7 @@ sub main {
my $failed_job_list = $self->{'dba'}->get_AnalysisJobAdaptor->fetch_all_by_analysis_id_status($analysis && $analysis->dbID, 'FAILED');
foreach my $job (@{$failed_job_list}) {
$job->print_job();
print $job->toString. "\n";
}
}
}
......
......@@ -92,7 +92,7 @@ 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,
'analysis' => $analysis,
'input_id' => destringify( $input_id ), # Make sure all job creations undergo re-stringification to avoid alternative "spellings" of the same input_id hash
);
......
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