-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DISCO-2028] Cache weather reports in Redis #202
Conversation
cdfbe7c
to
b3a31a8
Compare
Looks good. \o/ A couple of follow-up questions:
|
Thanks for the review, @ncloudioj! 🚀
That sounds good to me! We can have a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry for my tardiness in my comments. Similarly I will be OOF the next couple days and so will trust you to take or leave anything I've said.
Thank you for this work, especially the thoughtful tests!
@@ -90,6 +99,7 @@ def test_suggest_with_weather_report(client: TestClient, backend_mock: Any) -> N | |||
forecast=weather_report.forecast, | |||
) | |||
] | |||
backend_mock.cache_inputs_for_weather_report.return_value = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This return_value
assignment is consistent across tests, an option could be to assign it once in the fixture_backend_mock.
Alternatively, were you thinking we could have an integration test where we simulate the cache workflow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and assigned it in the fixture_backend_mock
!
Hmm, we'd still need to mock out Redis in our integration tests, right? My gut feeling is that simulating the cache workflow wouldn't tell us more than the unit tests we already have, or the contract tests with a real Redis container that we can add later—WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short -- I agree
An integration test wouldn't tell us more than the unit, it would serve as the redundancy to the unit test. However, this particular case will have a contract test as you pointed out, that I think we will produce in short order 🤞🏻, which can also serve that purpose.
@linabutler Doh, sorry, the PR I merged yesterday caused lots of conflicts with yours, some rebasing is needed :/ This looks good to me. Did you want to add the |
3129b56
to
0d312ad
Compare
@ncloudioj Yep, I just pushed a sketch of a |
LGTM 👍 |
0d312ad
to
88a0b1d
Compare
@ncloudioj Ready for re-review! I'll fold the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few nits for your consideration.
Thanks!
759b636
to
2d86ac0
Compare
This commit changes the weather provider to: * Serialize and store weather reports in a volatile Redis key. The new `providers.accuweather.suggestions_ttl_sec` config setting controls the expiration time of the report. * Check for cached reports before requesting them from the backend when fetching weather suggestions.
2d86ac0
to
d62ff4c
Compare
This PR adds logic to cache
WeatherReport
responses from AccuWeather in Redis, expiring after 15 minutes by default.