Skip to content

Commit

Permalink
Style code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Eagles committed Oct 23, 2023
1 parent 262f044 commit cee249e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions R/array_submit.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#'
array_submit <- function(name, task_ids = NULL, submit = FALSE, restore = TRUE, verbose = FALSE) {
## Check existence and validity of the shell script
if ((basename(name) != name) || !file.exists(paste0(name, '.sh'))) {
if ((basename(name) != name) || !file.exists(paste0(name, ".sh"))) {
stop(
paste(
"'name' must give the name of a shell script in the current",
Expand All @@ -59,7 +59,7 @@ array_submit <- function(name, task_ids = NULL, submit = FALSE, restore = TRUE,
)
}

job_original <- readLines(paste0(name, '.sh'))
job_original <- readLines(paste0(name, ".sh"))

############################################################################
# Infer failed task IDs if 'task_ids' is NULL
Expand Down Expand Up @@ -224,7 +224,7 @@ array_submit <- function(name, task_ids = NULL, submit = FALSE, restore = TRUE,
paste0("#SBATCH --array=", paste(task_ids, collapse = ","), "%\\1"),
job_original
)
writeLines(job_new, con = paste0(name, '.sh'))
writeLines(job_new, con = paste0(name, ".sh"))

# Invoke (sbatch) the modified script if requested
if (submit) {
Expand All @@ -233,8 +233,8 @@ array_submit <- function(name, task_ids = NULL, submit = FALSE, restore = TRUE,
}

# Restore the original script
if (restore) writeLines(job_original, con = paste0(name, '.sh'))
if (restore) writeLines(job_original, con = paste0(name, ".sh"))

# Return the path
return(invisible(paste0(name, '.sh')))
return(invisible(paste0(name, ".sh")))
}
5 changes: 2 additions & 3 deletions R/job_loop.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
#' cores = 2
#' )
#'
job_loop <- function(
loops, name, create_shell = FALSE, partition = "shared", memory = "10G",
cores = 1L, tc = 20, email = "ALL", logdir = "logs") {
job_loop <- function(loops, name, create_shell = FALSE, partition = "shared", memory = "10G",
cores = 1L, tc = 20, email = "ALL", logdir = "logs") {
## Check that the loops are correctly defined
if (!is.list(loops)) {
stop("'loops' should be a named list.", call. = FALSE)
Expand Down
9 changes: 5 additions & 4 deletions R/job_single.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@
#' ## An array job
#' job_single("jhpce_job_array", task_num = 20, create_logdir = FALSE)
#'
job_single <- function(name, create_shell = FALSE, partition = "shared", memory = "10G",
cores = 1L, email = "ALL", logdir = "logs", task_num = NULL, tc = 20,
command = 'Rscript -e "options(width = 120); sessioninfo::session_info()"',
create_logdir = TRUE) {
job_single <- function(
name, create_shell = FALSE, partition = "shared", memory = "10G",
cores = 1L, email = "ALL", logdir = "logs", task_num = NULL, tc = 20,
command = 'Rscript -e "options(width = 120); sessioninfo::session_info()"',
create_logdir = TRUE) {
## Remove any spaces
name <- gsub(" ", "_", name)

Expand Down

0 comments on commit cee249e

Please sign in to comment.