-
Notifications
You must be signed in to change notification settings - Fork 19
Validate component IDs when creating component pools #1340
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
Open
shsms
wants to merge
5
commits into
frequenz-floss:v1.x.x
Choose a base branch
from
shsms:pool-input-validation
base: v1.x.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−12
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
78f8f6f
Clear release notes
shsms 0425003
Validate component IDs when creating BatteryPool
shsms 3fd723b
Validate component IDs when creating PVPool
shsms 5c75707
Validate component IDs when creating EVChargerPool
shsms a162000
Update release notes
shsms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| # Frequenz Python SDK Release Notes | ||
|
|
||
| ## Bug fixes | ||
| ## Summary | ||
|
|
||
| - `FormulaEngine` and `FormulaEngine3Phase` are now type aliases to `Formula` and `Formula3Phase`, fixing a typing issue introduced in `v1.0.0-rc2202`. | ||
| <!-- Here goes a general summary of what this release is about --> | ||
|
|
||
| ## Upgrading | ||
|
|
||
| <!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with --> | ||
|
|
||
| ## New Features | ||
|
|
||
| <!-- Here goes the main new features and examples or instructions on how to use them --> | ||
|
|
||
| ## Bug Fixes | ||
|
|
||
| - Component IDs are validated during creation of battery, pv and ev charger pools, so that errors are caught early and we don't end up getting cryptic failures from somewhere else. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,12 +81,24 @@ def __init__( # pylint: disable=too-many-arguments | |||||||
| batteries_id: Subset of the batteries that should be included in the | ||||||||
| battery pool. If None or empty, then all batteries from the microgrid | ||||||||
| will be used. | ||||||||
|
|
||||||||
| Raises: | ||||||||
| ValueError: If any of the specified batteries is not present in the | ||||||||
| microgrid. | ||||||||
| """ | ||||||||
| self._batteries: frozenset[ComponentId] | ||||||||
| all_batteries = self._get_all_batteries() | ||||||||
| if batteries_id: | ||||||||
| self._batteries = frozenset(batteries_id) | ||||||||
| if not self._batteries.issubset(all_batteries): | ||||||||
| unknown_ids = self._batteries - all_batteries | ||||||||
|
Comment on lines
+93
to
+94
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could save a line of code and a couple cycles by reversing this:
Suggested change
(same for the rest)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that doesn't look like a subset check. |
||||||||
| raise ValueError( | ||||||||
| "Unable to create a BatteryPool. These component IDs are either " | ||||||||
| + "not batteries or are unknown: " | ||||||||
| + f"{unknown_ids}" | ||||||||
| ) | ||||||||
| else: | ||||||||
| self._batteries = self._get_all_batteries() | ||||||||
| self._batteries = all_batteries | ||||||||
|
|
||||||||
| self._working_batteries: set[ComponentId] = set() | ||||||||
|
|
||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would also add a note here, as this is effectively a breaking change. Users will need to update their code to deal with the exception, or validate the IDs before passing them to
new_xxx_pool().