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

allow jobs' dataflow rules to be overridden

parent 0b44297b
......@@ -28,6 +28,7 @@ package Bio::EnsEMBL::Hive::AnalysisJob;
use strict;
use Bio::EnsEMBL::Utils::Argument; # import 'rearrange()'
use Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor;
use base ('Bio::EnsEMBL::Hive::Params');
......@@ -73,6 +74,19 @@ sub input_id {
return $self->{'_input_id'};
}
sub dataflow_rules { # if ever set will prevent the Job from fetching rules from the DB
my $self = shift @_;
my $branch_name_or_code = shift @_;
my $branch_code = Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor::branch_name_2_code($branch_name_or_code);
$self->{'_dataflow_rules'}{$branch_code} = shift if(@_);
return $self->{'_dataflow_rules'}
? ( $self->{'_dataflow_rules'}{$branch_code} || [] )
: $self->adaptor->db->get_DataflowRuleAdaptor->fetch_all_by_from_analysis_id_and_branch_code($self->analysis_id, $branch_code);
}
sub worker_id {
my $self = shift;
$self->{'_worker_id'} = shift if(@_);
......@@ -243,14 +257,14 @@ sub dataflow_output_id {
# However if nothing is supplied, semaphored_job_id will be propagated from the parent job:
my $semaphored_job_id = $create_job_options->{'-semaphored_job_id'} ||= $self->semaphored_job_id();
my $dataflow_rule_adaptor = $self->adaptor->db->get_DataflowRuleAdaptor;
# map branch names to numbers:
my $branch_code = Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor::branch_name_2_code($branch_name_or_code);
# if branch_code is set to 1 (explicitly or impliticly), turn off automatic dataflow:
$self->autoflow(0) if($dataflow_rule_adaptor->branch_name_2_code($branch_name_or_code)==1);
$self->autoflow(0) if($branch_code == 1);
my @output_job_ids = ();
my $rules = $dataflow_rule_adaptor->fetch_all_by_from_analysis_id_and_branch_code($self->analysis_id, $branch_name_or_code);
foreach my $rule (@$rules) {
foreach my $rule (@{ $self->dataflow_rules( $branch_name_or_code ) }) {
my $output_ids_for_this_rule;
if(my $template = $rule->input_id_template()) {
......
......@@ -33,6 +33,7 @@ my $process = $runnable_module->new();
my $job = Bio::EnsEMBL::Hive::AnalysisJob->new();
my ($param_hash, $param_list) = parse_cmdline_options();
$job->param_init( 1, $process->param_defaults(), $param_hash );
$job->dataflow_rules( 1, [] ); # dataflow switched off by default
my $input_id = stringify($param_hash);
$job->input_id( $input_id );
......@@ -76,13 +77,19 @@ __DATA__
=head1 USAGE EXAMPLES
# Just run a job with default parameters:
# Run a job with default parameters, specify module by its package name:
standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::FailureTest
# Run the same job with default parameters, but specify module by its relative filename:
standaloneJob.pl RunnableDB/FailureTest.pm
# Run a job and re-define some of the default parameters:
standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::FailureTest -time_RUN=2 -time_WRITE_OUTPUT=3 -state=WRITE_OUTPUT -value=2
standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::SystemCmd -cmd 'ls -l'
# Run a job and re-define its 'db_conn' parameter to allow it to perform some database-related operations:
standaloneJob.pl RunnableDB/SqlCmd.pm -db_conn mysql://ensadmin:ensembl@127.0.0.1:2912/lg4_compara_families_63 -sql 'INSERT INTO meta (meta_key,meta_value) VALUES ("hello", "world2")'
# Run a job with given parameters, but skip the write_output() step:
standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::FailureTest -no_write -time_RUN=2 -time_WRITE_OUTPUT=3 -state=WRITE_OUTPUT -value=2
......
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