runbg_bwfor: Run an R expression on the bwForCluster

View source: R/remoteComputing.R

runbg_bwforR Documentation

Run an R expression on the bwForCluster

Description

Generate an R code of the expression that is copied via scp to the bwForCluster (ssh-key needed). Then collect the results.

Usage

runbg_bwfor(
  ...,
  machine,
  filename = NULL,
  nodes = 1,
  cores = 1,
  walltime = "01:00:00",
  input = ls(.GlobalEnv),
  compile = TRUE,
  recover = F
)

Arguments

...

Some R code

machine

e.g. fr_dk846@bwfor.cluster.uni-mannheim.de

filename

Character, defining the filename of the temporary file. Random file name ist chosen if NULL.

nodes

Number of nodes, e.g. 10

cores

Number of cores, e.g. 16

walltime

estimated runtime in the format hh:mm:ss, e.g. 01:30:00. Jobs with a walltime up to 30 min are sent to a quick queue. When the walltime is exceeded, all jobs are automatically killed by the queue.

input

Character vector, the objects in the workspace that are stored into an R data file and copied to the remove machine.

compile

Logical. If TRUE, C files are copied and compiled on the remote machine. Otherwise, the .so files are copied.

recover

Logical, If TRUE, the scripts will not be started again. Can be used to get back the check and get functions for an already started process, e.g. after local session has aborted.

Details

runbg() generates a workspace from the input argument and copies the workspace and all C files or .so files to the remote machines via scp. This will only work if *an ssh-key had been generated and added to the authorized keys on the remote machine*. The code snippet, i.e. the ... argument, can include several intermediate results but only the last call which is not redirected into a variable is returned via the variable .runbgOutput, see example below.

Value

List of functions check(), get() and purge(). check() checks, if the result is ready. get() copies the result file to the working directory and loads it into the workspace as an object called .runbgOutput. This object is a list named according to the machines that contains the results returned by each machine. purge() deletes the temporary folder from the working directory and the remote machines.

Examples

## Not run: 
out_job1 <- runbg({
   mstrust(obj, center, fits = 10, cores = 2)
 }, 
 machine = "bwfor", nodes = 2, cores = "2:best", 
 walltime = "00:01:00", 
 filename = "job1")
out_job1$check()          
out_job1$get()
out_job1$purge()
result <- .runbgOutput
print(result)

## End(Not run)


dkaschek/dMod documentation built on July 27, 2023, 11:45 p.m.