From 199d634fb7a794a609c93c6888dca8edb9e0c71c Mon Sep 17 00:00:00 2001 From: Dom Bennett Date: Tue, 12 Feb 2019 18:17:11 +0100 Subject: [PATCH] trying to fixing missing img error, supress running examples for now --- R/identities.R | 9 +++- R/outsider.R | 1 + R/search.R | 1 + examples/.arglist_parse.R | 2 +- examples/log_set.R | 39 ++++++++-------- examples/module_install.R | 28 +++++++----- examples/outsider-class.R | 96 ++++++++++++++++++++------------------- man/dot-arglist_parse.Rd | 2 +- man/log_set.Rd | 39 ++++++++-------- man/module_help.Rd | 28 +++++++----- man/module_import.Rd | 28 +++++++----- man/module_install.Rd | 28 +++++++----- man/module_uninstall.Rd | 28 +++++++----- man/outsider-class.Rd | 96 ++++++++++++++++++++------------------- 14 files changed, 231 insertions(+), 194 deletions(-) diff --git a/R/identities.R b/R/identities.R index bc65428..7eed127 100644 --- a/R/identities.R +++ b/R/identities.R @@ -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' diff --git a/R/outsider.R b/R/outsider.R index 63900c4..6e9cc25 100644 --- a/R/outsider.R +++ b/R/outsider.R @@ -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) diff --git a/R/search.R b/R/search.R index 50782d6..5769f4c 100644 --- a/R/search.R +++ b/R/search.R @@ -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, diff --git a/examples/.arglist_parse.R b/examples/.arglist_parse.R index 478080d..f1b3a73 100644 --- a/examples/.arglist_parse.R +++ b/examples/.arglist_parse.R @@ -14,4 +14,4 @@ arglist <- c('-a', 10, '-b', 'model2', '-wd', wd, '--unwanted') # clean-up -unlink(wd) +unlink(wd, recursive = TRUE) diff --git a/examples/log_set.R b/examples/log_set.R index 5fe791c..4031e47 100644 --- a/examples/log_set.R +++ b/examples/log_set.R @@ -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) diff --git a/examples/module_install.R b/examples/module_install.R index 11e70f1..2d0468f 100644 --- a/examples/module_install.R +++ b/examples/module_install.R @@ -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) diff --git a/examples/outsider-class.R b/examples/outsider-class.R index 02ed5b1..6c9e4c5 100644 --- a/examples/outsider-class.R +++ b/examples/outsider-class.R @@ -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) diff --git a/man/dot-arglist_parse.Rd b/man/dot-arglist_parse.Rd index a19681a..7d6b2b0 100644 --- a/man/dot-arglist_parse.Rd +++ b/man/dot-arglist_parse.Rd @@ -50,7 +50,7 @@ arglist <- c('-a', 10, '-b', 'model2', '-wd', wd, '--unwanted') # clean-up -unlink(wd) +unlink(wd, recursive = TRUE) } \seealso{ Other developer: \code{\link{.arglist_get}}, diff --git a/man/log_set.Rd b/man/log_set.Rd index 6493dc1..ed2cf6a 100644 --- a/man/log_set.Rd +++ b/man/log_set.Rd @@ -20,24 +20,27 @@ modules. See \code{\link[sys]{exec}}. } \examples{ -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) } \seealso{ Other user: \code{\link{module_details}}, diff --git a/man/module_help.Rd b/man/module_help.Rd index 67ab101..c2f3ee0 100644 --- a/man/module_help.Rd +++ b/man/module_help.Rd @@ -16,18 +16,22 @@ Look up help files for specific outsider module functions or whole modules. } \examples{ -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) } \seealso{ Other user: \code{\link{log_set}}, diff --git a/man/module_import.Rd b/man/module_import.Rd index eb69304..62fc347 100644 --- a/man/module_import.Rd +++ b/man/module_import.Rd @@ -23,18 +23,22 @@ If program is successfully removed from your system, TRUE is returned else FALSE. } \examples{ -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) } \seealso{ Other user: \code{\link{log_set}}, diff --git a/man/module_install.Rd b/man/module_install.Rd index aaf4091..7b2478c 100644 --- a/man/module_install.Rd +++ b/man/module_install.Rd @@ -20,18 +20,22 @@ Logical Install a module } \examples{ -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) } \seealso{ Other user: \code{\link{log_set}}, diff --git a/man/module_uninstall.Rd b/man/module_uninstall.Rd index af18ef0..e907d79 100644 --- a/man/module_uninstall.Rd +++ b/man/module_uninstall.Rd @@ -20,18 +20,22 @@ If program is successfully removed from your system, TRUE is returned else FALSE. } \examples{ -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) } \seealso{ Other user: \code{\link{log_set}}, diff --git a/man/outsider-class.Rd b/man/outsider-class.Rd index c3172c4..c9dfaa5 100644 --- a/man/outsider-class.Rd +++ b/man/outsider-class.Rd @@ -59,55 +59,57 @@ The \code{arglist}, \code{wd} or \code{files_to_send} do not need to be defined for the outsider to be run. } \examples{ -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) } \seealso{ Other developer: \code{\link{.arglist_get}},