-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from dominikl/jupyter_docker
Jupyter docker
- Loading branch information
Showing
6 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ | |
^inst$ | ||
^java$ | ||
^CHANGELOG.md$ | ||
^jupyter$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM imagedata/jupyter-docker:0.9.0 | ||
MAINTAINER ome-devel@lists.openmicroscopy.org.uk | ||
|
||
# The branch to build the romero.gateway from | ||
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 | ||
|
||
# R-kernel and R-OMERO prerequisites | ||
ADD environment-r-omero.yml .setup/ | ||
RUN conda env update -n r-omero -q -f .setup/environment-r-omero.yml && \ | ||
/opt/conda/envs/r-omero/bin/Rscript -e "IRkernel::installspec(displayname='OMERO R')" | ||
|
||
USER root | ||
RUN mkdir /opt/romero /opt/omero && \ | ||
fix-permissions /opt/romero /opt/omero | ||
# R requires these two packages at runtime | ||
RUN apt-get install -y -q \ | ||
libxrender1 \ | ||
libsm6 | ||
USER $NB_UID | ||
|
||
# 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 | ||
RUN bash -c "source activate r-omero && echo \"library('romero.gateway')\" | R --no-save" | ||
|
||
COPY --chown=1000:100 Get_Started.ipynb notebooks/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Load library and connect to an OMERO server" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"library(romero.gateway)\n", | ||
"library(EBImage) # for displaying an image (also useful for image analysis!)\n", | ||
"\n", | ||
"# Connect to server\n", | ||
"server <- OMEROServer(host = 'SERVER_NAME', username='USER_NAME', password='PASSWORD', port= as.integer(4064))\n", | ||
"server <- connect(server)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Perform some tasks" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Load an image\n", | ||
"imageId <- IMAGE_ID # Replace with an actual image id\n", | ||
"image <- loadObject(server, \"ImageData\", imageId)\n", | ||
"pixels <- getPixelValues(image, 1, 1, 1)\n", | ||
"\n", | ||
"# Use EBImage to display it\n", | ||
"ebimage <- EBImage::Image(data = pixels, colormode = 'Grayscale')\n", | ||
"ebimage <- normalize(ebimage)\n", | ||
"EBImage::display(ebimage)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Disconnect again" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"disconnect(server)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "OMERO R", | ||
"language": "R", | ||
"name": "ir" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "r", | ||
"file_extension": ".r", | ||
"mimetype": "text/x-r-source", | ||
"name": "R", | ||
"pygments_lexer": "r", | ||
"version": "3.5.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Jupyter server | ||
============== | ||
|
||
Spin up a Jupyter server with Docker: | ||
|
||
CD into this directory and run: | ||
``` | ||
docker build -t romero . | ||
``` | ||
(this will build the romero.gateway from the current ome/master branch) | ||
|
||
Run the docker image: | ||
``` | ||
docker run -it -p 8888:8888 romero | ||
``` | ||
|
||
Go to the respective URL in your browser and open the `Get_Started` notebook in `notebooks`, | ||
or create a new 'OMERO R' notebook from scratch! | ||
|
||
Notes: | ||
- If you want to build a specific version or branch use: | ||
``` | ||
docker build --build-arg ROMERO_VERSION=0.4.5 . | ||
docker build --build-arg ROMERO_BRANCH_USER=ome --build-arg ROMERO_BRANCH=master . | ||
``` | ||
- The Dockerfile uses the [install.R](../install.R) script from the master branch. | ||
You can specify a different script with the `INSTALL_SCRIPT_URL` parameter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Install some common, useful R packages. These are | ||
# not all strictly necessary for romero.gateway. | ||
channels: | ||
- bioconda | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- bioconductor-ebimage | ||
- openjdk=8.0.* | ||
- r-assertthat | ||
- r-base=3.5.* | ||
- r-devtools | ||
- r-git2r | ||
- r-httr | ||
- r-irdisplay | ||
- r-irkernel | ||
- r-jpeg | ||
- r-repr | ||
- r-rjava | ||
- r-roxygen2 | ||
- r-testthat | ||
- r-tidyverse | ||
- r-xml2 | ||
- r-getpass | ||
prefix: /opt/conda/envs/r-omero |