Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
trying to fixing missing img error, supress running examples for now
Browse files Browse the repository at this point in the history
  • Loading branch information
DomBennett committed Feb 12, 2019
1 parent 8693eb8 commit 199d634
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 194 deletions.
9 changes: 7 additions & 2 deletions R/identities.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ ids_get <- function(pkgnm) {
imgs <- docker_img_ls()
#print(imgs)
if ('tag' %in% colnames(imgs)) {
tag <- imgs[imgs[['repository']] == img, 'tag'][[1]]
tag <- tag[[1]]
pull <- imgs[['repository']] == img
if (any(pull)) {
tag <- imgs[pull, 'tag'][[1]]
tag <- tag[[1]]
} else {
stop(char(repo), ' is missing its Docker image, try reinstalling.')
}
} else {
# Sometimes there is no tag column (?)
tag <- 'latest'
Expand Down
1 change: 1 addition & 0 deletions R/outsider.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ NULL
#' @export
#' @example examples/outsider-class.R
#' @family developer
# TODO: example needs to avoid pulling from GitHub over and over.
.outsider_init <- function(repo, cmd = NA, arglist = NULL, wd = NULL,
files_to_send = NULL, ignore_errors = FALSE) {
pkgnm <- repo_to_pkgnm(repo = repo)
Expand Down
1 change: 1 addition & 0 deletions R/search.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ tags <- function(repos) {
download_url <- paste0(gh_raw_url, repo, '/master/dockerfiles/',
raw_df[ ,'name'], '/Dockerfile')
} else {
warning('Unable to fetch data from GitHub for ', char(repo))
download_url <- tag <- ''
}
data.frame(repo = repo, tag = tag, download_url = download_url,
Expand Down
2 changes: 1 addition & 1 deletion examples/.arglist_parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ arglist <- c('-a', 10, '-b', 'model2', '-wd', wd, '--unwanted')


# clean-up
unlink(wd)
unlink(wd, recursive = TRUE)
39 changes: 21 additions & 18 deletions examples/log_set.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
library(outsider)
repo <- 'dombennett/om..hello.world'
# if not installed, install
installed <- module_installed()
if (!repo %in% installed[['repo']]) module_install(repo)
hello_world <- module_import(fname = 'hello_world', repo = repo)

# control the log stream
# send output to file
tmpfl <- tempfile()
log_set(log = 'program_out', val = tmpfl)
hello_world()
(readLines(con = tmpfl))
file.remove(tmpfl)
# send docker and program output to console
log_set(log = 'program_out', val = TRUE)
log_set(log = 'docker_out', val = TRUE)
hello_world()
# NOT RUN
# library(outsider)
# repo <- 'dombennett/om..hello.world'
# # install and import
# module_install(repo = repo)
# hello_world <- module_import(fname = 'hello_world', repo = repo)
#
# # control the log stream
# # send output to file
# tmpfl <- tempfile()
# log_set(log = 'program_out', val = tmpfl)
# hello_world()
# (readLines(con = tmpfl))
# file.remove(tmpfl)
# # send docker and program output to console
# log_set(log = 'program_out', val = TRUE)
# log_set(log = 'docker_out', val = TRUE)
# hello_world()
#
# # clean-up
# module_uninstall(repo)
28 changes: 16 additions & 12 deletions examples/module_install.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
library(outsider)
# simplest repo
repo <- 'dombennett/om..hello.world'
# if not installed, install
installed <- module_installed()
if (!repo %in% installed[['repo']]) module_install(repo)
# get help
module_help(repo = repo)
# import function
hello_world <- module_import(fname = 'hello_world', repo = repo)
# run function
hello_world()
# NOT RUN
# library(outsider)
# # simplest repo
# repo <- 'dombennett/om..hello.world'
# # install
# module_install(repo = repo)
# hello_world <- module_import(fname = 'hello_world', repo = repo)
# # get help
# module_help(repo = repo)
# # import function
# hello_world <- module_import(fname = 'hello_world', repo = repo)
# # run function
# hello_world()
#
# # uninstall
# module_uninstall(repo)
96 changes: 49 additions & 47 deletions examples/outsider-class.R
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
library(outsider)
# Set-up: install hello.world, ships with ubuntu
# we can make simple commands in bash via R
repo <- 'dombennett/om..hello.world'
# if not installed, install
installed <- module_installed()
if (!repo %in% installed[['repo']]) module_install(repo)

# Run echo
# create a outsider object that contains argument and Docker container details
otsdr <- outsider::.outsider_init(repo = repo, cmd = 'echo',
arglist = c('hello world!'))
# check details
print(otsdr)
# run the command
# NOT RUN
# library(outsider)
# # Set-up: install hello.world, ships with ubuntu
# # we can make simple commands in bash via R
# repo <- 'dombennett/om..hello.world'
# # install and import
# module_install(repo = repo)
# hello_world <- module_import(fname = 'hello_world', repo = repo)
#
# # Run echo
# # create a outsider object that contains argument and Docker container details
# otsdr <- outsider::.outsider_init(repo = repo, cmd = 'echo',
# arglist = c('hello world!'))
# # check details
# print(otsdr)
# # run the command
# # NOT RUN
# # outsider::.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
# outsider::.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
outsider::.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
outsider::.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)
#
# # 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
# outsider::.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)
# module_uninstall(repo)
2 changes: 1 addition & 1 deletion man/dot-arglist_parse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 21 additions & 18 deletions man/log_set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions man/module_help.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions man/module_import.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions man/module_install.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 199d634

Please sign in to comment.