krishnanlab / geneplexus-app-v2

GenePlexus App - backend (cloud functions) and frontend
https://gene-plexus.netlify.app/
2 stars 0 forks source link

Enable compression in functions #29

Closed falquaddoomi closed 2 months ago

vincerubinetti commented 2 months ago

As best I can tell, Flask doesn't do any compression by default. The recommendation looks like flask-compress, but not sure if it will work with google's functions_framework flavor of flask. https://github.com/colour-science/flask-compress

Might need to do it manually: https://stackoverflow.com/questions/30165475/how-to-compress-minimize-size-of-json-jsonify-with-flask-in-python

vincerubinetti commented 2 months ago

This seems to work, testing locally:

from flask import current_app as app
from flask_compress import Compress

Compress(app)

By default it seems to use Brotli, and testing our mock ml response on this site, Brotli compresses it the best. I'll throw it in my current PR.

https://github.com/GoogleCloudPlatform/functions-framework-python/issues/75