diff --git a/arkindex/himanis/acts.py b/arkindex/himanis/acts.py index 214990ec223686753a5b311d70c687e56ed3e339..4aa37dc09a4b25c0a3391f7d44e54b1926125fc6 100644 --- a/arkindex/himanis/acts.py +++ b/arkindex/himanis/acts.py @@ -43,7 +43,7 @@ class ActsImporter(object): self.folder = self.corpus.elements.get(type=self.folder_type, name__iexact=self.csvpath.stem) logger.debug('Matched folder "{}" for folder name "{}"'.format(self.folder.name, self.csvpath.stem)) except Element.DoesNotExist: - raise ValueError('Volume "" not found'.format(self.csvpath.stem)) + raise ValueError('Volume "{}" not found'.format(self.csvpath.stem)) # Allows finding an image in the corpus by its IIIF ID, # by concatenating the server's base URL and the image path diff --git a/arkindex/images/models.py b/arkindex/images/models.py index a91dc4388d04f5851b3e4d38c1bcf56548522103..951d1729129810f030fc1970bc283c731f8934e5 100644 --- a/arkindex/images/models.py +++ b/arkindex/images/models.py @@ -12,7 +12,6 @@ from arkindex.project.aws import S3FileMixin, S3FileStatus from arkindex.project.fields import StripSlashURLField, LStripTextField, MD5HashField from arkindex.project.models import IndexableModel from arkindex.project.polygon import PolygonField -from arkindex.project.triggers import resize_image import logging import os import requests @@ -244,6 +243,8 @@ class Image(S3FileMixin, IndexableModel): Check and update the image's properties from an IIIF Image Information response This does not save in the DB nor handles any exceptions. """ + from arkindex.project.triggers import resize_image + assert isinstance(data, dict), 'Payload should be a dict' assert all(item in data for item in ('@id', 'width', 'height', 'profile')), 'Missing required properties' assert isinstance(data['profile'], (str, list)), 'Profile is not a list or URI' diff --git a/arkindex/project/triggers.py b/arkindex/project/triggers.py index c7112e96d94831f7f048e090e12e9f9617689287..a6b1847fdce2c0078252491c20cb51bd98e71324 100644 --- a/arkindex/project/triggers.py +++ b/arkindex/project/triggers.py @@ -7,6 +7,7 @@ from asgiref.sync import async_to_sync from channels.layers import get_channel_layer from django.conf import settings from arkindex.documents.models import Element, Corpus, Entity +from arkindex.images.models import Image REINDEX_CHANNEL = 'reindex' ML_RESULTS_CHANNEL = 'ml_results' @@ -122,13 +123,12 @@ def corpus_delete(corpus: Union[Corpus, UUID, str], }) -def resize_image(image: Union['Image', UUID, str], +def resize_image(image: Union[Image, UUID, str], ratio: float = 1.0) -> None: """ Handle image resizing: when an ImageServer's maximum allowed size changes, rescale all of its zones. """ - from arkindex.images.models import Image if isinstance(image, Image): image_id = str(image.id) else: diff --git a/setup.cfg b/setup.cfg index 8d4213d85cb6c1f1815142ca1cfddf94b09d6ba4..ad3574a48896e04dfa02a99eb69374985d954666 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [flake8] max-line-length = 120 -exclude=build,.eggs,.git,src,arkindex/*/migrations/0001_initial.py +exclude=build,.eggs,.git,src,arkindex/*/migrations/0001_initial.py,.cache # Flake8 ignores multiple errors by default; # the only interesting ignore is W503, which goes against PEP8. # See https://lintlyci.github.io/Flake8Rules/rules/W503.html diff --git a/tests-requirements.txt b/tests-requirements.txt index f12d83ef91bf66d197c821dfad6bd4038ccc0bfd..59c491dd0bef9522e85086913e6bd7d9c7826bf8 100644 --- a/tests-requirements.txt +++ b/tests-requirements.txt @@ -1,4 +1,4 @@ -flake8==3.6.0 +flake8>=3.8 tripoli django-nose coverage