diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index 03110724..641aada4 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -41,6 +41,8 @@ jobs: if: matrix.python-version == 2.7 run: | cp -r requirements-py27.txt requirements.txt + # required for matplotlib @py2 + pip install -U backports.functools_lru_cache - name: Set min. dependencies if: matrix.requires == 'minimal' @@ -66,8 +68,6 @@ jobs: - name: Install dependencies run: | pip install $(grep "numpy" requirements.txt) - # required for matplotlib @py2 - pip install -U backports.functools_lru_cache # v46 crashes openslide-python install pip install "setuptools<46" -U pip install --requirement requirements.txt --quiet --upgrade @@ -77,15 +77,18 @@ jobs: pip list shell: bash - - name: Tests - env: - DISPLAY: "" + - name: Pkg install run: | - check-manifest --ignore tox.ini + check-manifest python setup.py check --metadata --strict python setup.py install --dry-run --user - coverage run --source birl -m py.test birl tests bm_dataset bm_experiments bm_ANHIR -v --doctest-modules --durations=25 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml - flake8 . + + - name: Tests and coverage + env: + DISPLAY: "" + run: | + coverage run --source birl -m pytest birl tests bm_dataset bm_experiments bm_ANHIR -v --durations=25 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml + # flake8 . - name: Upload pytest test results uses: actions/upload-artifact@master @@ -107,8 +110,6 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} file: coverage.xml - flags: cpu,pytest - name: CPU-coverage fail_ci_if_error: false - name: Run sample experiment diff --git a/.travis.yml b/.travis.yml index c2662086..83b55c0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,6 @@ matrix: language: python python: 2.7 dist: xenial # Ubuntu 16.04 - env: TOXENV=py27 #- os: linux # language: python # python: 3.5 @@ -30,21 +29,17 @@ matrix: language: python python: 3.6 dist: bionic # Ubuntu 18.04 - env: TOXENV=py36 - os: linux language: python 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 - env: TOXENV=py37 addons: homebrew: # update: true @@ -69,7 +64,6 @@ matrix: - python -m pip install --upgrade pip - choco install -y opencv env: - - TOXENV=py37 - PATH=/c/Python37:/c/Python37/Scripts:%OPENCV_DIR%/bin:$PATH # https://towardsdatascience.com/extensive-python-testing-on-travis-ci-4c24db9bf961 allow_failures: @@ -97,7 +91,10 @@ install: script: # integration - - tox -v + - check-manifest + - python setup.py check --metadata --strict + - python setup.py install --dry-run + - coverage run --source birl -m pytest birl tests bm_dataset bm_experiments bm_ANHIR -v # sample run - mkdir results && touch configs/sample_config.yaml - python bm_experiments/bm_comp_perform.py -o ./results -n 1 diff --git a/README.md b/README.md index f884c8c2..0a774011 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # BIRL: Benchmark on Image Registration methods with Landmark validation -[![Build Status](https://travis-ci.org/Borda/BIRL.svg?branch=master)](https://travis-ci.org/Borda/BIRL) +[![Build Status](https://travis-ci.com/Borda/BIRL.svg?branch=master)](https://travis-ci.com/Borda/BIRL) [![CircleCI](https://circleci.com/gh/Borda/BIRL.svg?style=svg&circle-token=e58b9845aab1b02d749df60060afbac54138ea28)](https://circleci.com/gh/Borda/BIRL) [![Build status](https://ci.appveyor.com/api/projects/status/rmfvuxix379eu6fh/branch/master?svg=true)](https://ci.appveyor.com/project/Borda/birl/branch/master) [![codecov](https://codecov.io/gh/Borda/BIRL/branch/master/graph/badge.svg?token=JZwA1rlUGA)](https://codecov.io/gh/Borda/BIRL) diff --git a/appveyor.yml b/appveyor.yml index 020f8c54..343985f5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,22 +14,18 @@ environment: #- PYTHON: "C:\\Python27" # PYTHON_VERSION: "2.7.x" # PYTHON_ARCH: "32" - # TOXENV: "py27" #- PYTHON: "C:\\Python27-x64" # PYTHON_VERSION: "2.7.x" # PYTHON_ARCH: "64" - # TOXENV: "py27" #- PYTHON: "C:\\Python36-x64" # PYTHON_VERSION: "3.6.x" # PYTHON_ARCH: "64" - # TOXENV: "py36" - PYTHON: "C:\\Python37-x64" PYTHON_VERSION: "3.7.x" PYTHON_ARCH: "64" - TOXENV: "py37" build: off @@ -55,7 +51,6 @@ install: - pip install "setuptools<46" -U # v46 crashes openslide-python install - pip install -r requirements.txt - pip install -r ./tests/requirements.txt - - pip install tox # scripts to run before tests (working directory and environment changes are persisted from the previous steps such as "before_build") before_test: @@ -66,7 +61,7 @@ before_test: # to run your custom scripts instead of automatic tests test_script: - - tox -v --sitepackages --parallel auto + - coverage run --source birl -m pytest birl tests bm_dataset bm_experiments bm_ANHIR -v - mkdir results && touch configs/sample_config.yaml - python bm_experiments/bm_comp_perform.py -o ./results -n 1 - python birl/bm_template.py -n anhir -t ./data-images/pairs-imgs-lnds_mix.csv -o ./results --preprocessing matching-rgb gray --unique --visual -cfg configs/sample_config.yaml diff --git a/birl/utilities/drawing.py b/birl/utilities/drawing.py index 86a7c630..190abd7b 100644 --- a/birl/utilities/drawing.py +++ b/birl/utilities/drawing.py @@ -32,21 +32,21 @@ def draw_image_points(image, points, color='green', marker_size=5, shape='o'): :return: np.ndarray >>> image = np.zeros((10, 10, 3)) - >>> points = np.array([[7, 9], [2, 2], [5, 5]]) - >>> img = draw_image_points(image, points, marker_size=1) + >>> points = np.array([[9, 1], [2, 2], [5, 5]]) + >>> img = draw_image_points(image, points, marker_size=1, shape='s') >>> img.shape == (10, 10, 3) # Windows x64 returns (10L, 10L, 3L) True >>> np.round(img[:, :, 1], 2) - array([[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], - [ 0. , 0.5, 0.5, 0.5, 0. , 0. , 0. , 0. , 0. , 0. ], - [ 0. , 0.5, 0. , 0.5, 0. , 0. , 0. , 0. , 0. , 0. ], + array([[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.5, 0.5], + [ 0. , 0.5, 0.5, 0.5, 0. , 0. , 0. , 0. , 0.5, 0. ], + [ 0. , 0.5, 0. , 0.5, 0. , 0. , 0. , 0. , 0.5, 0.5], [ 0. , 0.5, 0.5, 0.5, 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.5, 0.5, 0.5, 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.5, 0. , 0.5, 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.5, 0.5, 0.5, 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], - [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.5, 0. ]]) + [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ]]) >>> img = draw_image_points(None, points, marker_size=1) """ assert list(points), 'missing points' @@ -64,6 +64,8 @@ def draw_image_points(image, points, color='green', marker_size=5, shape='o'): draw.ellipse(pos_marker, outline=color) elif shape == '.': draw.ellipse(pos_marker, fill=color) + elif shape == 's': + draw.rectangle(pos_marker, outline=color) else: draw.ellipse(pos_marker, fill=color, outline=color) draw.text(pos_text, str(i + 1), fill=(0, 0, 0)) diff --git a/bm_ANHIR/Dockerfile b/bm_ANHIR/Dockerfile index 466e8a3c..0f50093b 100644 --- a/bm_ANHIR/Dockerfile +++ b/bm_ANHIR/Dockerfile @@ -2,6 +2,8 @@ FROM python:3.7-slim-stretch #FROM borda/docker_python-opencv-ffmpeg:py3 +LABEL maintainer="jiri.borovec@fel.cvut.cz" + # Install packages RUN apt-get update -qq && apt-get install -y --no-install-recommends \ git>=2.0 \ diff --git a/bm_experiments/Dockerfile b/bm_experiments/Dockerfile index 64de1a3e..f4597944 100644 --- a/bm_experiments/Dockerfile +++ b/bm_experiments/Dockerfile @@ -1,9 +1,10 @@ #FROM ubuntu:bionic FROM ubuntu:20.04 - ARG PYTHON_VERSION=3.7 +LABEL maintainer="jiri.borovec@fel.cvut.cz" + SHELL ["/bin/bash", "-c"] # for installing tzdata see: https://stackoverflow.com/a/58264927/4521646 diff --git a/circle.yml b/circle.yml index 92a292d2..971d568a 100644 --- a/circle.yml +++ b/circle.yml @@ -41,7 +41,7 @@ references: unset DISPLAY pip install -r ./tests/requirements.txt mkdir test-reports && mkdir results - coverage run --source birl -m py.test birl tests bm_dataset bm_experiments bm_ANHIR -v --doctest-modules --junitxml=test-reports/pytest_junit.xml + coverage run --source birl -m pytest birl tests bm_dataset bm_experiments bm_ANHIR -v --junitxml=test-reports/pytest_junit.xml coverage report codecov rm -rf results diff --git a/docs/source/conf.py b/docs/source/conf.py index 5af89dd9..270b7552 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,8 +21,9 @@ import m2r -PATH_ROOT = os.path.join('..', '..') +PATH_UP = os.path.join('..', '..') PATH_HERE = os.path.abspath(os.path.dirname(__file__)) +PATH_ROOT = os.path.abspath(os.path.join(PATH_HERE, PATH_UP)) sys.path.insert(0, os.path.abspath(PATH_ROOT)) import birl # noqa: E402 @@ -65,7 +66,7 @@ readme = re.sub(r'(!\[.*.gif\))', '', readme) for dir_name in (os.path.basename(p) for p in glob.glob(os.path.join(PATH_ROOT, '*')) if os.path.isdir(p)): - readme = readme.replace('](%s/' % dir_name, '](%s/%s/' % (PATH_ROOT, dir_name)) + readme = readme.replace('](%s/' % dir_name, '](%s/%s/' % (PATH_UP, dir_name)) with open('readme.md', 'w') as fp: fp.write(readme) diff --git a/requirements-py27.txt b/requirements-py27.txt index 97cd80e4..0adbf6ec 100644 --- a/requirements-py27.txt +++ b/requirements-py27.txt @@ -1,15 +1,15 @@ -numpy>=1.8.2 +numpy>=1.9 scipy>=0.10.0 pandas>=0.17.1 six>=1.7.3 -pillow>=2.1.0, !=7.1 # 7.x fails to load PNG via skimage +pillow>=4.0, <7 # 7.x fails to load PNG via skimage matplotlib>=2.0.2, <3.0.0 # new version does not support py2 tqdm>=4.7.4, <=4.30 # higher fails ascii for py2 pyyaml scikit-image opencv-python-headless<4.3 openslide-python<=1.1.1 -nibabel +nibabel<3.0 SimpleITK psutil pathos \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8f700f46..e625de3f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ numpy>=1.13.3 scipy>=1.0 pandas>=0.21 six>=1.10 -pillow>=4.0, !=7.1 # 7.x fails to load PNG via skimage +pillow>=4.0, !=7 # 7.x fails to load PNG via skimage matplotlib>=2.0.2 tqdm>=4.7.4 pyyaml>=3.12 diff --git a/setup.cfg b/setup.cfg index c883fb1d..20a325ea 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,16 +8,22 @@ requirements-file = requirements.txt [flake8] # http://flake8.pycqa.org/en/latest/user/configuration.html -ignore = E402,E731 -max-line-length = 100 exclude = .tox,*.egg,build,temp select = E,W,F doctests = True verbose = 2 -# max-complexity = 10 +# https://pep8.readthedocs.io/en/latest/intro.html#error-codes +ignore = + E402 + E501 +format = pylint +max-line-length = 100 [tool:pytest] -log_cli = 1 +addopts = + --doctest-modules + --color=yes +log_cli = 0 log_cli_level = CRITICAL #log_cli_format = %(message)s log_file = pytest.log diff --git a/setup.py b/setup.py index 8a310085..fab1907a 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ """ # Always prefer setuptools over distutils +import sys from os import path from setuptools import setup # io.open is needed for projects that support Python 2.7 @@ -21,10 +22,20 @@ PATH_HERE = path.abspath(path.dirname(__file__)) -with open(path.join(PATH_HERE, 'requirements.txt'), encoding='utf-8') as fp: - reqs = [rq.rstrip() for rq in fp.readlines()] + +def load_requirements(fname='requirements.txt'): + with open(path.join(PATH_HERE, fname), encoding='utf-8') as fp: + reqs = [rq.rstrip() for rq in fp.readlines()] reqs = [ln[:ln.index('#')] if '#' in ln else ln for ln in reqs] - requirements = [ln for ln in reqs if ln] + reqs = [ln for ln in reqs if ln] + return reqs + + +if sys.version_info.major == 2: + requirements = load_requirements('requirements-py27.txt') +else: + requirements = load_requirements('requirements.txt') + # Get the long description from the README file # with open(path.join(PATH_HERE, 'README.md'), encoding='utf-8') as fp: diff --git a/tests/requirements.txt b/tests/requirements.txt index b94ff778..b3ec3bd3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -7,5 +7,4 @@ flake8 check-manifest codacy-coverage parameterized -tox mock \ No newline at end of file diff --git a/tox.ini b/tox.ini deleted file mode 100644 index fa4ebb0d..00000000 --- a/tox.ini +++ /dev/null @@ -1,59 +0,0 @@ -# this file is *not* meant to cover or endorse the use of tox or pytest or testing in general, -# -# It's meant to show the use of: -# -# - check-manifest -# confirm items checked into vcs are in your segdist -# - python setup.py check -# confirm required package meta-data in setup.py -# - readme_renderer (when using a ReStructuredText README) -# confirms your long_description will render correctly on PyPI. -# -# and also to help confirm pull requests to this project. - -[build-system] -requires = [ "pip >= 18.0" ] - -[tox] -envlist = py{27,35,36,37,38} - -[pytest] -log_cli = 0 -log_cli_level = CRITICAL -log_cli_format = %(message)s -log_file = pytest.log -log_file_level = DEBUG -log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) -log_file_date_format=%Y-%m-%d %H:%M:%S - -[testenv] -# https://github.com/tox-dev/tox/issues/791 -download = true -sitepackages = True -basepython = - py27: python2.7 - py35: python3.5 - py36: python3.6 - py37: python3.7 - py38: python3.8 -deps = - -r requirements.txt - -r ./tests/requirements.txt -commands = - check-manifest --ignore tox.ini - python setup.py check --metadata --strict - python setup.py install --dry-run --user - coverage run --source birl -m py.test birl tests bm_dataset bm_experiments bm_ANHIR -v --doctest-modules - flake8 . - -[flake8] -exclude = .tox,*.egg,build,temp -select = E,W,F -doctests = True -verbose = 2 -# https://pep8.readthedocs.io/en/latest/intro.html#error-codes -ignore = - E402 - E501 -format = pylint -max-line-length = 100