Kitware / UPennContrast

UPenn ?
https://upenn-contrast.netlify.com/
Apache License 2.0
8 stars 6 forks source link

This uses the orjson library to serialize annotations. #839

Closed manthey closed 5 days ago

manthey commented 5 days ago

The orjson library is substantially faster than the built in python library at he expense of being less flexible. Here, we strip out the access control dictionaries from each annotation, convert the mongo id to a string, then use orjson to serialize. Further, rather than load the entire set of annotations into memory and serialize them in one shot, we stream them from the database and serialize them individually. When there are enough of them for efficiency, we yield them to the output function. This allows the data to start being returned before the database finishes, and, if the connection is interrupted, to stop pulling from the database when it is no longer useful.

orjson is included as part of large_image, so we don't need to add it to the dependencies.