From af2ddf3fcc724fee6ec7700a46ce017daad9a769 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Wed, 4 Oct 2023 14:42:06 -0400 Subject: [PATCH] Try another approach --- dev/interactive_testing/my_array_job.sh.sh | 36 ++++++++++++++++++++++ tests/testthat/test-array_submit.R | 33 ++++++++++++-------- 2 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 dev/interactive_testing/my_array_job.sh.sh diff --git a/dev/interactive_testing/my_array_job.sh.sh b/dev/interactive_testing/my_array_job.sh.sh new file mode 100644 index 0000000..4be6901 --- /dev/null +++ b/dev/interactive_testing/my_array_job.sh.sh @@ -0,0 +1,36 @@ +#!/bin/bash +#SBATCH -p shared +#SBATCH --mem-per-cpu=10G +#SBATCH --job-name=my_array_job.sh +#SBATCH -c 1 +#SBATCH -o logs/my_array_job.sh.%a.txt +#SBATCH -e logs/my_array_job.sh.%a.txt +#SBATCH --mail-type=ALL +#SBATCH --array=1-10%5 + +set -e + +echo "**** Job starts ****" +date + +echo "**** JHPCE info ****" +echo "User: ${USER}" +echo "Job id: ${SLURM_JOB_ID}" +echo "Job name: ${SLURM_JOB_NAME}" +echo "Node name: ${SLURMD_NODENAME}" +echo "Task id: ${SLURM_ARRAY_TASK_ID}" + +## Load the R module +module load conda_R + +## List current modules for reproducibility +module list + +## Edit with your job command +Rscript -e "options(width = 120); sessioninfo::session_info()" + +echo "**** Job ends ****" +date + +## This script was made using slurmjobs version 0.99.0 +## available from http://research.libd.org/slurmjobs/ diff --git a/tests/testthat/test-array_submit.R b/tests/testthat/test-array_submit.R index 1c4fb2d..b30a378 100644 --- a/tests/testthat/test-array_submit.R +++ b/tests/testthat/test-array_submit.R @@ -2,24 +2,33 @@ script_name <- "my_array_job.sh" # Write a basic shell script with 'job_single()' basic_job <- function() { - # Delete the shell script if it exists - unlink(script_name) + with_wd( + tempdir(), + { + # Delete the shell script if it exists + unlink(script_name) - job_single( - name = script_name, - create_shell = TRUE, - task_num = 10, - tc = 5 - ) + job_single( + name = script_name, + create_shell = TRUE, + task_num = 10, + tc = 5 + ) + } } # Write a basic shell script but break it by removing the '--array' line broken_job <- function() { - basic_job() + with_wd( + tempdir(), + { + basic_job() - orig_script <- readLines(script_name) - orig_script <- sub("^#SBATCH", "something", orig_script) - writeLines(orig_script, script_name) + orig_script <- readLines(script_name) + orig_script <- sub("^#SBATCH", "something", orig_script) + writeLines(orig_script, script_name) + } + ) } # Create (write) some shell script with the 'shell_creation_fun' function,