From d9de43f461e5bf292f9a01d597e0aa589f751d24 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 29 Nov 2021 11:09:24 -0500 Subject: [PATCH] Improve logging loading annotations. --- .../models/annotationelement.py | 3 ++- .../girder_large_image_annotation/rest/annotation.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/girder_annotation/girder_large_image_annotation/models/annotationelement.py b/girder_annotation/girder_large_image_annotation/models/annotationelement.py index e38f66f95..762312e23 100644 --- a/girder_annotation/girder_large_image_annotation/models/annotationelement.py +++ b/girder_annotation/girder_large_image_annotation/models/annotationelement.py @@ -301,7 +301,8 @@ def removeWithQuery(self, query): see general MongoDB docs for "find()" :type query: dict """ - assert query + if not query: + raise Exception('query must be specified') attachedQuery = query.copy() attachedQuery['datafile'] = {'$exists': True} diff --git a/girder_annotation/girder_large_image_annotation/rest/annotation.py b/girder_annotation/girder_large_image_annotation/rest/annotation.py index a35c32ad5..7e0bc95b4 100644 --- a/girder_annotation/girder_large_image_annotation/rest/annotation.py +++ b/girder_annotation/girder_large_image_annotation/rest/annotation.py @@ -16,6 +16,7 @@ import json import struct +import time import cherrypy import ujson @@ -346,6 +347,7 @@ def deleteAnnotation(self, annotation, params): if item is not None: Item().requireAccess( item, user=self.getCurrentUser(), level=AccessType.WRITE) + setResponseTimeLimit(86400) Annotation().remove(annotation) @describeRoute( @@ -451,6 +453,7 @@ def getAnnotationHistory(self, id, version): ) @access.public def revertAnnotationHistory(self, id, version): + setResponseTimeLimit(86400) annotation = Annotation().revertVersion(id, version, self.getCurrentUser()) if not annotation: raise RestException('Annotation history version not found.') @@ -506,8 +509,11 @@ def generateResult(): def createItemAnnotations(self, item, annotations): user = self.getCurrentUser() if hasattr(annotations, 'read'): + startTime = time.time() annotations = annotations.read().decode('utf8') annotations = ujson.loads(annotations) + if time.time() - startTime > 10: + logger.info('Decoded json in %5.3fs', time.time() - startTime) if not isinstance(annotations, list): annotations = [annotations] for entry in annotations: @@ -532,6 +538,7 @@ def createItemAnnotations(self, item, annotations): ) @access.user def deleteItemAnnotations(self, item): + setResponseTimeLimit(86400) user = self.getCurrentUser() query = {'_active': {'$ne': False}, 'itemId': item['_id']}