-
Notifications
You must be signed in to change notification settings - Fork 20
Clean ups and improvements to the resampler (mostly) #68
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
Clean ups and improvements to the resampler (mostly) #68
Conversation
|
This might depend on frequenz-floss/frequenz-channels-python#48, I am getting a lot of flakyness in tests, stalling at the grpc mocking layer. At some point the traceback showed issues with comparing time aware and native datetimes, but locally I still get sometimes stalled tests. It is very hard to find a way to reproduce and it doesn't always seem to be related to these changes, but it happens even when rebuilding the whole virtualenv. |
|
This is also a step forward (needed preparation) for making the API more stable and for #56. |
|
Updated:
|
f4736a7 to
b7e2a46
Compare
All sessions can now take positional arguments, which will be forwarded to the command run by the session. This is usually very useful to check individual files, or pass extra arguments, like: nox -R -s pytest_max -- -s tests/my/test_this.py Sessions will not process the pre-defined files when positional arguments are passed, so when using positional arguments you should always include paths to check, except for pytest_xxx sessions, which still if files are omitted, all files will be processed, so it can be used to use custom options only too. For example: nox -R -s pytest_max -- -sx Signed-off-by: Leandro Lucarella <[email protected]>
More precisely, from: frequenz.sdk.data_ingestion.resampling.component_metrics_resampling_actor to: frequenz.sdk.actor.resampling Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
The resampler expects samples to be in order (from older to newer), otherwise when calculating which samples are relevant to the current resampling window some valid samples could be left out. Some tests didn't have them in the proper order but they were working just by chance. Signed-off-by: Leandro Lucarella <[email protected]>
With these names it is easier to identify which sample belongs to each metric. Signed-off-by: Leandro Lucarella <[email protected]>
We use the epoch so it is very easy to debug time issues when using datetime.timestamp(). We also stop the time from ticking, because we want to have full control over time passing in these tests. Signed-off-by: Leandro Lucarella <[email protected]>
This is necessary to achieve full timestamp consistency across the whole resampling machinery, otherwise there could be some inconsistencies when calculating which are the current relevant samples to use when resampling in the ComponentMetricResampler. The ComponentMetricGroupResampler now passes the timestamp to all the ComponentMetricResampler it controls. Signed-off-by: Leandro Lucarella <[email protected]>
The resampling class now can take an optional timestamp to be used to produce the new samples and the resampling actor now passes the timestamp produced by the timer instead of calling `now()` manually. This also adds a more explicit check to make sure the timer receiver is not closed. Fixes frequenz-floss#54. Signed-off-by: Leandro Lucarella <[email protected]>
There is some redundancy when specifying the types for arguments and the return value because we are going to use mkdocstrings and it doesn't support this very specific use case of documenting a callable type specifically. Signed-off-by: Leandro Lucarella <[email protected]>
Now that we have a timeseries package it makes more sense to have the Sample class living there. Signed-off-by: Leandro Lucarella <[email protected]>
All we are using pytz for is to using aware datetime object with UTC timezone, which is perfectly doable with the standard datetime and timezone objects. This commit also converts some instances of "native" datetimes to "aware". Signed-off-by: Leandro Lucarella <[email protected]>
If an assertion is raised and we don't properly stop the mock server, the test stalls waiting for the server to finish. Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
The resampling actor test was very complex, including starting a mock gRPC server. This adds a lot of complexity to debug the test when it fails and adds a lot of unnecessary complexity to the test and mocking needs (we need to mock components in the component graph and interact with the microgrid API when the resampling actor knows nothing about the microgrid API). To completely remove the flakiness, we need to use some solution to mock time in asyncio (see frequenz-floss#70). Signed-off-by: Leandro Lucarella <[email protected]>
dca3a8c to
b0691f2
Compare
sahas-subramanian-frequenz
left a comment
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 LGTM. There's a commit updating channel version to the dev version. Do you want to remove that and take this in, and update channel version once there is a new release?
I'll wait and see if we can make the channels release soon enough. |
We will switch back to a release when the new release is ready. Signed-off-by: Leandro Lucarella <[email protected]>
Both ComponentMetricGroupResampler and ComponentMetricResampler have nothing to do with component metrics, so it makes no sense to have that in the name. Signed-off-by: Leandro Lucarella <[email protected]>
The resampler classes are already exposed via the `timeseries` package, so there is no need to have them exposed twice. Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
All the types left in `frequenz.sdk.data_pipeline(.types)` were specific to the data sourcing actor, so they were moved to `frequenz.sdk.data_sourcing.types` (and exported in `frequenz.sdk.data_sourcing`). The resampling actor for now is also forwarding requests to the data sourcing actor, so it also re-exports those symbols. Signed-off-by: Leandro Lucarella <[email protected]>
b0691f2 to
a62350c
Compare
|
Updated to move the |
This PR mainly moves classes from the resampler to the new
timeseriespackage, but it also includes some nox and test improvements and fixes.
It also uses the timestamp produced by the timer as the resampling timestamp,
unifying it across all the resampling levels for full consistency.