-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow optionally forcing power requests #365
Allow optionally forcing power requests #365
Conversation
78b0cea
to
890f3f7
Compare
890f3f7
to
1a64f55
Compare
Added unit tests:
Note that the current patch/solution depends on the metrics cache, therefore if the cache is not available for a non-working battery then the battery won't be used even though the request is forced. This needs to be discussed as it was my personal assumption rather something explicitly added in the issue #312 or agreed with the team. |
1a64f55
to
9b6fe90
Compare
9b6fe90
to
c85cb50
Compare
src/frequenz/sdk/actor/power_distributing/power_distributing.py
Outdated
Show resolved
Hide resolved
c85cb50
to
4babd11
Compare
It was agreed that the power need to be distributed equally between the batteries if there is no previous metrics cached and the request is forced. |
4babd11
to
297f9f3
Compare
297f9f3
to
59f713c
Compare
src/frequenz/sdk/actor/power_distributing/power_distributing.py
Outdated
Show resolved
Hide resolved
FYI, if this is blocking @shsms to move fast with his PR, I'm fine to merge this as is and address the remaining comments in a separate PR. We need to make sure to get the public API right before the release, but other minor improvements like the dataclass stuff or internal argument names can be worked out even after the release. |
24a08eb
to
552ff65
Compare
Signed-off-by: Daniel Zullo <[email protected]>
Future annotations is already imported and it should be used instead. Signed-off-by: Daniel Zullo <[email protected]>
A test was not added when the power distributing actor was updated in the past to use all the batteries for cases where all of them are reported as not working batteries. Signed-off-by: Daniel Zullo <[email protected]>
To make it consistent with recently added power distributing tests. Signed-off-by: Daniel Zullo <[email protected]>
The _get_working_batteries method had unnecessary complexity and was redundant as it was returning the original set of batteries if there was any working battery. Therefore, this commit removes the _get_working_batteries method and simplifies the check for working batteries. Signed-off-by: Daniel Zullo <[email protected]>
Requests with empty batteries set need to be rejected. Signed-off-by: Daniel Zullo <[email protected]>
662467f
to
c24b165
Compare
I've updated following most of the suggestions. However we still need to make our minds about the attribute name to force the power requests. Also documentation needs to be improved/amended. I´d suggest to review it again focus in the logic and we can address the naming and documentation updates in follow-up PRs to unblock Sahas |
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.
Except from my own mistakes, LGTM :D
src/frequenz/sdk/actor/power_distributing/power_distributing.py
Outdated
Show resolved
Hide resolved
src/frequenz/sdk/actor/power_distributing/power_distributing.py
Outdated
Show resolved
Hide resolved
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.
An improvement for a subsequent PR could be to use timestamps coming from the microgrid component data, rather than repeated calls to time.monotonic_ns
, when creating the cache entries.
src/frequenz/sdk/actor/power_distributing/power_distributing.py
Outdated
Show resolved
Hide resolved
c24b165
to
43c2135
Compare
A power request might need to be forced to implement safety mechanisms, even when some components might be seemingly failing (i.e. when there is not proper consumption information, the user wants to slowly discharge batteries to prevent potential peak breaches). Signed-off-by: Daniel Zullo <[email protected]>
43c2135
to
7fa7b70
Compare
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.10.0 to 3.11.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-mock/releases">pytest-mock's releases</a>.</em></p> <blockquote> <h2>v3.11.1</h2> <ul> <li> <p>Fixed introspection for failed <code>assert_has_calls</code> (<a href="https://github.com/pytest-dev/pytest-mock/issues/365">#365</a>).</p> </li> <li> <p>Updated type annotations for <code>mocker.patch</code> and <code>mocker.spy</code> (<a href="https://github.com/pytest-dev/pytest-mock/issues/364">#364</a>).</p> </li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst">pytest-mock's changelog</a>.</em></p> <blockquote> <h2>3.11.1 (2023-06-15)</h2> <ul> <li> <p>Fixed introspection for failed <code>assert_has_calls</code> (<code>[#365](https://github.com/pytest-dev/pytest-mock/issues/365)</code>_).</p> </li> <li> <p>Updated type annotations for <code>mocker.patch</code> and <code>mocker.spy</code> (<code>[#364](https://github.com/pytest-dev/pytest-mock/issues/364)</code>_).</p> </li> </ul> <p>.. _<a href="https://github.com/pytest-dev/pytest-mock/issues/365">#365</a>: <a href="https://github.com/pytest-dev/pytest-mock/pull/365">pytest-dev/pytest-mock#365</a> .. _<a href="https://github.com/pytest-dev/pytest-mock/issues/364">#364</a>: <a href="https://github.com/pytest-dev/pytest-mock/pull/364">pytest-dev/pytest-mock#364</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/d3e73f2e93f7b93eba0a36e17e43bafd969da4fe"><code>d3e73f2</code></a> Explicitly specify the tag name during GitHub Release</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/5668efe23e01673af9905febeefd9a9791b023f4"><code>5668efe</code></a> Update CHANGELOG for 3.11.0</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/c9a4d13ab4e808ef02250898a79c07b2acf76f61"><code>c9a4d13</code></a> Improve CI</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/5818160717a16b7f8867d950ed60b9dc3349ec8d"><code>5818160</code></a> Add assert_has_calls_wrapper (<a href="https://github.com/pytest-dev/pytest-mock/issues/365">#365</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/355b5aae1a1a9b3f2c17b2a6bbfde9980967bceb"><code>355b5aa</code></a> Fix return type annotation for patch and spy (<a href="https://github.com/pytest-dev/pytest-mock/issues/364">#364</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/8ba681201488bec69f27f6e9e2a56988a01f0d1b"><code>8ba6812</code></a> [pre-commit.ci] pre-commit autoupdate (<a href="https://github.com/pytest-dev/pytest-mock/issues/362">#362</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/786eaaf416fed8204a8aebb29cbf71527228a9f6"><code>786eaaf</code></a> [pre-commit.ci] pre-commit autoupdate (<a href="https://github.com/pytest-dev/pytest-mock/issues/360">#360</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/1cb146af21ffd0b5be24703419cf4a192c4ec0ab"><code>1cb146a</code></a> Push tag manually</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/9608e9659b1f062bb09915f3ef1c538ca7cb5c5f"><code>9608e96</code></a> Update permissions for deploy workflow</li> <li><a href="https://github.com/pytest-dev/pytest-mock/commit/c778ee73bd516d465dca3512d099682ba32108fa"><code>c778ee7</code></a> Fix deployment workflow (<a href="https://github.com/pytest-dev/pytest-mock/issues/358">#358</a>)</li> <li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest-mock/compare/v3.10.0...v3.11.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest-mock&package-manager=pip&previous-version=3.10.0&new-version=3.11.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
A power request might need to be forced to implement safety mechanisms, even when some components might be
seemingly failing (i.e. when there is not proper consumption information, the user wants to slowly discharge batteries to
prevent potential peak breaches).
Fixes #321