Skip to content

Commit 69b7a0b

Browse files
committed
Implement initial "Poetry" and "Github Actions" support.
1 parent cfefe41 commit 69b7a0b

File tree

10 files changed

+1035
-203
lines changed

10 files changed

+1035
-203
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Continuous Integration
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
unix-build:
7+
name: Unix Build
8+
strategy:
9+
matrix:
10+
# os: [ubuntu-18.04, macOS-10.14]
11+
# python-version: [3.6, 3.7]
12+
os: [ubuntu-18.04]
13+
python-version: [3.6]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v1
17+
with:
18+
submodules: true
19+
- name: Environment Variables
20+
run: |
21+
CI_PYTHON_VERSION=${{ matrix.python-version }}
22+
CI_PACKAGE=colour_checker_detection
23+
CI_SHA=${{ github.sha }}
24+
CI_SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }}
25+
CI_SLACK_SUCCESS_NOTIFICATION="payload={\"attachments\": [{\"color\": \"#4CAF50\", \"author_name\": \"Python ${{ matrix.python-version }} build on ${{ matrix.os }}\", \"text\": \"Build for commit *${CI_SHA:0:7}* succeeded!\", \"title\": \"${{ github.repository }}@${{ github.ref }}\", \"title_link\": \"https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks\", \"footer\": \"Triggered by ${{ github.actor }}\"}], \"username\":\"Github Actions @ ${{ github.repository }}\", \"channel\":\"#continuous-integration\", \"icon_url\":\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"}"
26+
CI_SLACK_FAILURE_NOTIFICATION="${CI_SLACK_SUCCESS_NOTIFICATION/4CAF50/F44336}"
27+
CI_SLACK_FAILURE_NOTIFICATION="${CI_SLACK_FAILURE_NOTIFICATION/succeeded/failed}"
28+
COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}
29+
echo ::set-env name=CI_PYTHON_VERSION::$CI_PYTHON_VERSION
30+
echo ::set-env name=CI_PACKAGE::$CI_PACKAGE
31+
echo ::set-env name=CI_SHA::$CI_SHA
32+
echo ::set-env name=CI_SLACK_WEBHOOK::$CI_SLACK_WEBHOOK
33+
echo ::set-env name=CI_SLACK_SUCCESS_NOTIFICATION::$CI_SLACK_SUCCESS_NOTIFICATION
34+
echo ::set-env name=CI_SLACK_FAILURE_NOTIFICATION::$CI_SLACK_FAILURE_NOTIFICATION
35+
echo ::set-env name=COVERALLS_REPO_TOKEN::$COVERALLS_REPO_TOKEN
36+
- name: Set up Python ${{ matrix.python-version }}
37+
uses: actions/setup-python@v1
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
# TODO: Remove when "colour-science-0.3.13" is released.
41+
- name: Ubuntu - Update OS & Install APT Dependencies
42+
if: matrix.os == 'ubuntu-18.04'
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get --yes install libboost-all-dev libilmbase-dev libopenexr-dev libpng-dev libtiff5-dev
46+
# - name: Ubuntu - Set up Matplotlib Backend
47+
# if: matrix.os == 'ubuntu-18.04'
48+
# run: |
49+
# mkdir -p ~/.config/matplotlib
50+
# echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc
51+
# - name: macOS - Set up Matplotlib Backend
52+
# if: matrix.os == 'macOS-10.14'
53+
# run: |
54+
# mkdir -p ~/.matplotlib
55+
# echo "backend: Agg" > ~/.matplotlib/matplotlibrc
56+
- name: Install Poetry
57+
run: |
58+
curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
59+
python get-poetry.py --preview
60+
PATH=$HOME/.poetry/bin:$PATH
61+
echo ::set-env name=PATH::$PATH
62+
- name: Install Package Dependencies
63+
run: |
64+
poetry install
65+
poetry env use $CI_PYTHON_VERSION
66+
source $(poetry env info -p)/bin/activate
67+
python -c "import imageio;imageio.plugins.freeimage.download()"
68+
# TODO: Remove when "colour-science-0.3.13" is released.
69+
- name: Ubuntu - Install OpenImageIO
70+
if: matrix.os == 'ubuntu-18.04' && matrix.python-version == '3.6'
71+
run: |
72+
curl -L https://github.com/colour-science/artifacts/suites/233020849/artifacts/44967 -o OpenImageIO-Release-2.0.10.zip
73+
unzip OpenImageIO-Release-2.0.10.zip
74+
sudo cp OpenImageIO-Release-2.0.10/linux64/bin/* /usr/bin/
75+
sudo cp -r OpenImageIO-Release-2.0.10/linux64/lib/* /usr/lib/
76+
sudo rm -rf /usr/lib/python3.6
77+
cp OpenImageIO-Release-2.0.10/linux64/lib/python3.6/site-packages/OpenImageIO.so $(poetry env info -p)/lib/python3.6/site-packages/
78+
- name: Lint with flake8
79+
run: |
80+
source $(poetry env info -p)/bin/activate
81+
flake8 $CI_PACKAGE --count --show-source --statistics
82+
- name: Test with nosetests
83+
run: |
84+
source $(poetry env info -p)/bin/activate
85+
PYTHONWARNINGS=ignore
86+
nosetests --nocapture --with-doctest --doctest-options=+ELLIPSIS --with-coverage --cover-package=$CI_PACKAGE $CI_PACKAGE
87+
- name: Upload Coverage to coveralls.io
88+
if: matrix.python-version == '3.6' || matrix.python-version == '3.7'
89+
run: |
90+
source $(poetry env info -p)/bin/activate
91+
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else coveralls; fi
92+
- name: Notify Slack
93+
if: always()
94+
run: |
95+
if [ "${{ job.status }}" == "Success" ]; then CI_SLACK_NOTIFICATION="$CI_SLACK_SUCCESS_NOTIFICATION"; else CI_SLACK_NOTIFICATION="$CI_SLACK_FAILURE_NOTIFICATION"; fi
96+
if [ -z "$CI_SLACK_WEBHOOK" ]; then echo \"SLACK_WEBHOOK\" secret is undefined!; else curl -k -d "$CI_SLACK_NOTIFICATION" -X POST $CI_SLACK_WEBHOOK; fi
97+
# windows-build:
98+
# name: Windows Build
99+
# strategy:
100+
# matrix:
101+
# os: [windows-2019]
102+
# python-version: [3.6, 3.7]
103+
# runs-on: ${{ matrix.os }}
104+
# steps:
105+
# - uses: actions/checkout@v1
106+
# with:
107+
# submodules: true
108+
# - name: Environment Variables
109+
# run: |
110+
# set CI_PYTHON_VERSION=${{ matrix.python-version }}
111+
# set CI_PACKAGE=colour_checker_detection
112+
# set CI_SHA=${{ github.sha }}
113+
# set CI_SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }}
114+
# set CI_SLACK_SUCCESS_NOTIFICATION="payload={\"attachments\": [{\"color\": \"#4CAF50\", \"author_name\": \"Python ${{ matrix.python-version }} build on ${{ matrix.os }}\", \"text\": \"Build for commit *"%CI_SHA:~0,7%"* succeeded!\", \"title\": \"${{ github.repository }}@${{ github.ref }}\", \"title_link\": \"https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks\", \"footer\": \"Triggered by ${{ github.actor }}\"}], \"username\":\"Github Actions @ ${{ github.repository }}\", \"channel\":\"#continuous-integration\", \"icon_url\":\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"}"
115+
# set CI_SLACK_FAILURE_NOTIFICATION=%CI_SLACK_SUCCESS_NOTIFICATION:4CAF50=F44336%
116+
# set CI_SLACK_FAILURE_NOTIFICATION=%CI_SLACK_FAILURE_NOTIFICATION:succeeded=failed%
117+
# set COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}
118+
# echo ::set-env name=CI_PYTHON_VERSION::%CI_PYTHON_VERSION%
119+
# echo ::set-env name=CI_PACKAGE::%CI_PACKAGE%
120+
# echo ::set-env name=CI_SHA::%CI_SHA%
121+
# echo ::set-env name=CI_SLACK_WEBHOOK::%CI_SLACK_WEBHOOK%
122+
# echo ::set-env name=CI_SLACK_SUCCESS_NOTIFICATION::%CI_SLACK_SUCCESS_NOTIFICATION%
123+
# echo ::set-env name=CI_SLACK_FAILURE_NOTIFICATION::%CI_SLACK_FAILURE_NOTIFICATION%
124+
# echo ::set-env name=COVERALLS_REPO_TOKEN::%COVERALLS_REPO_TOKEN%
125+
# - name: Set up Python ${{ matrix.python-version }}
126+
# uses: actions/setup-python@v1
127+
# with:
128+
# python-version: ${{ matrix.python-version }}
129+
# - name: Install Poetry
130+
# run: |
131+
# curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
132+
# python get-poetry.py --preview
133+
# set PATH=%USERPROFILE%\.poetry\bin;%PATH%
134+
# echo ::set-env name=PATH::%PATH%
135+
# - name: Install Package Dependencies
136+
# run: |
137+
# call poetry install
138+
# FOR /F %%a IN ('poetry env info -p') DO SET CI_VIRTUAL_ENVIRONMENT=%%a
139+
# echo ::set-env name=CI_VIRTUAL_ENVIRONMENT::%CI_VIRTUAL_ENVIRONMENT%
140+
# call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate
141+
# python -c "import imageio;imageio.plugins.freeimage.download()"
142+
# - name: Lint with flake8
143+
# run: |
144+
# call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate
145+
# flake8 %CI_PACKAGE% --count --show-source --statistics
146+
# - name: Test with nosetests
147+
# run: |
148+
# call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate
149+
# set PYTHONWARNINGS=ignore
150+
# nosetests --nocapture --with-doctest --doctest-options=+ELLIPSIS --with-coverage --cover-package=%CI_PACKAGE% %CI_PACKAGE%
151+
# - name: Upload Coverage to coveralls.io
152+
# if: matrix.python-version == '3.6' || matrix.python-version == '3.7'
153+
# run: |
154+
# call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate
155+
# IF "%COVERALLS_REPO_TOKEN%"=="" (echo "COVERALLS_REPO_TOKEN" secret is undefined!) ELSE (coveralls)
156+
# - name: Notify Slack
157+
# if: always()
158+
# run: |
159+
# IF "${{ job.status }}"=="Success" (set CI_SLACK_NOTIFICATION=%CI_SLACK_SUCCESS_NOTIFICATION%) ELSE (set CI_SLACK_NOTIFICATION=%CI_SLACK_FAILURE_NOTIFICATION%)
160+
# IF "%CI_SLACK_WEBHOOK%"=="" (echo "SLACK_WEBHOOK" secret is undefined!) ELSE (curl -k -d %CI_SLACK_NOTIFICATION% -X POST %CI_SLACK_WEBHOOK%)

.readthedocs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build:
2+
image: latest
3+
4+
python:
5+
version: 3.6
6+
pip_install: true
7+
extra_requirements:
8+
- read-the-docs

.travis.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

README.rst

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Colour - Checker Detection
33

44
.. start-badges
55
6-
|travis| |coveralls| |codacy| |version|
6+
|actions| |coveralls| |codacy| |version|
77

8-
.. |travis| image:: https://img.shields.io/travis/colour-science/colour-checker-detection/develop.svg?style=flat-square
9-
:target: https://travis-ci.org/colour-science/colour-checker-detection
8+
.. |actions| image:: https://github.com/colour-science/colour-checker-detection/workflows/Continuous%20Integration/badge.svg
9+
:target: https://github.com/colour-science/colour-checker-detection/actions
1010
:alt: Develop Build Status
1111
.. |coveralls| image:: http://img.shields.io/coveralls/colour-science/colour-checker-detection/develop.svg?style=flat-square
1212
:target: https://coveralls.io/r/colour-science/colour-checker-detection
@@ -57,10 +57,9 @@ Primary Dependencies
5757

5858
**Colour - Checker Detection** requires various dependencies in order to run:
5959

60-
- `Python 2.7 <https://www.python.org/download/releases/>`_ or
61-
`Python 3.7 <https://www.python.org/download/releases/>`_
60+
- `Python >=3.5 <https://www.python.org/download/releases/>`_
6261
- `Colour Science <https://www.colour-science.org>`_
63-
- `opencv-python <https://pypi.org/project/opencv-python/>`_
62+
- `opencv-python >=4 <https://pypi.org/project/opencv-python/>`_
6463

6564
Pypi
6665
^^^^
@@ -71,14 +70,6 @@ issuing this command in a shell::
7170

7271
pip install colour-checker-detection
7372

74-
The tests suite dependencies are installed as follows::
75-
76-
pip install 'colour-checker-detection[tests]'
77-
78-
The documentation building dependencies are installed as follows::
79-
80-
pip install 'colour-checker-detection[docs]'
81-
8273
The overall development dependencies are installed as follows::
8374

8475
pip install 'colour-checker-detection[development]'

colour_checker_detection/detection/segmentation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import numpy as np
2323
from collections import namedtuple
2424

25-
from colour.models import eotf_reverse_sRGB, eotf_sRGB
25+
from colour.models import decoding_cctf, encoding_cctf
2626
from colour.utilities import as_float_array, as_int_array, as_int
2727

2828
__author__ = 'Colour Developers'
@@ -250,7 +250,7 @@ def as_8_bit_BGR_image(image):
250250
if image.dtype == np.uint8:
251251
return image
252252

253-
return cv2.cvtColor((eotf_reverse_sRGB(image) * 255).astype(np.uint8),
253+
return cv2.cvtColor((encoding_cctf(image) * 255).astype(np.uint8),
254254
cv2.COLOR_RGB2BGR)
255255

256256

@@ -547,8 +547,8 @@ def colour_checkers_coordinates_segmentation(image, additional_data=False):
547547
image_c = cv2.dilate(image_c, kernel, iterations=1)
548548

549549
# Detecting contours.
550-
_image_c, contours, _hierarchy = cv2.findContours(image_c, cv2.RETR_TREE,
551-
cv2.CHAIN_APPROX_NONE)
550+
contours, _hierarchy = cv2.findContours(image_c, cv2.RETR_TREE,
551+
cv2.CHAIN_APPROX_NONE)
552552

553553
# Filtering squares/swatches contours.
554554
swatches = []
@@ -568,8 +568,8 @@ def colour_checkers_coordinates_segmentation(image, additional_data=False):
568568
]:
569569
cv2.drawContours(clusters, [swatch], -1, [255] * 3, -1)
570570
clusters = cv2.cvtColor(clusters, cv2.COLOR_RGB2GRAY)
571-
_image_c, clusters, _hierarchy = cv2.findContours(
572-
clusters, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
571+
clusters, _hierarchy = cv2.findContours(clusters, cv2.RETR_EXTERNAL,
572+
cv2.CHAIN_APPROX_NONE)
573573
clusters = [
574574
as_int_array(
575575
scale_contour(cv2.boxPoints(cv2.minAreaRect(cluster)), 0.975))
@@ -767,7 +767,7 @@ class instances.
767767
colour_checkers_colours = []
768768
colour_checkers_data = []
769769
for colour_checker in extract_colour_checkers_segmentation(image):
770-
colour_checker = eotf_sRGB(
770+
colour_checker = decoding_cctf(
771771
as_float_array(colour_checker[..., ::-1]) / 255)
772772
width, height = (colour_checker.shape[1], colour_checker.shape[0])
773773
masks = swatch_masks(width, height, swatches_h, swatches_v, samples)

colour_checker_detection/detection/tests/test_segmentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import unittest
1414

1515
from colour import read_image
16-
from colour.models import eotf_reverse_sRGB
16+
from colour.models import encoding_cctf
1717

1818
from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
1919
from colour_checker_detection.detection.segmentation import (
@@ -90,7 +90,7 @@ def test_as_8_bit_BGR_image(self):
9090
self.assertEqual(image_o.dtype, np.uint8)
9191
np.testing.assert_almost_equal(
9292
image_o[16, 16, ...],
93-
(eotf_reverse_sRGB(image_i[16, 16, ::-1]) * 255).astype(np.uint8))
93+
(encoding_cctf(image_i[16, 16, ::-1]) * 255).astype(np.uint8))
9494

9595

9696
class TestAdjustImage(unittest.TestCase):

0 commit comments

Comments
 (0)