Skip to content

Commit

Permalink
bugfix-test-10
Browse files Browse the repository at this point in the history
  • Loading branch information
telatin committed Nov 8, 2023
1 parent a42bb08 commit 5c391eb
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.8.2 2023-11-08

* Bugfix: test 10-hpc had a typo and didnt work on Slurm clusters

0.8.1 2023-10-13

* Bugfix on stderr file name automatically assigned

0.8.0 2023-10-12

* Improved `runjob` verbose output and automatic naming
Expand Down
2 changes: 1 addition & 1 deletion bin/make_image_from_bioconda
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Pod::Usage;
use Term::ANSIColor qw(:constants);
use NBI::Slurm;

my $config = NBI::Slurm::load_config("$USER/.nbislurm.config");
my $config = NBI::Slurm::load_config("$ENV{USER}/.nbislurm.config");
my $output = undef;
my $move = 0;
my $def_file = undef;
Expand Down
7 changes: 3 additions & 4 deletions bin/make_package
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use File::Spec;
use Pod::Usage;
use NBI::Slurm;

my $config = NBI::Slurm::load_config("$USER/.nbislurm.config");
my $config = NBI::Slurm::load_config("$ENV{USER}/.nbislurm.config");
my $image = undef;
my $package = undef;
my $force = 0;
Expand Down Expand Up @@ -80,9 +80,8 @@ if (chmod($permissions, $source_file)) {
# Create symbolic links for the provided commands
my @COMMANDS = `singularity exec \"$image\" cat /etc/binaries.txt`;
if ($? != 0) {
say STDERR "ERROR: Failed to read /etc/binaries.txt from image.";
say STDERR " -> Are you sure this is a valid Singularity image?";
exit 1;
say STDERR "WARNING: Failed to read /etc/binaries.txt from image.";
say STDERR " -> We will consider this a 'custom' Singularity image?";
} elsif (scalar @COMMANDS == 0) {
say STDERR "ERROR: No commands supplied (or no /etc/binaries.txt found).";
} else {
Expand Down
10 changes: 10 additions & 0 deletions bin/runjob
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ $queue = update_queue($queue, $time_hours);
$command = join(" ", @ARGV);
usage(1) unless ($command);

if ($verbose) {
say STDERR YELLOW, BOLD, "PARAMETERS:",RESET;
say STDERR YELLOW, "Queue: ", RESET, $queue // "(not set)";
say STDERR YELLOW, "Memory: ", RESET, $memory // "(not set)";
say STDERR YELLOW, "Threads: ", RESET, $threads // "(not set)";
say STDERR YELLOW, "Time: ", RESET, $time // "(not set)";
say STDERR YELLOW, "Tmpdir: ", RESET, $tmpdir // "(not set)";
say STDERR YELLOW, "Name: ", RESET, $name // "(not set)";
say STDERR YELLOW, "Command: ", RESET, $command // "(not set)";
}
# Check threadshours
if (-d $time) {
say STDERR RED, BOLD, "ERROR:", RESET, " did you mean \"--tmpdir $time\" instead of $threads threads?";
Expand Down
19 changes: 15 additions & 4 deletions lib/NBI/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use File::Spec::Functions;
$Data::Dumper::Sortkeys = 1;
use File::Basename;

$NBI::Job::VERSION = $NBI::Slurm::VERSION;
my $DEFAULT_QUEUE = "nbi-short";
$NBI::Job::VERSION = $NBI::Slurm::VERSION;
my $DEFAULT_QUEUE = "nbi-short";
require Exporter;
our @ISA = qw(Exporter);

Expand Down Expand Up @@ -156,7 +156,7 @@ sub errorfile : lvalue {

# Create a default error_file if not defined
if (not defined $self->{error_file}) {
$self->{error_file} = catfile( $self->opts->tmpdir , $self->name . ".%j.out");
$self->{error_file} = catfile( $self->opts->tmpdir , $self->name . ".%j.err");
}

if ($interpolate) {
Expand Down Expand Up @@ -434,6 +434,11 @@ Accessor method for the error file path.
This method allows you to get or set the path of the error file generated by the job. If called with an argument, it sets the error file path to the specified value. If called without an argument, it returns the current error file path.
=head2 script_path
Accessor method for the actual script path. This is the path of the script file generated by the job.
invoking C<run()> will generate a script path if it was not set.
=head2 append_command
Append a command to the job.
Expand Down Expand Up @@ -507,4 +512,10 @@ Submit the job to SLURM.
my $jobid = $job->run;
This method submits the job to SLURM for execution.
It generates the sbatch script, writes it to a file, and uses the "sbatch" command to submit the job. If the submission is successful, it returns the job ID assigned by SLURM. Otherwise, it throws an exception.
It generates the sbatch script, writes it to a file, and uses the "sbatch" command to submit the job. If the submission is successful, it returns the job ID assigned by SLURM. Otherwise, it throws an exception.
=head2 view
Return a string representation of the object.
my $str = $job->view;
4 changes: 2 additions & 2 deletions lib/NBI/Slurm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use NBI::Job;
use NBI::Opts;
use base qw(Exporter);
our @ISA = qw(Exporter);
our @EXPORT = qw(Job Opts load_config %FORMAT_STRINGS);
$NBI::Slurm::VERSION = '0.8.0';
our @EXPORT = qw(Job Opts load_config has_queue %FORMAT_STRINGS);
$NBI::Slurm::VERSION = '0.8.1';



Expand Down
8 changes: 6 additions & 2 deletions t/10-hpc.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ use Test::More;
use Data::Dumper;
use NBI::Slurm;

my $has_queue = NBI::Slurm::has_squeue();

# Skip if NBI::Slurm::has_squeue() is false
if (NBI::Slurm::has_squeue() == 0) {
if ($has_queue == 0) {
plan skip_all => "Skipping all tests: not in a slurm cluster";
}

my @queue = NBI::Slurm::queue();
ok($has_queue == 1, "has_squeue() returns a value");

my @queue = NBI::Slurm::queues();
ok(scalar @queue > 0, "queue() returns a list of queues");
done_testing();

0 comments on commit 5c391eb

Please sign in to comment.