Invoke sbatch using R

57 Views Asked by At

How can I control the execution of sbatch from R?

I have an object called baby.bash, that holds the indications to execute a task in a remote computer.
Then, by opening my terminal and executing the command line sbatch baby.bash, a task is triggered. When running the command line sbatch baby.bash in my terminal, the work executes correctly.

baby.bash looks like this:

#!/bin/bash
#SBATCH --job-name=WORKNAME
#SBATCH [email protected]
#SBATCH --mail-type=FAIL
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=34gb
#SBATCH --time=80:00:00
#SBATCH --output=o.out
#SBATCH --error=e.error

echo "stage 01"
renumf90 baby.par
echo "stage 02"
gibbsf90+ renf90.par --samples 500000 --burnin 10000 --interval 5
echo "stage 03"
echo -e renf90.par '\n' 0 '\n' 5 '\n' 0 | postgibbsf90

Nowadays, I am trying with system() and system2() functions.

Example 1: will return the current working directory

system2(command = 'pwd')

Example 2: will list folders and files in the current working directory.

system2(command = 'ls', arg = '-l')

Now, I want to execute the command sbatch, and parse as argument baby.bsh.

Buggy line 1:

system2(command = 'sbatch', arg = 'baby.bsh')

sbatch: error: Invalid user for SlurmUser slurm, ignored

sbatch: fatal: Unable to process configuration file

Buggy line 2:

system('sbatch baby.bsh')

sbatch: error: Invalid user for SlurmUser slurm, ignored

sbatch: fatal: Unable to process configuration file

It may sound trivial my willingness of execute sbatch baby.bash through R. The reasons I want to do this, is because in that way I could insert the execution line inside a R loop, and use my R skills to handle parallel works in my remote computer.

I am new in this world of COMPSCI and multicored computing, so please excuse me if I am misusing some terminology, or if my question is not relevant/clear.

Thanks and best

0

There are 0 best solutions below