简体   繁体   中英

Passing SLURM batch command line arguments to R

I'm trying to run a SLURM sbatch command with various parameters that I can read in an R script. When using PBS system, I used to write qsub -v param1=x,param2=y (+ other system parameters like the memory requirements etc and the script name to be read by PBS) and then in the R script read it with x = Sys.getenv('param1') .

Now I tried

sbatch run.sh --export=basePath=‘a’

With run.sh:

#!/bin/bash

cd $SLURM_SUBMIT_DIR
echo $PWD

module load R/common/3.3.3

R CMD BATCH --quiet --no-restore --no-save runDo.R output.txt

And runDo.R:

base.path = Sys.getenv('basePath')

print(base.path)

The script is running but the argument value is not assigned to base.path variable (it prints an empty string).

The export parameter has to be passed to sbatch not to the run.sh script.

It should be like this:

sbatch --export=basePath=‘a’ run.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM