-
Notifications
You must be signed in to change notification settings - Fork 5
Fix sensor data streaming without metrics filter #148
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
Conversation
The test was requesting only one metric, but also sensing only one metric, so the filtering wasn't being tested. We also rename the test to make it more specific. Signed-off-by: Leandro Lucarella <[email protected]>
When no metric filter was passed to `stream_sensor_data()` the transform callback failed because the `metrics` argument wasn't passed when calling `sensor_data_samples_from_proto()` internally, making the gRPC streaming task stop with an unhandled exception. This commit makes the `metrics` argument optional for `sensor_data_samples_from_proto()` to fix that. A test case with no metric filters is added too. Signed-off-by: Leandro Lucarella <[email protected]>
|
Skipping release notes as this fixes unreleased code. |
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.
Pull Request Overview
This PR ensures that when no metric filters are provided, stream_sensor_data() still returns all sensor metrics by making the metrics argument optional and updating the filtering logic. It also adds and refines tests to cover streaming with and without metric filters.
- Allow
sensor_data_samples_from_proto()to default to retrieving all metrics if none are specified. - Adjust the filter logic to handle
Nonefor metrics and add a test for streaming without filters, while improving the existing filter test.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_client.py | Renamed and extended tests to cover streaming with one metric filter and without filters |
| src/frequenz/client/microgrid/_sensor_proto.py | Made metrics parameter optional and updated filtering logic |
Comments suppressed due to low confidence (2)
tests/test_client.py:915
- [nitpick] The test name
test_stream_sensor_data_one_metricsuggests a single-metric scenario, but the test data yields two metrics when no filter is passed. Consider renaming the test to clarify that it's streaming without filters or adjust the data and assertions to match the intended filter behavior.
async def test_stream_sensor_data_one_metric(
tests/test_client.py:915
- This test never passes a metrics filter to
client.stream_sensor_data, so it's not validating filtered behavior. Add the appropriatemetricsargument to the call and assert that only the specified metric samples are returned.
async def test_stream_sensor_data_one_metric(
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
a24d1c3
When no metric filter was passed to
stream_sensor_data()the transform callback failed because themetricsargument wasn't passed when callingsensor_data_samples_from_proto()internally, making the gRPC streaming task stop with an unhandled exception.This PR makes the
metricsargument optional forsensor_data_samples_from_proto()to fix that.A test case with no metric filters is added too, and the test case testing metric filters is improved to actually test the filtering.