Skip to content

Commit

Permalink
update CI & tests
Browse files Browse the repository at this point in the history
+ add GH action
- drop Travis
* fix tests
  • Loading branch information
Borda committed Jan 8, 2021
1 parent 74d6e20 commit 8413e09
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 74 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI testing

# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the master branch
- push
- pull_request

jobs:
pytest:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04] # , macOS-10.15
python-version: [2.7, 3.6, 3.8]

# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 15
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
- name: Get pip cache
id: pip-cache
run: |
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.requires }}-
- name: Install dependencies
run: |
# sudo apt-get install python-opencv
pip install "setuptools<46" -U # v46 crashes openslide-python install
pip install -r requirements.txt
pip install -U check-manifest coverage pytest codecov codacy-coverage flake8
# code coverage tool
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
shell: bash

- name: Preparation
run: |
mkdir output
python --version
pwd ; ls -l
./cc-test-reporter before-build
pip --version
pip list
- name: Tests
env:
DISPLAY: ""
run: |
coverage run --source handlers -m pytest handlers -v --doctest-modules --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
- name: Formatting
run: |
flake8 . --ignore=E402 --max-line-length=120
- name: Run scripts
run: |
python handlers/run_evaluate_landmarks.py -a ./annotations -o ./output --visual
python handlers/run_generate_landmarks.py -a ./annotations -d ./dataset --scales 5
python handlers/run_visualise_landmarks.py -l ./dataset -i ./dataset -o ./output
- name: Upload pytest test results
uses: actions/upload-artifact@master
with:
name: pytest-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}
path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: always()

- name: Statistics
if: success()
run: |
coverage report
coverage xml
# upload to ...
python-codacy-coverage -r coverage.xml
./cc-test-reporter after-build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: success()
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
fail_ci_if_error: false
61 changes: 0 additions & 61 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dataset: histology landmarks

[![Build Status](https://travis-ci.org/Borda/dataset-histology-landmarks.svg?branch=master)](https://travis-ci.org/Borda/dataset-histology-landmarks)
[![CI testing](https://github.com/Borda/dataset-histology-landmarks/workflows/CI%20testing/badge.svg?branch=master&event=push)](https://github.com/Borda/dataset-histology-landmarks/actions?query=workflow%3A%22CI+testing%22)
[![codecov](https://codecov.io/gh/Borda/dataset-histology-landmarks/branch/master/graph/badge.svg)](https://codecov.io/gh/Borda/dataset-histology-landmarks)
[![codebeat badge](https://codebeat.co/badges/6c0bfead-09bc-42ed-aa8e-cf49944aaa40)](https://codebeat.co/projects/github-com-borda-dataset-histology-landmarks-master)
[![Maintainability](https://api.codeclimate.com/v1/badges/e1374e80994253cc8e95/maintainability)](https://codeclimate.com/github/Borda/dataset-histology-landmarks/maintainability)
Expand Down
28 changes: 16 additions & 12 deletions handlers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,24 @@ def compute_landmarks_statistic(landmarks_ref, landmarks_in, use_affine=False, i
... [47., -15.], [65., -60.], [77., -52.], [0, 0]])
>>> d_stat = compute_landmarks_statistic(lnds0, lnds1, use_affine=True)
>>> import pandas as pd
>>> _org_float_format = pd.options.display.float_format
>>> pd.options.display.float_format = '{:,.1f}'.format
>>> pd.Series(d_stat).sort_index() # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
TRE count 8
TRE max 68.9...
TRE mean 18.6...
TRE median 13.5...
TRE min 1.02...
TRE std 21.4...
image diagonal (estimated) 85.7...
image size (estimated) (65, 56)
rTRE max 0.80...
rTRE mean 0.21...
rTRE min 0.011...
rTRE std 0.25...
TRE count 8.0
TRE max 69.0
TRE mean 18.6
TRE median 13.5
TRE min 1.0
TRE std 21.5
image diagonal (estimated) 85.8
image size (estimated) (65, 56)
rTRE max 0.8
rTRE mean 0.2
rTRE median 0.2
rTRE min 0.0
rTRE std 0.3
dtype: object
>>> pd.options.display.float_format = _org_float_format
>>> d_stat = compute_landmarks_statistic(lnds0, lnds1, im_size=(150, 175))
>>> d_stat['rTRE median'] # doctest: +ELLIPSIS
0.324...
Expand Down

0 comments on commit 8413e09

Please sign in to comment.