From 8fa5147ff387e609316bedb6257dd0e334fb835d Mon Sep 17 00:00:00 2001 From: Ben Tupper Date: Mon, 15 Aug 2022 13:28:08 -0400 Subject: [PATCH 1/4] add remotes install that returns 0/1 --- r/install.R | 45 +++++++++++++++++++++++++++++++++++++++++++++ r/remotes.yml | 22 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 r/install.R create mode 100644 r/remotes.yml diff --git a/r/install.R b/r/install.R new file mode 100644 index 0000000..d51e283 --- /dev/null +++ b/r/install.R @@ -0,0 +1,45 @@ +# Install one or more R packages using remotes package +# +# Input/Output: +# @param single argument with fully qualified name to (yaml) configuration file +# @return 0 for success, non-zero if an issue arises. Fails soon. +# +# Usage: +# Rscript /path/to/install.R /path/to/remotes.yml +# +library(yaml) +library(remotes) + +x <- yaml::read_yaml(commandArgs(trailingOnly = TRUE)[1]) + +args <- x$extra + +if ('install_cran' %in% names(x)){ + for (p in x[['install_cran']]){ + ok <- try(remotes::install_cran(p, + dependencies=args$dependencies, + upgrade_dependencies=args$upgrade_dependencies, + upgrade=args$upgrade)) + if (inherits(ok, 'try-error')){ + print("unable to install package:", p) + print(ok) + quit(save = "no", status = 1) + } + } +} + +if ('install_github' %in% names(x)){ + for (p in x[['install_github']]){ + ok <- try(remotes::install_github(p, + dependencies=args$dependencies, + upgrade_dependencies=args$upgrade_dependencies, + upgrade=args$upgrade)) + if (inherits(ok, 'try-error')){ + + print(ok) + quit(save = "no", status = 1) + } + } +} + +quit(save = "no", status = 0) \ No newline at end of file diff --git a/r/remotes.yml b/r/remotes.yml new file mode 100644 index 0000000..1d8cbf5 --- /dev/null +++ b/r/remotes.yml @@ -0,0 +1,22 @@ +extra: + dependencies: no + upgrade_dependencies: no + upgrade: no +install_cran: +- assertthat +- ggspatial +- plot.matrix +- isdparser +- geonames +- rnoaa +install_github: +- hadley/emo +- BigelowLab/ohwobpg +- BigelowLab/rasf +- BigelowLab/xyzt +- BigelowLab/ghrsst +- BigelowLab/bsw +- BigelowLab/ersst +- BigelowLab/ersst +- BigelowLab/hycom +- kwstat/pals From 25035df3731c6eb555a7389dbdf9a7f31d46969e Mon Sep 17 00:00:00 2001 From: Ben Tupper Date: Mon, 15 Aug 2022 13:30:44 -0400 Subject: [PATCH 2/4] modify docker file to run remotes installer script --- r/Dockerfile | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/r/Dockerfile b/r/Dockerfile index 697ddf5..6b6b9de 100644 --- a/r/Dockerfile +++ b/r/Dockerfile @@ -75,21 +75,22 @@ ARG MAMBA_DOCKERFILE_ACTIVATE=1 # Install BigelowLab dev R libs # RUN installGithub.R BigelowLab/rasf BigelowLab/ohwobpg # not working on GH but works locally :-/ -RUN Rscript -e "remotes::install_cran('assertthat', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('ggspatial', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('plot.matrix', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('isdparser', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('geonames', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_cran('rnoaa', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('hadley/emo', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/ohwobpg', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/rasf', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/xyzt', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/ghrsst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/bsw', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/ersst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('BigelowLab/hycom', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ - Rscript -e "remotes::install_github('kwstat/pals', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" +#RUN Rscript -e "remotes::install_cran('assertthat', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('ggspatial', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('plot.matrix', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('isdparser', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('geonames', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_cran('rnoaa', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('hadley/emo', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/ohwobpg', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/rasf', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/xyzt', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/ghrsst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/bsw', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/ersst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('BigelowLab/hycom', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ +# Rscript -e "remotes::install_github('kwstat/pals', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" +RUN Rscript install.R remotes.yml COPY CONDARC ./.condarc From f5babec82653995b7f1e5f0b0c8c9f8a491617f4 Mon Sep 17 00:00:00 2001 From: Ben Tupper Date: Mon, 15 Aug 2022 21:11:52 -0400 Subject: [PATCH 3/4] Update r/Dockerfile Adds script copy Co-authored-by: Alex Kerney --- r/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/r/Dockerfile b/r/Dockerfile index 6b6b9de..e5b3b31 100644 --- a/r/Dockerfile +++ b/r/Dockerfile @@ -90,6 +90,8 @@ ARG MAMBA_DOCKERFILE_ACTIVATE=1 # Rscript -e "remotes::install_github('BigelowLab/ersst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ # Rscript -e "remotes::install_github('BigelowLab/hycom', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ # Rscript -e "remotes::install_github('kwstat/pals', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" +COPY ./install.R ./ + RUN Rscript install.R remotes.yml COPY CONDARC ./.condarc From 1567dd2c5a4d04986f9b4b19762380ea82d4d4eb Mon Sep 17 00:00:00 2001 From: Ben Tupper Date: Mon, 15 Aug 2022 21:48:38 -0400 Subject: [PATCH 4/4] Update r/Dockerfile Co-authored-by: Alex Kerney --- r/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/Dockerfile b/r/Dockerfile index e5b3b31..c513971 100644 --- a/r/Dockerfile +++ b/r/Dockerfile @@ -90,7 +90,7 @@ ARG MAMBA_DOCKERFILE_ACTIVATE=1 # Rscript -e "remotes::install_github('BigelowLab/ersst', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ # Rscript -e "remotes::install_github('BigelowLab/hycom', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" && \ # Rscript -e "remotes::install_github('kwstat/pals', dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE)" -COPY ./install.R ./ +COPY ./install.R ./remotes.yml ./ RUN Rscript install.R remotes.yml