From f59741441012172c03a48c9d6c236da8c14005b5 Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Wed, 24 Jul 2019 10:25:05 +0100 Subject: [PATCH 1/5] Add possibility to use merge-ci java libs --- R/zzz.R | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index 7b06c2b..cf08693 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -22,17 +22,27 @@ zipFile <- 'OMERO.java.zip' getLibs <- Sys.getenv("OMERO_LIBS_DOWNLOAD", unset = NA) - if (!is.na(getLibs) && as.logical(getLibs) == TRUE) { + if (!is.na(getLibs) && getLibs != 'merge' && as.logical(getLibs) == TRUE) { acc <- 'y' - } else { + } else if (!is.na(getLibs) && getLibs == 'merge') { + git_info <- GET('https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/artifact/src/target/') + git_info <- content(git_info, "text") + ex <- "(OMERO\\.java-\\S+\\.zip)" + r <- gregexpr(ex, git_info) + res <- regmatches(git_info, r) + zipFile <- res[[1]][[2]] + baseURL <- "https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/artifact/src/target" + acc <- 'y' + }else { packageStartupMessage('Have to download OMERO Java libraries ', baseURL, '/', zipFile, '\nProceed? [y/n]') acc <- readLines(con = stdin(), n=1, ok=TRUE) } if (length(acc) > 0 && (acc[[1]] == 'y' || acc[[1]] == 'Y')) { - packageStartupMessage('Downloading...') dest <- paste(omeroLibs, zipFile, sep = '/') - GET(paste(baseURL, zipFile, sep = '/'), write_disk(dest, overwrite=TRUE)) + dlURL <- paste(baseURL, zipFile, sep = '/') + packageStartupMessage(paste('Downloading', dlURL, '...')) + GET(dlURL, write_disk(dest, overwrite=TRUE)) packageStartupMessage('Extracting...') unzip(dest, exdir = omeroLibs) unzippedLibs <- NA From 29c8b2ea30e9a268ed6f49bac5d64726c55d6e44 Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Fri, 2 Aug 2019 09:36:44 +0100 Subject: [PATCH 2/5] Allow to override OMERO_LIBS_DOWNLOAD in jupyter docker --- jupyter/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index ce6ce18..8107ce3 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -6,6 +6,7 @@ ARG ROMERO_VERSION= ARG ROMERO_BRANCH_USER=ome ARG ROMERO_BRANCH=master ARG INSTALL_SCRIPT_URL=https://raw.githubusercontent.com/ome/rOMERO-gateway/master/install.R +ARG OMERO_LIBS_DOWNLOAD=TRUE USER root RUN apt-get update -y && \ @@ -30,13 +31,14 @@ RUN conda env update -n r-omero -q -f .setup/environment-r-omero.yml && \ # build/install rOMERO ENV _JAVA_OPTIONS="-Xss2560k -Xmx2g" + RUN cd /opt/romero && \ curl -sf $INSTALL_SCRIPT_URL --output install.R RUN if [ -z ${ROMERO_VERSION} ]; then \ bash -c "source activate r-omero && Rscript /opt/romero/install.R --user=$ROMERO_BRANCH_USER --branch=$ROMERO_BRANCH --quiet"; else \ bash -c "source activate r-omero && Rscript /opt/romero/install.R --version=$ROMERO_VERSION --quiet"; fi -ENV OMERO_LIBS_DOWNLOAD=TRUE +ENV OMERO_LIBS_DOWNLOAD=${OMERO_LIBS_DOWNLOAD} RUN bash -c "source activate r-omero && echo \"library('romero.gateway')\" | R --no-save" COPY --chown=1000:100 Get_Started.ipynb notebooks/ From d1125fa2692c7bb726b06e17d87afb4dfa20f8ea Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Fri, 2 Aug 2019 10:42:58 +0100 Subject: [PATCH 3/5] Use URL instead of 'merge' for OMERO_LIBS_DOWNLOAD --- R/zzz.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index cf08693..47ecab7 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -22,10 +22,8 @@ zipFile <- 'OMERO.java.zip' getLibs <- Sys.getenv("OMERO_LIBS_DOWNLOAD", unset = NA) - if (!is.na(getLibs) && getLibs != 'merge' && as.logical(getLibs) == TRUE) { - acc <- 'y' - } else if (!is.na(getLibs) && getLibs == 'merge') { - git_info <- GET('https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/artifact/src/target/') + if (!is.na(getLibs) && startsWith(tolower(getLibs), 'http')) { + git_info <- GET(getLibs) git_info <- content(git_info, "text") ex <- "(OMERO\\.java-\\S+\\.zip)" r <- gregexpr(ex, git_info) @@ -33,8 +31,11 @@ zipFile <- res[[1]][[2]] baseURL <- "https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/artifact/src/target" acc <- 'y' - }else { - packageStartupMessage('Have to download OMERO Java libraries ', baseURL, '/', zipFile, '\nProceed? [y/n]') + } + else if (!is.na(getLibs) && as.logical(getLibs) == TRUE) { + acc <- 'y' + } else { + packageStartupMessage('Have to download OMERO Java libraries from downloads.openmicroscopy.org.\nProceed? [y/n]') acc <- readLines(con = stdin(), n=1, ok=TRUE) } From 0abb93a87e48cc68e653db68683bf5f3da7cd98a Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Fri, 2 Aug 2019 11:15:19 +0100 Subject: [PATCH 4/5] Check status code --- R/zzz.R | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index 47ecab7..f807a59 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -24,13 +24,21 @@ getLibs <- Sys.getenv("OMERO_LIBS_DOWNLOAD", unset = NA) if (!is.na(getLibs) && startsWith(tolower(getLibs), 'http')) { git_info <- GET(getLibs) - git_info <- content(git_info, "text") - ex <- "(OMERO\\.java-\\S+\\.zip)" - r <- gregexpr(ex, git_info) - res <- regmatches(git_info, r) - zipFile <- res[[1]][[2]] - baseURL <- "https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/artifact/src/target" - acc <- 'y' + status <- status_code(git_info) + if (status != 200) { + packageStartupMessage("Request failed. ", getLibs, " returned ", status) + acc <- 'n' + } else { + git_info <- content(git_info, "text") + ex <- "(OMERO\\.java-\\S+\\.zip)" + r <- gregexpr(ex, git_info) + res <- regmatches(git_info, r) + zipFile <- res[[1]][[2]] + baseURL <- getLibs + if (endsWith(getLibs, '/')) + baseURL <- substr(baseURL, 1, nchar(baseURL)-1) + acc <- 'y' + } } else if (!is.na(getLibs) && as.logical(getLibs) == TRUE) { acc <- 'y' From 203f6b0d625addceb98f709e6bf3f1924edf7522 Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Wed, 7 Aug 2019 10:54:06 +0100 Subject: [PATCH 5/5] Use shorter URL for OMERO_LIBS_DOWNLOAD --- R/zzz.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index f807a59..0196505 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -23,6 +23,8 @@ getLibs <- Sys.getenv("OMERO_LIBS_DOWNLOAD", unset = NA) if (!is.na(getLibs) && startsWith(tolower(getLibs), 'http')) { + # Allows using Java libs from merge-ci builds, e.g. + # https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/ git_info <- GET(getLibs) status <- status_code(git_info) if (status != 200) { @@ -30,13 +32,15 @@ acc <- 'n' } else { git_info <- content(git_info, "text") - ex <- "(OMERO\\.java-\\S+\\.zip)" + ex <- ">(OMERO\\.java-\\S+\\.zip)<" r <- gregexpr(ex, git_info) res <- regmatches(git_info, r) - zipFile <- res[[1]][[2]] + zipFile <- substr(res[[1]], 2, nchar(res[[1]])-1) baseURL <- getLibs if (endsWith(getLibs, '/')) - baseURL <- substr(baseURL, 1, nchar(baseURL)-1) + baseURL <- paste(baseURL, "artifact/src/target", sep = '') + else + baseURL <- paste(baseURL, "artifact/src/target", sep = '/') acc <- 'y' } }