Skip to content

Commit

Permalink
Merge 012612b into ec1d691
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstranneheim committed Jan 10, 2021
2 parents ec1d691 + 012612b commit 643a8b1
Show file tree
Hide file tree
Showing 135 changed files with 2,798 additions and 3,748 deletions.
82 changes: 82 additions & 0 deletions lib/MIP/Active_parameter.pm
Expand Up @@ -42,6 +42,7 @@ BEGIN {
get_not_allowed_temp_dirs
get_package_env_attributes
get_package_env_cmds
get_recipe_resources
get_user_supplied_pedigree_parameter
parse_infiles
parse_recipe_resources
Expand Down Expand Up @@ -1055,6 +1056,87 @@ sub get_package_env_cmds {
return @env_method_cmds;
}

sub get_recipe_resources {

## Function : Return recipe resources
## Returns : $recipe_resource | %recipe_resource
## Arguments: $active_parameter_href => The active parameters for this analysis hash {REF}
## : $recipe_name => Recipe name
## : $recipe_resource => Recipe parameter key

my ($arg_href) = @_;

## Flatten argument(s)
my $active_parameter_href;
my $recipe_name;
my $resource;

my $tmpl = {
active_parameter_href => {
default => {},
defined => 1,
required => 1,
store => \$active_parameter_href,
strict_type => 1,
},
recipe_name => {
defined => 1,
required => 1,
store => \$recipe_name,
strict_type => 1,
},
resource => {
allow => [qw{ core_number gpu_number load_env_ref memory mode time }],
store => \$resource,
strict_type => 1,
},
};

check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!};

use MIP::Active_parameter qw{ get_package_env_cmds };
use MIP::Environment::Cluster qw{ check_recipe_memory_allocation };

## Initilize variable
my @environment_cmds = get_package_env_cmds(
{
active_parameter_href => $active_parameter_href,
package_name => $recipe_name,
}
);

my $core_number = $active_parameter_href->{recipe_core_number}{$recipe_name};
my $process_memory = $active_parameter_href->{recipe_memory}{$recipe_name};
my $core_ram_memory = $active_parameter_href->{core_ram_memory};

my $memory =
( $process_memory and $core_number ) ? $process_memory * $core_number
: ( not $process_memory and $core_number ) ? $core_number * $core_ram_memory
: ( not $process_memory and not $core_number ) ? $core_ram_memory
: $process_memory;

check_recipe_memory_allocation(
{
node_ram_memory => $core_ram_memory,
recipe_memory_allocation => $memory,
}
);

my %recipe_resource = (
core_number => $core_number,
gpu_number => $active_parameter_href->{recipe_gpu_number}{$recipe_name},
load_env_ref => \@environment_cmds,
memory => $memory,
mode => $active_parameter_href->{$recipe_name},
time => $active_parameter_href->{recipe_time}{$recipe_name},
);

return $recipe_resource{$resource} if ( defined $resource && $resource );

return %recipe_resource;

}

sub get_user_supplied_pedigree_parameter {

## Function : Detect if user supplied info on parameters otherwise collected from pedigree
Expand Down
165 changes: 0 additions & 165 deletions lib/MIP/Get/Parameter.pm

This file was deleted.

49 changes: 49 additions & 0 deletions lib/MIP/Parameter.pm
Expand Up @@ -32,6 +32,7 @@ BEGIN {
get_order_of_parameters
get_parameter_attribute
get_program_executables
get_recipe_attributes
parse_reference_path
parse_parameter_files
parse_parameter_recipe_names
Expand Down Expand Up @@ -422,6 +423,54 @@ sub get_program_executables {
return uniq(@program_executables);
}

sub get_recipe_attributes {

## Function : Return recipe attributes
## Returns : $attribute | %attribute
## Arguments: $attribute => Attribute key
## : $parameter_href => Holds all parameters
## : $recipe_name => Recipe name

my ($arg_href) = @_;

## Flatten argument(s)
my $attribute;
my $parameter_href;
my $recipe_name;

my $tmpl = {
attribute => {
store => \$attribute,
strict_type => 1,
},
parameter_href => {
default => {},
defined => 1,
required => 1,
store => \$parameter_href,
strict_type => 1,
},
recipe_name => {
defined => 1,
required => 1,
strict_type => 1,
store => \$recipe_name,
},
};

check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!};

if ( not exists $parameter_href->{$recipe_name} ) {
croak(qq{Recipe name: $recipe_name. Does not exists in parameter hash});
}

## Get attribute value
return $parameter_href->{$recipe_name}{$attribute} if ( defined $attribute and $attribute );

## Get recipe attribute hash
return %{ $parameter_href->{$recipe_name} };
}

sub parse_parameter_files {

## Function : Parse parameter file objects and checks that their paths exist
Expand Down
2 changes: 1 addition & 1 deletion lib/MIP/Parse/File.pm
Expand Up @@ -134,7 +134,7 @@ sub parse_io_outfiles {
check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!};

use MIP::Get::File qw{ get_io_files };
use MIP::Get::Parameter qw{ get_recipe_attributes };
use MIP::Parameter qw{ get_recipe_attributes };
use MIP::Set::File qw{ set_io_files };

my @file_paths = @{$file_paths_ref};
Expand Down

0 comments on commit 643a8b1

Please sign in to comment.