View source: R/remoteComputing.R
runbg | R Documentation |
Generate an R code of the expression that is copied via scp
to any machine (ssh-key needed). Then collect the results.
runbg(
...,
machine = "localhost",
filename = NULL,
input = ls(.GlobalEnv),
compile = FALSE,
wait = FALSE,
recover = F
)
... |
Some R code |
machine |
Character vector, e.g. |
filename |
Character, defining the filename of the temporary file. Random file name ist chosen if NULL. |
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 |
wait |
Logical. Wait until executed. If |
recover |
Logical. This option is useful to recover the three functions check(), get() and purge(), e.g. when a session has crashed. Then, the three functions are recreated without restarting the job. They can then be used to get the results of a job wihtout having to do it manually. Requires the correct filename, so if the previous runbg was run with filename = NULL, you have to specify the tmp_filename manually. |
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.
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.
## Not run:
out_job1 <- runbg({
M <- matrix(rnorm(1e2), 10, 10)
solve(M)
}, machine = c("localhost", "localhost"), filename = "job1")
out_job1$check()
out_job1$get()
result <- .runbgOutput
print(result)
out_job1$purge()
## End(Not run)
## Not run:
#' Recover a runbg job with the option "recover"
out_job1 <- runbg({
M <- matrix(rnorm(1e2), 10, 10)
solve(M)
}, machine = c("localhost", "localhost"), filename = "job1")
Sys.sleep(1)
remove(out_job1)
try(out_job1$check())
out_job1 <- runbg({
"This code is not run"
}, machine = c("localhost", "localhost"), filename = "job1", recover = T)
out_job1$get()
result <- .runbgOutput
print(result)
out_job1$purge()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.