Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
add Docker for experiments (#51)
Browse files Browse the repository at this point in the history
* base image
* docker build
* fix init imports
* docker: add Fiji
* docker: add ANTs
* docker: add ANTsPy
* docker: add elastix
* docker: add DROP
* docker: add RNiftyREg
* update tox / travis
  • Loading branch information
Borda committed Jul 9, 2020
1 parent 2237bf1 commit 1c9432f
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 27 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Docker Image
# https://www.docker.com/blog/first-docker-github-action-is-here
# https://github.com/docker/build-push-action
on:
push:
branches:
- master

jobs:
build-push:
runs-on: ubuntu-20.04
strategy:
matrix:
python_version: [3.6, 3.7]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Build and Publish to Docker Hub
# publish master
uses: docker/build-push-action@v1.1.0
# TODO: push to master
# if: github.event_name == 'push'
with:
repository: borda/birl
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: bm_experiments/Dockerfile
build_args: PYTHON_VERSION=${{ matrix.python_version }}
tags: "SOTA-py${{ matrix.python_version }}"
# timeout-minutes: 50
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ matrix:
python: 2.7
dist: xenial # Ubuntu 16.04
env: TOXENV=py27
- os: linux
language: python
python: 3.5
dist: xenial # Ubuntu 16.04
env: TOXENV=py35
#- os: linux
# language: python
# python: 3.5
# dist: xenial # Ubuntu 16.04
# env: TOXENV=py35
- os: linux
language: python
python: 3.6
Expand All @@ -36,6 +36,11 @@ matrix:
python: 3.7
dist: bionic # Ubuntu 18.04
env: TOXENV=py37
- os: linux
language: python
python: 3.8
dist: bionic # Ubuntu 18.04
env: TOXENV=py38
- os: osx
osx_image: xcode10.3
language: generic
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ recursive-include assets *.jpg
recursive-include bm_dataset *.py
recursive-include bm_experiments *.py
recursive-exclude bm_experiments *.sh
exclude bm_experiments/Dockerfile

# exclude tests from package
recursive-exclude tests *
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,31 @@ python bm_experiments/bm_comp_perform.py -o ./results
```
This script generate simple report exported in JSON file on given output path.

### Prepared experimental docker image

Used prepared docker image from [Docker Hub](https://hub.docker.com/repository/docker/borda/birl)

```bash
docker run --rm -it borda/birl:SOTA-py3.7 bash
```

You can build it on your own, note it takes lots of time, be prepared.

```bash
git clone <git-repository>
docker image build \
-t birl:py3.6 \
-f bm_experiments/Dockerfile \
--build-arg PYTHON_VERSION=3.6 \
.
```

To run your docker use

```bash
docker image list
docker run --rm -it birl:py3.6 bash
```

### Included registration methods

Expand Down
51 changes: 31 additions & 20 deletions birl/utilities/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
import os
import subprocess
from distutils.version import LooseVersion

import matplotlib
import numpy as np
import pandas as pd
try:
import matplotlib
except ImportError:
print('Package `matplotlib` which shall be configured are missing...')
else:
CMD_TRY_MATPLOTLIB = 'python -c "from matplotlib import pyplot; pyplot.close(pyplot.figure())"'
# in case you are running on machine without display, e.g. server
if not os.environ.get('DISPLAY', '') and matplotlib.rcParams['backend'] != 'agg':
print('No display found. Using non-interactive Agg backend')
matplotlib.use('Agg')
# _tkinter.TclError: couldn't connect to display "localhost:10.0"
elif subprocess.call(CMD_TRY_MATPLOTLIB, stdout=None, stderr=None, shell=True):
print('Problem with display. Using non-interactive Agg backend')
matplotlib.use('Agg')


CMD_TRY_MATPLOTLIB = 'python -c "from matplotlib import pyplot; pyplot.close(pyplot.figure())"'
# in case you are running on machine without display, e.g. server
if not os.environ.get('DISPLAY', '') and matplotlib.rcParams['backend'] != 'agg':
print('No display found. Using non-interactive Agg backend')
matplotlib.use('Agg')
# _tkinter.TclError: couldn't connect to display "localhost:10.0"
elif subprocess.call(CMD_TRY_MATPLOTLIB, stdout=None, stderr=None, shell=True):
print('Problem with display. Using non-interactive Agg backend')
matplotlib.use('Agg')
try:
import numpy as np
except ImportError:
print('Package `numpy` which shall be configured are missing...')
else:
# comparing strings does not work for version lower 1.10
if LooseVersion(np.version.full_version) >= LooseVersion('1.14'):
# np.set_printoptions(sign='legacy')
np.set_printoptions(legacy='1.13')

# parse the numpy versions
np_version = [int(i) for i in np.version.full_version.split('.')]
# comparing strings does not work for version lower 1.10
if np_version >= [1, 14]:
# np.set_printoptions(sign='legacy')
np.set_printoptions(legacy='1.13')

# default display size was changed in pandas v0.23
pd.set_option('display.max_columns', 20)
try:
import pandas as pd
except ImportError:
print('Package `pandas` which shall be configured are missing...')
else:
# default display size was changed in pandas v0.23
pd.set_option('display.max_columns', 20)
2 changes: 1 addition & 1 deletion bm_ANHIR/automatic-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ docker image ls
**Cleaning**
In case you fail with some builds, you may need to clean your local storage.
```bash
docker image prune
docker system prune
```
or [Docker - How to cleanup (unused) resources](https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430)
```bash
Expand Down
Loading

0 comments on commit 1c9432f

Please sign in to comment.