Skip to content

Commit

Permalink
Try another approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Eagles committed Oct 4, 2023
1 parent 7ac8c10 commit af2ddf3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 12 deletions.
36 changes: 36 additions & 0 deletions dev/interactive_testing/my_array_job.sh.sh
Original file line number Diff line number Diff line change
@@ -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/
33 changes: 21 additions & 12 deletions tests/testthat/test-array_submit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit af2ddf3

Please sign in to comment.