Skip to content
Snippets Groups Projects
Commit 79e33148 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Merge branch 'update-ci' into 'master'

Update pre-commit hooks

See merge request !1609
parents 8b0adc18 b6336b01
No related branches found
No related tags found
1 merge request!1609Update pre-commit hooks
Showing
with 40 additions and 27 deletions
repos:
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
rev: v5.10.1
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- 'flake8-copyright==0.2.2'
- 'flake8-debugger==3.1.0'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v4.1.0
hooks:
- id: check-ast
- id: check-docstring-first
......@@ -31,6 +27,8 @@ repos:
args: ['--django']
- id: check-json
- id: requirements-txt-fixer
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: meta
hooks:
- id: check-useless-excludes
......@@ -43,7 +43,14 @@ class CorpusWorkerVersionManager(models.Manager):
"""
Rebuild the corpus worker versions cache from all ML results.
"""
from arkindex.documents.models import Element, Transcription, Entity, TranscriptionEntity, Classification, MetaData
from arkindex.documents.models import (
Classification,
Element,
Entity,
MetaData,
Transcription,
TranscriptionEntity,
)
querysets = [
Element.objects.exclude(worker_version_id=None).values_list('corpus_id', 'worker_version_id'),
......
......@@ -106,7 +106,7 @@ class GitProvider(ABC):
For a worker repository, start a single process to build the new workers
For other repositories, start a process for each corpus depending on the repository
"""
from arkindex.dataimport.models import DataImport, RepositoryType, DataImportMode
from arkindex.dataimport.models import DataImport, DataImportMode, RepositoryType
mode = DataImportMode.Repository
user = rev.repo.credentials.user
refs = ", ".join(rev.refs.values_list('name', flat=True))
......@@ -279,7 +279,7 @@ class GitLabProvider(GitProvider):
raise APIException("Error while creating GitLab hook: {}".format(str(e)))
def create_revision(self, repo, sha, save=True):
from arkindex.dataimport.models import Revision, GitRefType
from arkindex.dataimport.models import GitRefType, Revision
project = self._get_project_from_repo(repo)
commit = project.commits.get(sha)
......
......@@ -20,6 +20,7 @@ Please, try again with another push or contact your system administrator.
--
Arkindex
"""
......
......@@ -8,4 +8,4 @@ SELECT
entity.worker_version_id
FROM documents_entity entity
LEFT JOIN users_user moderator ON (moderator.id = entity.moderator_id)
WHERE entity.corpus_id = '{corpus_id}'::uuid
\ No newline at end of file
WHERE entity.corpus_id = '{corpus_id}'::uuid
SELECT link.id, link.parent_id, link.child_id, link.role_id
FROM documents_entitylink link
INNER JOIN documents_entityrole role ON (link.role_id = role.id)
WHERE role.corpus_id = '{corpus_id}'::uuid
\ No newline at end of file
WHERE role.corpus_id = '{corpus_id}'::uuid
SELECT id, parent_name, child_name, parent_type, child_type
FROM documents_entityrole
WHERE corpus_id = '{corpus_id}'::uuid
\ No newline at end of file
WHERE corpus_id = '{corpus_id}'::uuid
......@@ -8,4 +8,4 @@ SELECT
metadata.worker_version_id
FROM documents_metadata metadata
INNER JOIN documents_element element ON (element.id = metadata.element_id)
WHERE element.corpus_id = '{corpus_id}'::uuid
\ No newline at end of file
WHERE element.corpus_id = '{corpus_id}'::uuid
......@@ -6,4 +6,4 @@ SELECT
transcription.worker_version_id
FROM documents_transcription transcription
INNER JOIN documents_element element ON (element.id = transcription.element_id)
WHERE element.corpus_id = '{corpus_id}'::uuid
\ No newline at end of file
WHERE element.corpus_id = '{corpus_id}'::uuid
......@@ -21,8 +21,15 @@ class ElementQuerySet(models.QuerySet):
def trash(self, delete_children=True):
"""Performant deletion of any element queryset"""
from arkindex.documents.models import Element, MetaData, Transcription, TranscriptionEntity, Classification, Selection
from arkindex.dataimport.models import DataImport, DataImportElement, WorkerActivity
from arkindex.documents.models import (
Classification,
Element,
MetaData,
Selection,
Transcription,
TranscriptionEntity,
)
# We only need the Element IDs to join on other models
# Disable all ordering as it will not be required for deletions
......
......@@ -11,7 +11,7 @@ if __name__ == "__main__":
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django # noqa
import django # noqa
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
......
......@@ -43,6 +43,7 @@ def local_imageserver_check(*args, **kwargs):
Check that the configured local ImageServer exists
"""
from django.conf import settings
from arkindex.images.models import ImageServer
local_id = settings.LOCAL_IMAGESERVER_ID
......
......@@ -9,9 +9,9 @@ sys.path.insert(0, test_dir)
def run():
# Setup django
from django.test.utils import get_runner
from django.conf import settings
import django
from django.conf import settings
from django.test.utils import get_runner
django.setup()
# Run tests on arkindex apps
......
......@@ -570,7 +570,7 @@ if TEST_ENV:
# Optional unit tests runner with code coverage
try:
import django_nose # noqa
import django_nose # noqa
INSTALLED_APPS.append('django_nose')
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
......@@ -584,7 +584,7 @@ except ImportError:
# Local settings
if DEBUG and not TEST_ENV:
try:
from .local_settings import * # noqa
from .local_settings import * # noqa
except ImportError:
pass
......@@ -602,7 +602,7 @@ except ImportError:
pass
try:
import debug_toolbar.settings # noqa
import debug_toolbar.settings # noqa
MIDDLEWARE.insert(0, 'debug_toolbar.middleware.DebugToolbarMiddleware')
INSTALLED_APPS.append('debug_toolbar')
except ImportError:
......@@ -611,9 +611,9 @@ except ImportError:
if SENTRY_DSN and not DJANGO_SHELL:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.integrations.redis import RedisIntegration
from sentry_sdk.integrations.rq import RqIntegration
from sentry_sdk.integrations.logging import ignore_logger
ignore_logger('django.security.DisallowedHost')
sentry_sdk.init(
......
......@@ -29,4 +29,3 @@ session:
cookie_samesite: "'foo' is not a valid CookieSameSiteOption"
static:
root_path: /aaaaa does not exist
......@@ -14,8 +14,8 @@ class ChecksTestCase(TestCase):
'''
Check should always be OK
'''
from arkindex.project.checks import api_urls_check
from arkindex.project.api_v1 import api
from arkindex.project.checks import api_urls_check
self.assertListEqual(api_urls_check(), [])
......@@ -39,8 +39,8 @@ class ChecksTestCase(TestCase):
"""
Test the local imageserver existence check
"""
from arkindex.project.checks import local_imageserver_check
from arkindex.images.models import ImageServer
from arkindex.project.checks import local_imageserver_check
self.assertEqual(ImageServer.objects.count(), 0)
with self.settings(LOCAL_IMAGESERVER_ID=42):
......
......@@ -10,4 +10,4 @@ Please, try again with another push or contact your system administrator.
--
Arkindex
{% endautoescape %}
\ No newline at end of file
{% endautoescape %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment