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

splitting the resource_description table into two

parent 5a40123e
......@@ -143,8 +143,8 @@ sub pipeline_wide_parameters {
sub resource_classes {
my ($self) = @_;
return {
0 => { -desc => 'default, 8h', 'LSF' => '' },
1 => { -desc => 'urgent', 'LSF' => '-q yesterday' },
1 => { -desc => 'default', 'LSF' => '' },
2 => { -desc => 'urgent', 'LSF' => '-q yesterday' },
};
}
......@@ -309,6 +309,7 @@ sub run {
}
my $hive_dba = new Bio::EnsEMBL::Hive::DBSQL::DBAdaptor(%{$self->o('pipeline_db')});
my $resource_class_adaptor = $hive_dba->get_ResourceClassAdaptor;
unless($job_topup) {
my $meta_container = $hive_dba->get_MetaContainer;
......@@ -323,19 +324,30 @@ sub run {
}
warn "Done.\n\n";
# pre-load the resource_description table
my $resource_description_adaptor = $hive_dba->get_ResourceDescriptionAdaptor;
warn "Loading the ResourceDescriptions ...\n";
# pre-load resource_class and resource_description tables:
my $resource_description_adaptor = $hive_dba->get_ResourceDescriptionAdaptor;
warn "Loading the Resources ...\n";
my $resource_classes = $self->resource_classes;
my %seen_resource_name = ();
while( my($rc_id, $mt2param) = each %$resource_classes ) {
my $description = delete $mt2param->{-desc};
my $name = delete $mt2param->{-desc};
if(!$name or $seen_resource_name{$name}++) {
die "Every resource has to have a unique description, please fix the PipeConfig file";
}
warn "Creating resource_class '$name'($rc_id).\n";
$resource_class_adaptor->create_new(
-DBID => $rc_id,
-NAME => $name,
);
while( my($meadow_type, $xparams) = each %$mt2param ) {
$resource_description_adaptor->create_new(
-RC_ID => $rc_id,
-MEADOW_TYPE => $meadow_type,
-PARAMETERS => $xparams,
-DESCRIPTION => $description,
);
}
}
......@@ -347,8 +359,8 @@ sub run {
my %seen_logic_name = ();
foreach my $aha (@{$self->pipeline_analyses}) {
my ($logic_name, $module, $parameters_hash, $program_file, $input_ids, $blocked, $batch_size, $hive_capacity, $failed_job_tolerance, $max_retry_count, $can_be_empty, $rc_id, $priority) =
rearrange([qw(logic_name module parameters program_file input_ids blocked batch_size hive_capacity failed_job_tolerance max_retry_count can_be_empty rc_id priority)], %$aha);
my ($logic_name, $module, $parameters_hash, $program_file, $input_ids, $blocked, $batch_size, $hive_capacity, $failed_job_tolerance, $max_retry_count, $can_be_empty, $rc_id, $rc_name, $priority) =
rearrange([qw(logic_name module parameters program_file input_ids blocked batch_size hive_capacity failed_job_tolerance max_retry_count can_be_empty rc_id rc_name priority)], %$aha);
unless($logic_name) {
die "logic_name' must be defined in every analysis";
......@@ -374,6 +386,13 @@ sub run {
warn "Creating analysis '$logic_name'.\n";
if($rc_id) {
warn "(-rc_id => $rc_id) syntax is deprecated, please start using (-rc_name => 'your_resource_class_name')";
} elsif($rc_name) {
my $rc = $resource_class_adaptor->fetch_by_name($rc_name ) or die "Could not fetch resource with name '$rc_name', please check the resource_classes() method of your PipeConfig";
$rc_id = $rc->dbID();
}
$analysis = Bio::EnsEMBL::Analysis->new(
# -db => '',
# -db_file => '',
......
......@@ -14,7 +14,6 @@
rc_id int(10) unsigned DEFAULT 0 NOT NULL,
meadow_type varchar(40) NOT NULL,
parameters varchar(255) DEFAULT '' NOT NULL,
description varchar(255),
PRIMARY KEY(rc_id, meadow_type)
) ENGINE=InnoDB;
......@@ -36,14 +35,13 @@ sub new {
my $self = bless {}, $class;
my ($adaptor, $rc_id, $meadow_type, $parameters ,$description) =
rearrange([qw(adaptor rc_id meadow_type parameters description) ], @_);
my ($adaptor, $rc_id, $meadow_type, $parameters) =
rearrange([qw(adaptor rc_id meadow_type parameters) ], @_);
$self->adaptor($adaptor) if(defined($adaptor));
$self->rc_id($rc_id);
$self->meadow_type($meadow_type);
$self->parameters($parameters);
$self->description($description);
return $self;
}
......@@ -88,19 +86,10 @@ sub parameters {
return $self->{'_parameters'};
}
sub description {
my $self = shift @_;
if(@_) {
$self->{'_description'} = shift @_;
}
return $self->{'_description'};
}
sub to_string {
my $self = shift @_;
return (ref($self).': '.join(', ', map { $_.'="'.$self->$_().'"' } qw(rc_id meadow_type parameters description) ));
return (ref($self).': '.join(', ', map { $_.'="'.$self->$_().'"' } qw(rc_id meadow_type parameters) ));
}
1;
......
-- Split the former resource_description table into two:
-- Create a new auto-incrementing table:
DROP TABLE IF EXISTS resource_class;
CREATE TABLE resource_class (
resource_class_id int(10) unsigned NOT NULL AUTO_INCREMENT, # unique internal id
name varchar(40) NOT NULL,
PRIMARY KEY(resource_class_id),
UNIQUE KEY(name)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
-- Populate it with data from resource_description (unfortunately, id<=0 will be ignored - let's hope they were not used!)
INSERT INTO resource_class (resource_class_id, name) SELECT rc_id, description from resource_description WHERE rc_id>0;
-- The population command may crash if the original "description" contained non-unique values -
-- just fix the original table and reapply the patch.
-- Now drop the name/description column:
ALTER TABLE resource_description DROP COLUMN description;
......@@ -333,9 +333,17 @@ CREATE TABLE resource_description (
rc_id int(10) unsigned DEFAULT 0 NOT NULL,
meadow_type varchar(40) NOT NULL,
parameters varchar(255) DEFAULT '' NOT NULL,
description varchar(255),
PRIMARY KEY(rc_id, meadow_type)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
CREATE TABLE resource_class (
resource_class_id int(10) unsigned NOT NULL AUTO_INCREMENT, # unique internal id
name varchar(40) NOT NULL,
PRIMARY KEY(resource_class_id),
UNIQUE KEY(name)
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
......
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