Re: [Bioc-devel] return value of BiocManager::install()

2019-01-22 Thread Martin Morgan
require is expensive and detach() fraught with subtle difficulties. Using 
withCallingHandlers is more elegant than capture.output(). See and direct 
further commentary to the issue.

Martin

On 1/22/19, 4:41 AM, "Bioc-devel on behalf of Levi Waldron" 
 
wrote:

BTW I just noticed the alternative approach of searching through the
warnings, used at

https://github.com/Bioconductor/bioc_docker/blob/5be6d37ded4f97995640cbb3a7d201165234b1e4/src/core/install.R.in#L42
:

if (!is.null(warnings()))
{
w <- capture.output(warnings())
if (length(grep("is not available|had non-zero exit status", w)))
quit("no", 1L)
}


On Tue, Jan 22, 2019 at 10:19 AM Levi Waldron 
wrote:

> I opened an issue on BiocManager (
> https://github.com/Bioconductor/BiocManager/issues/39) somewhat related
> to Sean's recent post, about what BiocManager::install() should return, 
and
> it occurs to me that I should mention it here too for feedback:
>
> > Having `BiocManager::install()` return the "pkgs" argument is not
> especially useful. Could it instead return success/error codes? Otherwise,
> how can you tell in a script whether the requested packages were installed
> successfully or not?
>
> The most basic return value I can think of would be like `require()`, TRUE
> if successful and FALSE if unsuccessful. More sophisticated behavior could
> give different error codes for different failures, although I don't know
> how difficult that would be to implement. This came up from wanting to 
test
> a Docker container for ability to install many different packages within
> it, and doing this by making a (hacked and specific to my purpose of
> installing/testing one package at a time) wrapper around
> `BiocManager::install()` that uses require() to test whether the
> installation was successful. That said, the workaround was not that
> difficult and it's probably not a priority for too many other users if
> you're hesitant to change the return value of BiocManager::install().
>
> installcheck <- function(x){
>   if (x %in% installed.packages())
> return(TRUE)
>   BiocManager::install(x, ask=FALSE, update=FALSE)
>   res <- require(x, character.only = TRUE)
>   detach(paste0("package:", x), unload=TRUE, character.only = TRUE)
>   return(res)
> }
>
>
>

-- 
Levi Waldron
http://www.waldronlab.io
Associate Professor of BiostatisticsCUNY School of Public Health
US: +1 646-364-9616   Skype:
levi.waldron

[[alternative HTML version deleted]]

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel


Re: [Bioc-devel] return value of BiocManager::install()

2019-01-22 Thread Levi Waldron
BTW I just noticed the alternative approach of searching through the
warnings, used at
https://github.com/Bioconductor/bioc_docker/blob/5be6d37ded4f97995640cbb3a7d201165234b1e4/src/core/install.R.in#L42
:

if (!is.null(warnings()))
{
w <- capture.output(warnings())
if (length(grep("is not available|had non-zero exit status", w)))
quit("no", 1L)
}


On Tue, Jan 22, 2019 at 10:19 AM Levi Waldron 
wrote:

> I opened an issue on BiocManager (
> https://github.com/Bioconductor/BiocManager/issues/39) somewhat related
> to Sean's recent post, about what BiocManager::install() should return, and
> it occurs to me that I should mention it here too for feedback:
>
> > Having `BiocManager::install()` return the "pkgs" argument is not
> especially useful. Could it instead return success/error codes? Otherwise,
> how can you tell in a script whether the requested packages were installed
> successfully or not?
>
> The most basic return value I can think of would be like `require()`, TRUE
> if successful and FALSE if unsuccessful. More sophisticated behavior could
> give different error codes for different failures, although I don't know
> how difficult that would be to implement. This came up from wanting to test
> a Docker container for ability to install many different packages within
> it, and doing this by making a (hacked and specific to my purpose of
> installing/testing one package at a time) wrapper around
> `BiocManager::install()` that uses require() to test whether the
> installation was successful. That said, the workaround was not that
> difficult and it's probably not a priority for too many other users if
> you're hesitant to change the return value of BiocManager::install().
>
> installcheck <- function(x){
>   if (x %in% installed.packages())
> return(TRUE)
>   BiocManager::install(x, ask=FALSE, update=FALSE)
>   res <- require(x, character.only = TRUE)
>   detach(paste0("package:", x), unload=TRUE, character.only = TRUE)
>   return(res)
> }
>
>
>

-- 
Levi Waldron
http://www.waldronlab.io
Associate Professor of BiostatisticsCUNY School of Public Health
US: +1 646-364-9616   Skype:
levi.waldron

[[alternative HTML version deleted]]

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel


[Bioc-devel] return value of BiocManager::install()

2019-01-22 Thread Levi Waldron
I opened an issue on BiocManager (
https://github.com/Bioconductor/BiocManager/issues/39) somewhat related to
Sean's recent post, about what BiocManager::install() should return, and it
occurs to me that I should mention it here too for feedback:

> Having `BiocManager::install()` return the "pkgs" argument is not
especially useful. Could it instead return success/error codes? Otherwise,
how can you tell in a script whether the requested packages were installed
successfully or not?

The most basic return value I can think of would be like `require()`, TRUE
if successful and FALSE if unsuccessful. More sophisticated behavior could
give different error codes for different failures, although I don't know
how difficult that would be to implement. This came up from wanting to test
a Docker container for ability to install many different packages within
it, and doing this by making a (hacked and specific to my purpose of
installing/testing one package at a time) wrapper around
`BiocManager::install()` that uses require() to test whether the
installation was successful. That said, the workaround was not that
difficult and it's probably not a priority for too many other users if
you're hesitant to change the return value of BiocManager::install().

installcheck <- function(x){
  if (x %in% installed.packages())
return(TRUE)
  BiocManager::install(x, ask=FALSE, update=FALSE)
  res <- require(x, character.only = TRUE)
  detach(paste0("package:", x), unload=TRUE, character.only = TRUE)
  return(res)
}

[[alternative HTML version deleted]]

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel