Skip to content

Commit

Permalink
Merge pull request #695 from girder/improve-annotation-logs
Browse files Browse the repository at this point in the history
Improve logging loading annotations.
  • Loading branch information
manthey authored Nov 29, 2021
2 parents fce2e24 + d9de43f commit 573b494
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import json
import struct
import time

import cherrypy
import ujson
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.')
Expand Down Expand Up @@ -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:
Expand All @@ -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']}

Expand Down

0 comments on commit 573b494

Please sign in to comment.