Skip to content

Commit

Permalink
Merge pull request #82 from dominikl/merge_ci
Browse files Browse the repository at this point in the history
Add possibility to use merge-ci java libs
  • Loading branch information
jburel authored Jan 16, 2020
2 parents cd03155 + 203f6b0 commit babf551
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
31 changes: 27 additions & 4 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,40 @@
zipFile <- 'OMERO.java.zip'

getLibs <- Sys.getenv("OMERO_LIBS_DOWNLOAD", unset = NA)
if (!is.na(getLibs) && as.logical(getLibs) == TRUE) {
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) {
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 <- substr(res[[1]], 2, nchar(res[[1]])-1)
baseURL <- getLibs
if (endsWith(getLibs, '/'))
baseURL <- paste(baseURL, "artifact/src/target", sep = '')
else
baseURL <- paste(baseURL, "artifact/src/target", sep = '/')
acc <- 'y'
}
}
else if (!is.na(getLibs) && as.logical(getLibs) == TRUE) {
acc <- 'y'
} else {
packageStartupMessage('Have to download OMERO Java libraries ', baseURL, '/', zipFile, '\nProceed? [y/n]')
packageStartupMessage('Have to download OMERO Java libraries from downloads.openmicroscopy.org.\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
Expand Down
4 changes: 3 additions & 1 deletion jupyter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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/
Expand Down

0 comments on commit babf551

Please sign in to comment.