Commit 76a6e820 authored by Leo Gordon's avatar Leo Gordon
Browse files

rationalized reg_conf/reg_alias names and fixed the way they are passed into...

rationalized reg_conf/reg_alias names and fixed the way they are passed into runWorker and used in it
parent 1678fc1f
......@@ -56,32 +56,33 @@ sub main {
my $reset_job_id = 0;
my $reset_all_jobs_for_analysis = 0;
$self->{'reg_conf'} = undef;
$self->{'reg_alias'} = undef;
$self->{'sleep_minutes'} = 1;
# $self->{'overdue_minutes'} = 60; # which means one hour
$self->{'verbose_stats'} = 1;
$self->{'reg_name'} = 'hive';
$self->{'maximise_concurrency'} = 0;
$self->{'retry_throwing_jobs'} = undef;
$self->{'hive_output_dir'} = undef;
GetOptions(
# connection parameters
'conf=s' => \$conf_file,
'regfile=s' => \$self->{'reg_file'},
'regname=s' => \$self->{'reg_name'},
'url=s' => \$self->{'url'},
'host|dbhost=s' => \$self->{'db_conf'}->{'-host'},
'port|dbport=i' => \$self->{'db_conf'}->{'-port'},
'user|dbuser=s' => \$self->{'db_conf'}->{'-user'},
'password|dbpass=s' => \$self->{'db_conf'}->{'-pass'},
'database|dbname=s' => \$self->{'db_conf'}->{'-dbname'},
'conf=s' => \$conf_file,
'reg_conf|regfile=s' => \$self->{'reg_conf'},
'reg_alias|regname=s'=> \$self->{'reg_alias'},
'url=s' => \$self->{'url'},
'host|dbhost=s' => \$self->{'db_conf'}->{'-host'},
'port|dbport=i' => \$self->{'db_conf'}->{'-port'},
'user|dbuser=s' => \$self->{'db_conf'}->{'-user'},
'password|dbpass=s' => \$self->{'db_conf'}->{'-pass'},
'database|dbname=s' => \$self->{'db_conf'}->{'-dbname'},
# loop control
'run' => \$run,
'loop' => \$loopit,
'max_loops=i' => \$max_loops,
'keep_alive' => \$keep_alive,
'job_id|run_job_id=i' => \$self->{'run_job_id'},
'job_id|run_job_id=i'=> \$self->{'run_job_id'},
'sleep=f' => \$self->{'sleep_minutes'},
# meadow control
......@@ -105,7 +106,6 @@ sub main {
'sync' => \$sync,
'dead' => \$check_for_dead,
'killworker=i' => \$kill_worker_id,
# 'overdue' => \$self->{'overdue_minutes'},
'alldead' => \$all_dead,
'no_analysis_stats' => \$self->{'no_analysis_stats'},
'verbose_stats=i' => \$self->{'verbose_stats'},
......@@ -136,9 +136,9 @@ sub main {
}
}
if($self->{'reg_file'}) {
Bio::EnsEMBL::Registry->load_all($self->{'reg_file'});
$self->{'dba'} = Bio::EnsEMBL::Registry->get_DBAdaptor($self->{'reg_name'}, 'hive');
if($self->{'reg_conf'} and $self->{'reg_alias'}) {
Bio::EnsEMBL::Registry->load_all($self->{'reg_conf'});
$self->{'dba'} = Bio::EnsEMBL::Registry->get_DBAdaptor($self->{'reg_alias'}, 'hive');
} elsif($self->{'url'}) {
$self->{'dba'} = Bio::EnsEMBL::Hive::URLFactory->fetch($self->{'url'}) || die("Unable to connect to $self->{'url'}\n");
} elsif ( $self->{'db_conf'}->{'-host'}
......@@ -147,7 +147,7 @@ sub main {
$self->{'dba'} = new Bio::EnsEMBL::Hive::DBSQL::DBAdaptor(%{$self->{'db_conf'}});
$self->{'url'} = $self->{'dba'}->dbc->url;
} else {
print "\nERROR : Connection parameters (regfile+regname, url or dbhost+dbuser+dbname) need to be specified\n\n";
print "\nERROR : Connection parameters (reg_conf+reg_alias, url or dbhost+dbuser+dbname) need to be specified\n\n";
script_usage(1);
}
......@@ -318,7 +318,18 @@ sub show_failed_workers { # does not seem to be used
sub generate_worker_cmd {
my ($self) = @_;
my $worker_cmd = 'runWorker.pl'; # -bk '. $self->{'meadow'}->type();
my $worker_cmd = 'runWorker.pl';
if ($self->{'reg_conf'}) { # if reg_conf is defined, we have to pass it anyway, regardless of whether it is used to connect to the Hive database or not:
$worker_cmd .= ' -reg_conf '. $self->{'reg_conf'};
}
if ($self->{'reg_alias'}) { # then we pass the connection parameters:
$worker_cmd .= ' -reg_alias '. $self->{'reg_alias'};
} else {
$worker_cmd .= ' -url '. $self->{'url'};
}
if ($self->{'run_job_id'}) {
$worker_cmd .= " -job_id ".$self->{'run_job_id'};
} else {
......@@ -329,12 +340,6 @@ sub generate_worker_cmd {
}
}
if ($self->{'reg_file'}) {
$worker_cmd .= ' -regfile '. $self->{'reg_file'} .' -regname '. $self->{'reg_name'};
} else {
$worker_cmd .= ' -url '. $self->{'url'};
}
return $worker_cmd;
}
......@@ -476,8 +481,8 @@ __DATA__
=head2 Connection parameters
-conf <path> : config file describing db connection
-regfile <path> : path to a Registry configuration file
-regname <string> : species/alias name for the Hive DBAdaptor
-reg_conf <path> : path to a Registry configuration file
-reg_alias <string> : species/alias name for the Hive DBAdaptor
-url <url string> : url defining where hive database is located
-host <machine> : mysql database host <machine>
-port <port#> : mysql port number
......
......@@ -28,21 +28,21 @@ sub run {
sub _options {
my ($self) = @_;
GetOptions(
'regfile=s' => \$self->{reg_file},
'regname=s' => \$self->{reg_name},
'url=s' => \$self->{url},
'host|dbhost=s' => \$self->{db_conf}->{'-host'},
'port|dbport=i' => \$self->{db_conf}->{'-port'},
'user|dbuser=s' => \$self->{db_conf}->{'-user'},
'password|dbpass=s' => \$self->{db_conf}->{'-pass'},
'database|dbname=s' => \$self->{db_conf}->{'-dbname'},
'reg_conf|regfile=s' => \$self->{'reg_conf'},
'reg_alias|regname=s' => \$self->{'reg_alias'},
'url=s' => \$self->{url},
'host|dbhost=s' => \$self->{db_conf}->{'-host'},
'port|dbport=i' => \$self->{db_conf}->{'-port'},
'user|dbuser=s' => \$self->{db_conf}->{'-user'},
'password|dbpass=s' => \$self->{db_conf}->{'-pass'},
'database|dbname=s' => \$self->{db_conf}->{'-dbname'},
'f|format=s' => \$self->{format},
'o|output=s' => \$self->{output},
'config' => \$self->{config},
'f|format=s' => \$self->{format},
'o|output=s' => \$self->{output},
'config' => \$self->{config},
'h|help' => \$self->{help},
'm|man' => \$self->{man},
'h|help' => \$self->{help},
'm|man' => \$self->{man},
);
return;
}
......@@ -59,9 +59,9 @@ sub _process_options {
}
#Check for DB
if($self->{reg_file}) {
Bio::EnsEMBL::Registry->load_all($self->{reg_file});
$self->{dba} = Bio::EnsEMBL::Registry->get_DBAdaptor($self->{reg_name}, 'hive');
if($self->{'reg_conf'} and $self->{'reg_alias'}) {
Bio::EnsEMBL::Registry->load_all($self->{'reg_conf'});
$self->{dba} = Bio::EnsEMBL::Registry->get_DBAdaptor($self->{'reg_alias'}, 'hive');
}
elsif($self->{url}) {
$self->{dba} = Bio::EnsEMBL::Hive::URLFactory->fetch($self->{url}) || die("Unable to connect to $self->{url}\n");
......@@ -73,7 +73,7 @@ sub _process_options {
}
else {
pod2usage({
-message => 'ERROR: Connection parameters (regfile+regname, url or dbhost+dbuser+dbname) need to be specified',
-message => 'ERROR: Connection parameters (reg_conf+reg_alias, url or dbhost+dbuser+dbname) need to be specified',
-exitvalue => 1,
-verbose => 1
});
......@@ -173,11 +173,11 @@ Perl file which will return a Hash when evaluated. The hash is merged into the
default option set for configuring the graphs produced. See
L<Bio::EnsEMBL::Hive::Utils::Graph::Config>
=item B<-regfile>
=item B<-reg_conf>
path to a Registry configuration file
=item B<-regname>
=item B<-reg_alias>
species/alias name for the Hive DBAdaptor
......@@ -235,7 +235,7 @@ $Author: lg4 $
=head1 VERSION
$Revision: 1.4 $
$Revision: 1.5 $
=head1 REQUIREMENTS
......
......@@ -68,16 +68,19 @@ if ($help) { script_usage(0); }
parse_conf($conf_file);
my $DBA;
if($reg_conf) {
if($reg_conf) { # if reg_conf is defined, we load it regardless of whether it is used to connect to the Hive database or not:
Bio::EnsEMBL::Registry->load_all($reg_conf);
$DBA = Bio::EnsEMBL::Registry->get_DBAdaptor($reg_alias || 'hive', 'hive');
}
my $DBA;
if($reg_alias) {
$DBA = Bio::EnsEMBL::Registry->get_DBAdaptor($reg_alias, 'hive');
} elsif($url) {
$DBA = Bio::EnsEMBL::Hive::URLFactory->fetch($url) or die "Unable to connect to '$url'\n";
} elsif ($db_conf->{'-host'} and $db_conf->{'-user'} and $db_conf->{'-dbname'}) {
$DBA = new Bio::EnsEMBL::Hive::DBSQL::DBAdaptor(%$db_conf);
} else {
print "\nERROR : Connection parameters (regfile+regname, url or dbhost+dbuser+dbname) need to be specified\n\n";
print "\nERROR : Connection parameters (reg_conf+reg_alias, url or dbhost+dbuser+dbname) need to be specified\n\n";
script_usage(1);
}
......@@ -207,8 +210,8 @@ __DATA__
=head2 Connection parameters:
-conf <path> : config file describing db connection
-regfile <path> : path to a Registry configuration file
-regname <string> : species/alias name for the Hive DBAdaptor
-reg_conf <path> : path to a Registry configuration file
-reg_alias <string> : species/alias name for the Hive DBAdaptor
-url <url string> : url defining where database is located
-host <machine> : mysql database host <machine>
-port <port#> : mysql port number
......
......@@ -95,9 +95,10 @@ __DATA__
=head1 SCRIPT-SPECIFIC OPTIONS
-help : print this help
-debug <level> : turn on debug messages at <level>
-no_write : skip the execution of write_output() step this time
-help : print this help
-debug <level> : turn on debug messages at <level>
-no_write : skip the execution of write_output() step this time
-reg_conf <path> : load registry entries from the given file (these entries may be needed by the RunnableDB itself)
NB: all other options will be passed to the runnable (leading dashes removed) and will constitute the parameters for the job.
......
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