outsider-class: Construct outsider object

Description Usage Arguments Details Value Examples

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
outsider_init(
  pkgnm,
  cmd = NA,
  arglist = NULL,
  wd = NULL,
  files_to_send = NULL,
  ignore_errors = FALSE
)

run(x, ...)

## S3 method for class '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

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.

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
## Not run: 
# 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)
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!'))
# check details
print(otsdr)
# run the command
run(otsdr)

# 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
otsdr$cmd <- 'cat'
otsdr$arglist <- 'testfile'
# check details
print(otsdr)
# run the command
run(otsdr)

# Return a file
# an existing outsider object can be modified
otsdr$files_to_send <- NULL
otsdr$cmd <- 'touch'
otsdr$arglist <- 'newfile'
otsdr$wd <- tmppth  # determines where created files are returned to
# check details
print(otsdr)
# run the command
run(otsdr)
# check if 'newfile' exists in tempdir()
nwflpth <- file.path(tmppth, 'newfile')
(file.exists(nwflpth))

# Clean-up
rm(otsdr)
file.remove(flpth)
file.remove(nwflpth)
uninstall(pkgnm)

## End(Not run)

outsider.base documentation built on April 19, 2021, 1:06 a.m.