R/detectHpc.R

Defines functions detectHpc

Documented in detectHpc

#' Detect HPC environment
#'
#' Detect if R is running on a high-performance computing (HPC) cluster.
#'
#' Currently supports detection of Slurm or LSF.
#'
#' @export
#' @note Updated 2021-08-13.
#'
#' @return `character(1)` or `logical(1)`.
#' Workload manager (scheduler) name if HPC is detected (e.g. `"SLURM"` or
#' `"LSF"`), otherwise `FALSE`.
#'
#' @seealso
#' - `Sys.getenv`.
#' - `Sys.info`.
#' - `R.version`.
#' - `.Platform`.
#'
#' @examples
#' detectHpc()
detectHpc <- function() {
    if (!identical(Sys.getenv("LSF_ENVDIR"), "")) {
        "LSF"
    } else if (!identical(Sys.getenv("SLURM_CONF"), "")) {
        "SLURM"
    } else {
        FALSE
    }
}
acidgenomics/r-koopa documentation built on Oct. 31, 2023, 9:21 a.m.