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

introducing semantic versions for the Meadow interface

parent 0d1dd4c9
......@@ -39,6 +39,37 @@ use warnings;
use base ('Bio::EnsEMBL::Hive::Configurable');
# -------------------------------------- <versioning of the Meadow interface> -------------------------------------------------------
our $MEADOW_MAJOR_VERSION = '1'; # Make sure you change this number whenever an incompatible change is introduced
sub get_meadow_major_version {
return $MEADOW_MAJOR_VERSION; # fetch the declared $MEADOW_MAJOR_VERSION of the interface
}
sub get_meadow_version {
my $self = shift @_;
return $self->VERSION // 'unversioned'; # fetch the declared $VERSION of a specific Meadow implementation
}
sub check_version_compatibility {
my $self = shift @_;
my $mmv = $self->get_meadow_major_version();
my $mv = $self->get_meadow_version();
# warn "$self : MVC='$mmv', MV='$mv'\n";
return ($mv=~/^$mmv\./) ? 1 : 0;
}
# -------------------------------------- </versioning of the Meadow interface> ------------------------------------------------------
sub new {
my ($class, $config) = @_;
......
......@@ -37,6 +37,11 @@ use Sys::Hostname;
use base ('Bio::EnsEMBL::Hive::Meadow');
our $VERSION = '1.0'; # Semantic version of the Meadow interface:
# change the Major version whenever an incompatible change is introduced,
# change the Minor version whenever the interface is extended, but compatibility is retained.
sub name { # also called to check for availability; for the moment assume LOCAL meadow is always available
return (split(/\./, hostname))[0]; # only take the first name
......
......@@ -38,6 +38,11 @@ use Bio::EnsEMBL::Hive::Utils ('split_for_bash');
use base ('Bio::EnsEMBL::Hive::Meadow');
our $VERSION = '1.0'; # Semantic version of the Meadow interface:
# change the Major version whenever an incompatible change is introduced,
# change the Minor version whenever the interface is extended, but compatibility is retained.
sub name { # also called to check for availability; assume LSF is available if LSF cluster_name can be established
my $mcni = 'My cluster name is';
my $cmd = "lsid 2>/dev/null | grep '$mcni'";
......
......@@ -55,6 +55,8 @@ package Bio::EnsEMBL::Hive::Utils;
use strict;
use warnings;
use Data::Dumper;
use Bio::EnsEMBL::Hive::Meadow;
use Bio::EnsEMBL::Hive::Valley;
use Bio::EnsEMBL::Hive::Version;
use Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor;
use Bio::EnsEMBL::Hive::DBSQL::DBConnection;
......@@ -358,6 +360,22 @@ sub go_figure_dbc {
sub report_versions {
print "CodeVersion\t".Bio::EnsEMBL::Hive::Version->get_code_version()."\n";
print "CompatibleHiveDatabaseSchemaVersion\t".Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor->get_code_sql_schema_version()."\n";
print "MeadowInterfaceVersion\t".Bio::EnsEMBL::Hive::Meadow->get_meadow_major_version()."\n";
my $meadow_class_path = Bio::EnsEMBL::Hive::Valley->meadow_class_path;
foreach my $meadow_class (@{ Bio::EnsEMBL::Hive::Valley->loaded_meadow_drivers }) {
$meadow_class=~/^${meadow_class_path}::(.+)$/;
my $meadow_driver = $1;
my $meadow_version = $meadow_class->get_meadow_version;
my $compatible = $meadow_class->check_version_compatibility;
my $status = $compatible
? ( $meadow_class->name
? 'available'
: 'unavailable'
)
: 'incompatible';
print '',join("\t", 'Meadow::'.$meadow_driver, $meadow_version, $status)."\n";
}
}
1;
......
......@@ -49,6 +49,19 @@ sub meadow_class_path {
}
our $_loaded_meadow_drivers;
sub loaded_meadow_drivers {
unless( $_loaded_meadow_drivers ) {
foreach my $meadow_class (@{ $_loaded_meadow_drivers = Bio::EnsEMBL::Hive::Utils::find_submodules( meadow_class_path() ) }) {
eval "require $meadow_class";
}
}
return $_loaded_meadow_drivers;
}
sub new {
my ($class, $config, $default_meadow_type, $pipeline_name) = @_;
......@@ -59,10 +72,12 @@ sub new {
my $amh = $self->available_meadow_hash( {} );
# make sure modules are loaded and available ones are checked prior to setting the current one
foreach my $meadow_class (@{ find_submodules( $self->meadow_class_path ) }) {
eval "require $meadow_class";
if($meadow_class->name) {
# make sure modules are loaded and available ones are checked prior to setting the current one:
foreach my $meadow_class (@{ $self->loaded_meadow_drivers }) {
if( $meadow_class->check_version_compatibility
and $meadow_class->name) { # the assumption is if we can get a name, it is available
my $meadow_object = $meadow_class->new( $config );
$meadow_object->pipeline_name( $pipeline_name ) if($pipeline_name);
......
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