centralized classifier loading, better error handling, no error messages when auto matching is not used

This commit is contained in:
jonaswinkler
2021-01-30 14:22:23 +01:00
parent dda384f4a3
commit a37e41ef0c
8 changed files with 131 additions and 43 deletions

View File

@@ -34,7 +34,7 @@ from rest_framework.viewsets import (
import documents.index as index
from paperless.db import GnuPG
from paperless.views import StandardPagination
from .classifier import DocumentClassifier, IncompatibleClassifierVersionError
from .classifier import load_classifier
from .filters import (
CorrespondentFilterSet,
DocumentFilterSet,
@@ -259,15 +259,7 @@ class DocumentViewSet(RetrieveModelMixin,
except Document.DoesNotExist:
raise Http404()
try:
classifier = DocumentClassifier()
classifier.reload()
except (OSError, EOFError, IncompatibleClassifierVersionError) as e:
logging.getLogger(__name__).warning(
"Cannot load classifier: Not providing auto matching "
"suggestions"
)
classifier = None
classifier = load_classifier()
return Response({
"correspondents": [