Skip to content

Commit 8ddbbc3

Browse files
authored
Merge pull request #271 from DigitalSlideArchive/annotation-size
Update the handler for annotation size.
2 parents 912abb1 + daa0635 commit 8ddbbc3

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ HistomicsUI uses large_image sources to read different image file formats. You
2828
.. code-block:: bash
2929
3030
# install all sources from the main repo
31-
pip install large-image[sources] --find-links https://girder.github.io/large_image_wheels
31+
pip install large-image[sources] --find-links https://girder.github.io/large_image_wheels
3232
33-
or
33+
or
3434

3535
.. code-block:: bash
3636
3737
# install openslide and tiff sources
38-
pip install large-image-source-tiff large-image-source-openslide --find-links https://girder.github.io/large_image_wheels
38+
pip install large-image-source-tiff large-image-source-openslide --find-links https://girder.github.io/large_image_wheels
3939
40-
Now install the histomicsui package, have Girder build its UI, and start the Girder server. Note that at Girder may still require an old verison of node (12.x) to build correctly.
40+
Now install the histomicsui package, have Girder build its UI, and start the Girder server. Note that at Girder may still require an old version of node (12.x) to build correctly -- nvm can be used to manage multiple versions of node.
4141

4242
.. code-block:: bash
4343
4444
pip install histomicsui[analysis]
4545
girder build
46-
girder serve
46+
girder serve
4747
4848
To use Girder Worker:
4949

histomicsui/handlers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def resolveAnnotationGirderIds(event, results, data, possibleGirderIds):
115115
return True
116116

117117

118-
def process_annotations(event):
118+
def process_annotations(event): # noqa
119119
"""Add annotations to an image on a ``data.process`` event"""
120120
results = _itemFromEvent(event, 'AnnotationFile')
121121
if not results:
@@ -132,7 +132,16 @@ def process_annotations(event):
132132
logger.error('Could not load models from the database')
133133
return
134134
try:
135-
data = orjson.loads(File().open(file).read().decode())
135+
if file['size'] > 1 * 1024 ** 3:
136+
raise Exception('File is larger than will be read into memory.')
137+
data = []
138+
with File().open(file) as fptr:
139+
while True:
140+
chunk = fptr.read(1024 ** 2)
141+
if not len(chunk):
142+
break
143+
data.append(chunk)
144+
data = orjson.loads(b''.join(data).decode())
136145
except Exception:
137146
logger.error('Could not parse annotation file')
138147
raise

0 commit comments

Comments
 (0)