Skip to content
Snippets Groups Projects
Verified Commit 4cbe9af6 authored by Yoann Schneider's avatar Yoann Schneider :tennis:
Browse files

moar checks

parent c85ccbae
Branches new-training-worker-class
No related tags found
1 merge request!322Replace isort and flake8 by ruff for linting
Pipeline #80376 passed
......@@ -38,3 +38,7 @@ ignore = [
"__init__.py" = [
"G001", # Logging statement uses `string.format()`
]
"worker/__init__.py" = [
"SIM105", # Use `contextlib.suppress(Exception)` instead of try-except-pass
"S110", # `try`-`except`-`pass` detected, consider logging the exception
]
......@@ -6,6 +6,7 @@ On methods that support caching, the database will be used for all reads,
and writes will go both to the Arkindex API and the database,
reducing network usage.
"""
import json
from pathlib import Path
import sqlite3
......@@ -322,8 +323,9 @@ def merge_parents_cache(paths: list, current_database: Path):
# Check that the parent cache uses a compatible version
check_version(path)
with SqliteDatabase(path) as source, source.bind_ctx(MODELS):
source.create_tables(MODELS)
with SqliteDatabase(path) as source:
with source.bind_ctx(MODELS):
source.create_tables(MODELS)
logger.info(f"Merging parent db {path} into {current_database}")
statements = [
......
......@@ -3,7 +3,6 @@
Base classes to implement Arkindex workers.
"""
import contextlib
from enum import Enum
import json
import os
......@@ -21,7 +20,7 @@ from arkindex_worker.worker.base import BaseWorker
from arkindex_worker.worker.classification import ClassificationMixin
from arkindex_worker.worker.element import ElementMixin
from arkindex_worker.worker.entity import EntityMixin
from arkindex_worker.worker.metadata import MetaDataMixin
from arkindex_worker.worker.metadata import MetaDataMixin, MetaType # noqa: F401
from arkindex_worker.worker.transcription import TranscriptionMixin
from arkindex_worker.worker.version import WorkerVersionMixin
......@@ -229,9 +228,10 @@ class ElementsWorker(
)
if element:
# Try to update the activity to error state regardless of the response
with contextlib.suppress(Exception):
try:
self.update_activity(element.id, ActivityState.Error)
except Exception:
pass
self.report.error(element_id, e)
# Save report as local artifact
......
......@@ -7,7 +7,7 @@ import pytest
from arkindex.mock import MockApiClient
from arkindex_worker.cache import CachedElement
from arkindex_worker.models import Element
from arkindex_worker.worker.metadata import MetaType
from arkindex_worker.worker import MetaType
from . import BASE_API_CALLS
......
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