Skip to content
Permalink
Browse files

Allow user to disable core prescheduling in slurm_apply

Passes argument to mcmapply() via template
Documentation updated
Also removed some extraneous test output from the repo
  • Loading branch information
qdread committed Nov 12, 2019
1 parent 4e537ab commit 816b40e63e22586447efda18722717f4aa73c1c9
@@ -52,6 +52,12 @@
#' @param cpus_per_node The number of CPUs requested per node, i.e., how many
#' processes to run in parallel per node. This argument is mapped to the
#' Slurm parameter \code{cpus-per-task}.
#' @param preschedule_cores Corresponds to the \code{mc.preschedule} argument of
#' \code{parallel::mcmapply}. Defaults to \code{TRUE}. If \code{TRUE}, the
#' jobs are assigned to cores before computation. If \code{FALSE}, a new job is
#' created for each row of \code{params}. Setting \code{FALSE} may be faster if
#' different values of \code{params} result in very variable completion time for
#' jobs.
#' @param add_objects A character vector containing the name of R objects to be
#' saved in a .RData file and loaded on each cluster node prior to calling
#' \code{f}.
@@ -76,17 +82,18 @@
#' number of \code{nodes} effectively used.
#' @seealso \code{\link{slurm_call}} to evaluate a single function call.
#' @seealso \code{\link{cancel_slurm}}, \code{\link{cleanup_files}},
#' \code{\link{get_slurm_out}} and \code{\link{print_job_status}}
#' \code{\link{get_slurm_out}} and \code{\link{get_job_status}}
#' which use the output of this function.
#' @examples
#' \dontrun{
#' sjob <- slurm_apply(func, pars)
#' print_job_status(sjob) # Prints console/error output once job is completed.
#' get_job_status(sjob) # Prints console/error output once job is completed.
#' func_result <- get_slurm_out(sjob, "table") # Loads output data into R.
#' cleanup_files(sjob)
#' }
#' @export
slurm_apply <- function(f, params, jobname = NA, nodes = 2, cpus_per_node = 2,
slurm_apply <- function(f, params, jobname = NA,
nodes = 2, cpus_per_node = 2, preschedule_cores = TRUE,
add_objects = NULL, pkgs = rev(.packages()), libPaths = NULL,
rscript_path = NULL, r_template = NULL, sh_template = NULL,
slurm_options = list(), submit = TRUE) {
@@ -146,6 +153,7 @@ slurm_apply <- function(f, params, jobname = NA, nodes = 2, cpus_per_node = 2,
add_obj = !is.null(add_objects),
nchunk = nchunk,
cpus_per_node = cpus_per_node,
preschedule_cores = preschedule_cores,
libPaths = libPaths))
writeLines(script_r, file.path(tmpdir, "slurm_run.R"))

@@ -63,7 +63,7 @@
#' @seealso \code{\link{slurm_apply}} to parallelize a function over a parameter
#' set.
#' @seealso \code{\link{cancel_slurm}}, \code{\link{cleanup_files}},
#' \code{\link{get_slurm_out}} and \code{\link{print_job_status}} which use
#' \code{\link{get_slurm_out}} and \code{\link{get_job_status}} which use
#' the output of this function.
#' @export
slurm_call <- function(f, params, jobname = NA, add_objects = NULL,
@@ -2,7 +2,7 @@
#'
#' This function creates a \code{slurm_job} object which can be passed to other
#' functions such as \code{\link{cancel_slurm}}, \code{\link{cleanup_files}},
#' \code{\link{get_slurm_out}} and \code{\link{print_job_status}}.
#' \code{\link{get_slurm_out}} and \code{\link{get_job_status}}.
#'
#' In general, \code{slurm_job} objects are created automatically as the output of
#' \code{\link{slurm_apply}} or \code{\link{slurm_call}}, but it may be necessary
@@ -27,7 +27,7 @@ knitr::opts_chunk$set(

Development of this R package was supported by the National Socio-Environmental Synthesis Center (SESYNC) under funding received from the National Science Foundation grants DBI-1052875 and DBI-1639145.

The package was developed by Philippe Marchand (current maintainer), with Ian Carroll and Mike Smorul contributing.
The package was developed by Philippe Marchand, with Ian Carroll and Mike Smorul contributing. Quentin Read is the current maintainer.


### Installation
@@ -24,8 +24,8 @@ Development of this R package was supported by the National
Socio-Environmental Synthesis Center (SESYNC) under funding received
from the National Science Foundation grants DBI-1052875 and DBI-1639145.

The package was developed by Philippe Marchand (current maintainer),
with Ian Carroll and Mike Smorul contributing.
The package was developed by Philippe Marchand, with Ian Carroll and
Mike Smorul contributing. Quentin Read is the current maintainer.

### Installation

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

@@ -16,6 +16,7 @@ load('add_objects.RData')
FUN = .rslurm_func,
.rslurm_params[.rslurm_istart:.rslurm_iend, , drop = FALSE],
mc.cores = {{{cpus_per_node}}},
mc.preschedule = {{{preschedule_cores}}},
SIMPLIFY = FALSE))

saveRDS(.rslurm_result, file = paste0('results_', .rslurm_id, '.RDS'))

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

0 comments on commit 816b40e

Please sign in to comment.
You can’t perform that action at this time.