<commit_before>=head1 LICENSE

Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=cut

package EnsEMBL::Web::RunnableDB;

### Parent class for all the runnabledb classes for different tools
### The child modules of this class are not used by the webserver directly, but are used by hive to actually run the bsubed jobs.
### Error handling: In any child classes, "throw exception('HiveException', 'message ..')" to pass them back to the web server

use strict;
use warnings;

use Data::Dumper;
use DBI;
use IO::Compress::Gzip qw(gzip $GzipError);
use Scalar::Util qw(blessed);
use Storable qw(nfreeze);

use EnsEMBL::Web::Exceptions;
use EnsEMBL::Web::Tools::FileSystem qw(copy_files);
use EnsEMBL::Web::Tools::FileHandler qw(file_put_contents);

use parent qw(Bio::EnsEMBL::Hive::Process);

sub param_required {
  ## @overrides
  ## Throws a HiveException in case a param is not defined and is required
  my ($self, $param_name) = @_;

  throw exception('HiveException', "Param '$param_name' is not defined.") unless $self->param_is_defined($param_name);

  return $self->param($param_name);
}

sub work_dir {
  ## Gets/sets the work directory
  ## @return Directory path
  my $self = shift;

  $self->param('work_dir', shift) if @_;

  my $work_dir = $self->param_required('work_dir');

  throw exception('HiveException', 'Work directory could not be found.')  unless -d $work_dir;

  return $work_dir;
}<commit_msg>Redirect all warnings to hive db's log_message tbl<commit_after>=head1 LICENSE

Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=cut

package EnsEMBL::Web::RunnableDB;

### Parent class for all the runnabledb classes for different tools
### The child modules of this class are not used by the webserver directly, but are used by hive to actually run the bsubed jobs.
### Error handling: In any child classes, "throw exception('HiveException', 'message ..')" to pass them back to the web server

use strict;
use warnings;

use Data::Dumper;
use DBI;
use IO::Compress::Gzip qw(gzip $GzipError);
use Scalar::Util qw(blessed);
use Storable qw(nfreeze);

use EnsEMBL::Web::Exceptions;
use EnsEMBL::Web::Tools::FileSystem qw(copy_files);
use EnsEMBL::Web::Tools::FileHandler qw(file_put_contents);

use parent qw(Bio::EnsEMBL::Hive::Process);

sub new {
  ## @override
  ## Redirect all warnings from now onwards to hive database's log_message table
  my $self = shift->SUPER::new(@_);
  $SIG{'__WARN__'} = sub {
    $self->warning($_[0]);
  };
  return $self;
}

sub param_required {
  ## @override
  ## Throws a HiveException in case a param is not defined and is required
  my ($self, $param_name) = @_;

  throw exception('HiveException', "Param '$param_name' is not defined.") unless $self->param_is_defined($param_name);

  return $self->param($param_name);
}

sub work_dir {
  ## Gets/sets the work directory
  ## @return Directory path
  my $self = shift;

  $self->param('work_dir', shift) if @_;

  my $work_dir = $self->param_required('work_dir');

  throw exception('HiveException', 'Work directory could not be found.')  unless -d $work_dir;

  return $work_dir;
}
{'fraction_non_alphanumeric': 0.10339142722562411, 'fraction_numerical': 0.006358926048045219, 'mean_word_length': 5.007072135785007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5619355', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1254, 'n_words': 499}