Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to cirrus-ci and support mpl 3.4.1 #39

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Reference:
# - https://cirrus-ci.org/guide/writing-tasks/
# - https://cirrus-ci.org/guide/linux/
# - https://cirrus-ci.org/guide/macOS/
# - https://cirrus-ci.org/guide/windows/
# - https://hub.docker.com/_/gcc/
# - https://hub.docker.com/_/python/

#
# Global defaults.
#
container:
image: python:3.8

env:
# Maximum cache period (in weeks) before forcing a new cache upload.
CACHE_PERIOD: "2"
# Increment the build number to force new mambaforge cache upload.
MAMBA_CACHE_BUILD: "0"
# Increment the build number to force new phash cache upload.
PHASH_CACHE_BUILD: "0"
# Base environment conda packages to be installed
MAMBA_CACHE_PACKAGES: "conda-lock"

#
# Testing (Linux)
#
linux_task:
auto_cancellation: true
container:
image: gcc:latest
env:
PATH: ${HOME}/mambaforge/bin:${PATH}
ENV_NAME: phash
YAML_FILE: ${CIRRUS_WORKING_DIR}/requirements.yml
mamba_cache:
folder: ${HOME}/mambaforge
fingerprint_script:
- wget --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh -O mambaforge.sh
- echo "${CIRRUS_OS} $(sha256sum mambaforge.sh)"
- echo "${MAMBA_CACHE_PACKAGES}"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${MAMBA_CACHE_BUILD}"
- uname -r
populate_script:
- export CONDA_OVERRIDE_LINUX="$(uname -r | cut -d'+' -f1)"
- bash mambaforge.sh -b -p ${HOME}/mambaforge
- conda config --set always_yes yes --set changeps1 no
- conda config --set show_channel_urls True
- conda config --add channels conda-forge
- conda install --quiet --name base ${MAMBA_CACHE_PACKAGES}
check_script:
- conda info --all
- conda list --name base
phash_cache:
folder: ${CIRRUS_WORKING_DIR}/mambaforge/envs/${ENV_NAME}
fingerprint_script:
- echo "${CIRRUS_OS} ${ENV_NAME} tests"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${PHASH_CACHE_BUILD}"
- cat ${YAML_FILE}
- uname -r
populate_script:
- export CONDA_OVERRIDE_LINUX="$(uname -r | cut -d'+' -f1)"
- conda-lock --mamba --platform linux-64 --file ${YAML_FILE}
- mamba create --name ${ENV_NAME} --quiet --file conda-linux-64.lock
- conda info --envs
test_script:
- source activate ${ENV_NAME}
- python run_test.py
25 changes: 25 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[flake8]
# References:
# https://flake8.readthedocs.io/en/latest/user/configuration.html
# https://flake8.readthedocs.io/en/latest/user/error-codes.html
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes

max-line-length = 80
select = C,E,F,W,B,B950
ignore =
# E203: whitespace before ':'
E203,
# E226: missing whitespace around arithmetic operator
E226,
# E231: missing whitespace after ',', ';', or ':'
E231,
# E402: module level imports on one line
E402,
# E501: line too long
E501,
# E731: do not assign a lambda expression, use a def
E731,
# W503: line break before binary operator
W503,
# W504: line break after binary operator
W504,
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.4.0'
hooks:
# Prevent giant files from being committed.
- id: check-added-large-files
# Check whether files parse as valid Python.
- id: check-ast
# Check for file name conflicts on case-insensitive filesytems.
- id: check-case-conflict
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
- id: debug-statements
# Don't commit to master branch.
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: '20.8b1'
hooks:
- id: black
# Force black to run on whole repo, using settings from pyproject.toml
pass_filenames: false
args: [--config=./pyproject.toml, .]
- repo: https://gitlab.com/pycqa/flake8
rev: '3.9.0'
hooks:
# Run flake8.
- id: flake8
args: [--config=./.flake8]
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

12 changes: 8 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
Test Iris ImageHash
===================

|Travis|_
|CirrusCI|_ |PreCommit|_ |Black|_

\(C) British Crown Copyright 2015 - 2020, Met Office
\(C) British Crown Copyright 2015 - 2021, Met Office

A perceptual hash image store for graphical testing of `SciTools iris <https://github.com/SciTools/iris>`_.

Images shall not be removed from this repository, it is to be added to only.

All files in the images folder shall be named with the perceptual image hash of the file (plus a suitable suffix).

.. |Travis| image:: https://travis-ci.org/SciTools/test-iris-imagehash.svg?branch=gh-pages
.. _Travis: https://travis-ci.org/SciTools/test-iris-imagehash
.. |CirrusCI| image:: https://api.cirrus-ci.com/github/SciTools/test-iris-imagehash.svg?branch=gh-pages
.. _CirrusCI: https://cirrus-ci.com/github/SciTools/iris
.. |PreCommit| image:: https://results.pre-commit.ci/badge/github/SciTools/test-iris-imagehash/gh-pages.svg
.. _PreCommit: https://results.pre-commit.ci/latest/github/SciTools/test-iris-imagehash/gh-pages
.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
.. _Black: https://github.com/psf/black
2 changes: 0 additions & 2 deletions conda-requirements.txt

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[tool.black]
line-length = 79
target-version = ['py38']
include = '\.pyi?$'
exclude = '''

(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| etc
)/
)
'''
17 changes: 9 additions & 8 deletions recreate_v4_files_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@


REPO_MAIN_DIRPATH = os.path.dirname(os.path.abspath(__file__))
V4_DIR = os.sep.join([REPO_MAIN_DIRPATH, 'images', 'v4'])
V4_LISTFILE_NAME = 'v4_files_listing.txt'
V4_DIR = os.sep.join([REPO_MAIN_DIRPATH, "images", "v4"])
V4_LISTFILE_NAME = "v4_files_listing.txt"
V4_LISTFILE_PATH = os.sep.join([REPO_MAIN_DIRPATH, V4_LISTFILE_NAME])


def get_v4_imagefile_names(search_dirpath=V4_DIR, filespec='*.png'):
def get_v4_imagefile_names(search_dirpath=V4_DIR, filespec="*.png"):
"""Return a list of the current image files in the v4 subdirectory."""
files_spec = os.path.join(search_dirpath, filespec)
file_paths = glob(files_spec)
return [os.path.basename(file_path) for file_path in file_paths]


def create_v4_images_listfile(search_dirpath=V4_DIR, filespec='*.png',
output_filepath=V4_LISTFILE_PATH):
def create_v4_images_listfile(
search_dirpath=V4_DIR, filespec="*.png", output_filepath=V4_LISTFILE_PATH
):
file_names = get_v4_imagefile_names(search_dirpath, filespec)
with open(output_filepath, 'w') as f_out:
with open(output_filepath, "w") as f_out:
for file_name in sorted(file_names):
f_out.write('{}\n'.format(file_name))
f_out.write("{}\n".format(file_name))


if __name__ == '__main__':
if __name__ == "__main__":
create_v4_images_listfile()
11 changes: 11 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: phash-dev

channels:
- conda-forge

dependencies:
- black=20.8b1
- flake8
- imagehash>=4.0
- pillow<7
- pre-commit
30 changes: 17 additions & 13 deletions run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def test(self):
fname_base = os.path.basename(fname)
fname_hash = os.path.splitext(fname_base)[0]
if str(phash) != fname_hash:
msg = 'Calculated phash {} does not match filename {!r}.'
exceptions.append(ValueError(msg.format(str(phash), fname_base)))
msg = "Calculated phash {} does not match filename {!r}."
exceptions.append(
ValueError(msg.format(str(phash), fname_base))
)
self.assertEqual([], exceptions)


Expand All @@ -34,27 +36,29 @@ def test(self):
listing_filepath = v4list.V4_LISTFILE_NAME
self.assertTrue(os.path.exists(listing_filepath))
with open(listing_filepath) as listing_file:
listed_names = [line.strip()
for line in listing_file.readlines()]
listed_names = [line.strip() for line in listing_file.readlines()]

files = set(file_names)
listed = set(listed_names)
if listed != files:
msg = ('Filenames in the listing file {} do not match the image '
'file contents of the {} directory:')
msg = (
"Filenames in the listing file {} do not match the image "
"file contents of the {} directory:"
)
msg = msg.format(v4list.V4_LISTFILE_NAME, v4list.V4_DIR)
newfiles = files - listed
if newfiles:
msg += '\n Names in directory, but not in the listing file:'
msg += ''.join(['\n ' + name for name in newfiles])
msg += "\n Names in directory, but not in the listing file:"
msg += "".join(["\n " + name for name in newfiles])
missing = listed - files
if missing:
msg += '\n Names in the listing, but not in the directory:'
msg += ''.join(['\n ' + name for name in missing])
msg += ('\n\n*** Please run "{}.py" to correct. ***'.format(
os.path.basename(v4list.__name__)))
msg += "\n Names in the listing, but not in the directory:"
msg += "".join(["\n " + name for name in missing])
msg += '\n\n*** Please run "{}.py" to correct. ***'.format(
os.path.basename(v4list.__name__)
)
self.assertEqual(listed, files, msg)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
Loading