HPC-Runner-Command
view release on metacpan or search on metacpan
lib/HPC/Runner/Command/submit_jobs/Plugin/PBS.pm view on Meta::CPAN
predicate => 'has_template_file',
clearer => 'clear_template_file',
documentation =>
q{Path to Slurm template file if you do not wish to use the default}
);
=head2 Subroutines
=cut
=head3 submit_jobs
Submit jobs to slurm queue using PBS.
=cut
#TODO IF THESE ARE ARRAYS I NEED -W depend=afterokarray:1234[]
# -W depend=afterokarray:12345678[5] for a task in the array
sub submit_jobs {
my $self = shift;
my ( $exitcode, $stdout, $stderr ) =
$self->submit_to_scheduler(
$self->submit_command . " " . $self->slurmfile );
sleep(5);
if ( $exitcode != 0 ) {
$self->log->fatal("Job was not submitted successfully");
$self->log->warn( "STDERR: " . $stderr ) if $stderr;
$self->log->warn( "STDOUT: " . $stdout ) if $stdout;
}
my $jobid = $stdout;
#When submitting job arrays the array will be 1234[].hpc.nyu.edu
if ( !$jobid ) {
$self->job_failure;
}
else {
$self->log->debug(
"Submited job " . $self->slurmfile . "\n\tWith PBS jobid $jobid" );
}
return $jobid;
}
=head3 update_job_deps
Update the job dependencies if using job_array (not batches)
TODO - not entirely sure this will work...
# This is for Torque
# http://docs.adaptivecomputing.com/torque/4-1-4/Content/topics/commands/qalter.htm
# $tv = $tmp[0] . ' -t '.$tmp[1];
=cut
sub update_job_deps {
my $self = shift;
return unless $self->has_array_deps;
$self->log->warn('Task dependencies in PBS is still very experimental!');
$self->log->warn( 'Please raise any problems as an issue at github.' . "\n"
. "\thttp://github.com/biosails/HPC-Runner-Command" );
while ( my ( $current_task, $v ) = each %{ $self->array_deps } ) {
my $cmd;
if ( $self->use_batches ) {
my $dep_tasks = join( ':', @$v );
$cmd = "qalter $current_task -W depend=afterok:$dep_tasks";
}
else {
foreach my $tv ( @{$v} ) {
# The format is schedulerId_arrayIndex
$tv =~ s/\n//;
my @tmp = split( '_', $tv );
my $dep_scheduler_id =
$self->parse_pbs_scheduler_id( $tmp[0], $tmp[1] );
$tv = $dep_scheduler_id;
}
my @tmp = split( '_', $current_task );
my $current_scheduler_id =
$self->parse_pbs_scheduler_id( $tmp[0], $tmp[1] );
my $dep_tasks = join( ':', @$v );
$dep_tasks = '"' . $dep_tasks . '"';
$cmd =
"qalter \"$current_scheduler_id\" -W depend=afterokarray:$dep_tasks";
}
$self->submit_to_scheduler($cmd);
}
}
=head3 parse_pbs_scheduler_id
PBS tasks look like
1234[].hpc.nyu.edu
This needs to be split in order to get the task right
=cut
sub parse_pbs_scheduler_id {
my $self = shift;
my $pbs_scheduler_id = shift;
my $task = shift;
my @split_host = split( '\.', $pbs_scheduler_id );
my $scheduler_id = shift @split_host;
$scheduler_id =~ s/\[\]//;
my $host = join( '.', @split_host );
( run in 0.894 second using v1.01-cache-2.11-cpan-a49fcb8fa48 )