You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The /tree-benefits endpoint returns NO3, O3, PM2.5, etc. values for a single tree (based on the trunk diameter in the POST request). However we are making heavy model calculations every time we get request. We should cache the response in Redis.
For the each request for given trunk diameter check if the result is already in Redis. If not, then use predict_tree_benefits function and store results in Redis.
It would be also nice to write some API tests for the /tree-benefits endpoint. Maybe this library can help: https://github.com/Martiusweb/asynctest. If testing of the whole endpoint is too complicated (too much to mock, async problems), then please write unit tests.
The text was updated successfully, but these errors were encountered:
Overview
The
/tree-benefits
endpoint returns NO3, O3, PM2.5, etc. values for a single tree (based on the trunk diameter in the POST request). However we are making heavy model calculations every time we get request. We should cache the response in Redis.Endpoint
https://github.com/kodujdlapolski/ecobenefits/blob/master/eco/server.py#L48
https://github.com/kodujdlapolski/ecobenefits#tree-benefits-endpoint
What to do
For the each request for given trunk diameter check if the result is already in Redis. If not, then use
predict_tree_benefits
function and store results in Redis.Redis connection can be obtained here: https://github.com/kodujdlapolski/ecobenefits/blob/master/eco/server.py#L22. Asynchronous connection is preferred, but if there are problems, ordinary synchronous can be also used: https://github.com/kodujdlapolski/ecobenefits/blob/master/eco/utils.py#L12
It would be also nice to write some API tests for the
/tree-benefits
endpoint. Maybe this library can help: https://github.com/Martiusweb/asynctest. If testing of the whole endpoint is too complicated (too much to mock, async problems), then please write unit tests.The text was updated successfully, but these errors were encountered: