Returns an outsider object. The outsider object describes a outsider module's program and arguments. The object is generated every time an outsider module program is called. It details the arguments of a call, the command as well as the files to send to the docker container.

outsider_init(
  pkgnm,
  cmd = NA,
  arglist = NULL,
  wd = NULL,
  files_to_send = NULL,
  ignore_errors = FALSE
)

run(x, ...)

# S3 method for outsider
run(x, ...)

Arguments

pkgnm

Name of the installed R package for the outsider module

cmd

Command to be called in the container

arglist

Arguments for command, character vector

wd

Directory to which program generated files will be returned

files_to_send

Files to be sent to container

ignore_errors

Ignore raised errors? Default FALSE.

x

outsider object

...

Additional arguments

Value

A list of class outsider with the following items:

pkgnm

Package name of the outsider module

cmd

Command to be called in the container

arglist

Arguments for command, character vector

wd

Directory to which program generated files will be returned

files_to_send

Files to be sent to container

container

Docker container object

ignore_errors

Prevent errors being raised

Details

The outsider module runs a docker container that acts like a separate machine on the host computer. All the files necessary for the program to be run must be sent to the remote machine before the program is called. The arguments, wd and files_to_send can all be defined after the outsider has been initiated using $ notation. Once a outsider has been defined, the command can be run using .run(). The arglist, wd or files_to_send do not need to be defined for the outsider to be run.

Examples

# \donttest{ # Set-up: install "hello.world", ships with ubuntu # we can make simple commands in bash via R using the module library(outsider.base) # Manually install example module # outsider.base contains the hello.world module in its package files pkgnm <- 'om..hello.world' mdl_flpth <- system.file('extdata', 'om..hello.world', package = "outsider.base") # install and import (outsider::module_install performs these tasks) pkg_install(flpth = mdl_flpth)
#> Error: Can't find ''.
image_install(pkgnm = pkgnm) # Run echo # create a outsider object that contains argument and Docker container details otsdr <- outsider_init(pkgnm = pkgnm, cmd = 'echo', arglist = c('hello world!'))
#> Error: No 'om.yml' for 'om..hello.world'
# check details print(otsdr)
#> Error in print(otsdr): object 'otsdr' not found
# run the command run(otsdr)
#> Error in run(otsdr): object 'otsdr' not found
# Send a file # an existing outsider object can be modified tmppth <- tempdir() flpth <- file.path(tmppth, 'testfile') write(x = 'hello from within a file!', file = flpth) otsdr$files_to_send <- flpth
#> Error in otsdr$files_to_send <- flpth: object 'otsdr' not found
otsdr$cmd <- 'cat'
#> Error in otsdr$cmd <- "cat": object 'otsdr' not found
otsdr$arglist <- 'testfile'
#> Error in otsdr$arglist <- "testfile": object 'otsdr' not found
# check details print(otsdr)
#> Error in print(otsdr): object 'otsdr' not found
# run the command run(otsdr)
#> Error in run(otsdr): object 'otsdr' not found
# Return a file # an existing outsider object can be modified otsdr$files_to_send <- NULL
#> Error in otsdr$files_to_send <- NULL: object 'otsdr' not found
otsdr$cmd <- 'touch'
#> Error in otsdr$cmd <- "touch": object 'otsdr' not found
otsdr$arglist <- 'newfile'
#> Error in otsdr$arglist <- "newfile": object 'otsdr' not found
otsdr$wd <- tmppth # determines where created files are returned to
#> Error in otsdr$wd <- tmppth: object 'otsdr' not found
# check details print(otsdr)
#> Error in print(otsdr): object 'otsdr' not found
# run the command run(otsdr)
#> Error in run(otsdr): object 'otsdr' not found
# check if 'newfile' exists in tempdir() nwflpth <- file.path(tmppth, 'newfile') (file.exists(nwflpth))
#> [1] FALSE
# Clean-up rm(otsdr)
#> Warning: object 'otsdr' not found
file.remove(flpth)
#> [1] TRUE
file.remove(nwflpth)
#> Warning: cannot remove file '/tmp/Rtmpfu6u5L/newfile', reason 'No such file or directory'
#> [1] FALSE
uninstall(pkgnm) # }