Skip to content

Commit 777deed

Browse files
Merge pull request #245 from Dana-Farber-AIOS/docker-ci
Docker ci
2 parents 2721cb7 + fb81faf commit 777deed

File tree

6 files changed

+166
-6
lines changed

6 files changed

+166
-6
lines changed

.dockerignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
4+
# Unit test / coverage reports
5+
.pytest_cache/
6+
coverage_report_html/
7+
.coverage
8+
9+
# Sphinx documentation
10+
docs/build/
11+
12+
# data
13+
data/
14+
15+
# files created by matplotlib testing suite
16+
result_images/
17+
18+
# distribution / packaging
19+
*.egg-info
20+
*.egg
21+
build/
22+
dist/
23+
24+
# Jupyter Notebook
25+
.ipynb_checkpoints
26+
27+
# scratch notebook
28+
scratch.ipynb
29+
30+
# Mac files
31+
.DS_Store
32+
33+
# Pycharm
34+
.idea/
35+
36+
# dask
37+
dask-worker-space/
38+
39+
# git
40+
.git
41+
.gitigore
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish PathML Docker image on Docker Hub
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Set version number variable
12+
run: |
13+
VER=$(cat pathml/_version.py | grep -o '"[^"]\+"' | tr '"' ' ')
14+
echo "VERSION=$VER" >> $GITHUB_ENV
15+
- name: Set up QEMU
16+
uses: docker/[email protected]
17+
- name: Set up Docker Buildx
18+
uses: docker/[email protected]
19+
- name: Login to DockerHub
20+
uses: docker/[email protected]
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
- name: Build and push
25+
id: docker_build
26+
uses: docker/[email protected]
27+
with:
28+
push: true
29+
tags:
30+
pathml/pathml:latest
31+
pathml/pathml:${{ env.VERSION }}

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM ubuntu:20.04
4+
# LABEL about the custom image
5+
LABEL maintainer="[email protected]"
6+
LABEL description="This is custom Docker Image for running PathML"
7+
8+
# Disable Prompt During Packages Installation
9+
ARG DEBIAN_FRONTEND=noninteractive
10+
11+
#Set miniconda path
12+
ENV PATH="/root/miniconda3/bin:${PATH}"
13+
ARG PATH="/root/miniconda3/bin:${PATH}"
14+
15+
ENV JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/"
16+
ARG JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/"
17+
18+
ENV SHELL="/bin/bash"
19+
20+
#install packages on root
21+
USER root
22+
23+
#download and install miniconda and external dependencies
24+
RUN apt-get update && apt-get install -y --no-install-recommends openslide-tools \
25+
g++ \
26+
gcc \
27+
libpixman-1-0 \
28+
libblas-dev \
29+
liblapack-dev \
30+
wget \
31+
openjdk-8-jre \
32+
openjdk-8-jdk \
33+
&& wget \
34+
https://repo.anaconda.com/miniconda/Miniconda3-py38_4.10.3-Linux-x86_64.sh \
35+
&& mkdir /root/.conda \
36+
&& bash Miniconda3-py38_4.10.3-Linux-x86_64.sh -b \
37+
&& rm -f Miniconda3-py38_4.10.3-Linux-x86_64.sh \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
# copy pathml files into docker
41+
COPY setup.py README.md /opt/pathml/
42+
COPY pathml/ /opt/pathml/pathml
43+
COPY tests/ /opt/pathml/tests
44+
45+
# install pathml and deepcell
46+
RUN pip3 install --upgrade pip \
47+
&& pip3 install numpy==1.19.5 \
48+
&& pip3 install python-bioformats==4.0.0 deepcell /opt/pathml/ pytest
49+
50+
# run tests to verify container
51+
WORKDIR /opt/pathml
52+
RUN python3 -m pytest /opt/pathml/tests/ -m "not slow"
53+
54+
WORKDIR /home/pathml
55+
56+
# set up jupyter lab
57+
RUN pip3 install jupyter -U && pip3 install jupyterlab
58+
EXPOSE 8888
59+
ENTRYPOINT ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--no-browser"]

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ There are several ways to install `PathML`:
2626

2727
1. pip install (**recommended for users**)
2828
2. clone repo to local machine and install from source (recommended for developers/contributors)
29+
3. Use the PathML Docker container
2930

3031
Options (1) and (2) require that you first install all external dependencies:
3132
* openslide
@@ -87,6 +88,29 @@ Install `PathML`:
8788
pip install -e .
8889
````
8990

91+
## Installation option 3: docker
92+
93+
Build the PathML docker container:
94+
````
95+
docker build -t pathml-analysis .
96+
````
97+
98+
Connect to the container:
99+
````
100+
docker run -it -p 8888:8888 pathml-analysis
101+
````
102+
103+
The above command runs the container, which is configured to spin up a jupyter lab session and expose it on port 8888.
104+
The terminal should display a URL to the jupyter lab session starting with http://127.0.0.1:8888/lab?token=<...>.
105+
Navigate to that page and you should connect to the jupyter lab session running on the container with the pathml
106+
environment fully configured.
107+
108+
Note that the docker container requires extra configurations to use with GPU.
109+
Note that these instructions assume that there are no other processes using port 8888.
110+
111+
Please refer to the `Docker run` [documentation](https://docs.docker.com/engine/reference/run/) for further instructions
112+
on accessing the container, e.g. for mounting volumes to access files on a local machine from within the container.
113+
90114
## CUDA
91115

92116
To use GPU acceleration for model training or other tasks, you must install CUDA.

pathml/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
License: GNU GPL 2.0
44
"""
55

6-
__version__ = "2.0.1"
6+
__version__ = "2.0.dev1"

pathml/core/slide_backends.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55

66
from io import BytesIO
77
from typing import Tuple
8-
98
import numpy as np
109
import openslide
11-
import pathml.core
12-
import pathml.core.tile
13-
from pathml.utils import pil_to_rgb
1410
from PIL import Image
1511
from pydicom.dataset import Dataset
1612
from pydicom.encaps import get_frame_offsets
@@ -19,6 +15,11 @@
1915
from pydicom.tag import SequenceDelimiterTag, TupleTag
2016
from pydicom.uid import UID
2117
from scipy.ndimage import zoom
18+
from javabridge.jutil import JavaException
19+
20+
import pathml.core
21+
import pathml.core.tile
22+
from pathml.utils import pil_to_rgb
2223

2324
try:
2425
import bioformats
@@ -255,7 +256,11 @@ def __init__(self, filename):
255256
self.filename = filename
256257
# init java virtual machine
257258
javabridge.start_vm(class_path=bioformats.JARS, max_heap_size="50G")
258-
_init_logger()
259+
# disable verbose JVM logging if possible
260+
try:
261+
_init_logger()
262+
except JavaException:
263+
pass
259264
# java maximum array size of 2GB constrains image size
260265
ImageReader = bioformats.formatreader.make_image_reader_class()
261266
reader = ImageReader()

0 commit comments

Comments
 (0)