-
Couldn't load subscription status.
- Fork 20
Ensure root component is as close as possible to the grid component #1216
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
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 improves the behavior of find_first_descendant_component so that when searching for a component with a non‑GRID root category, the method uses the grid component as the base and returns the closest matching descendant.
- Introduces a separate branch for GRID components that directly selects the component from self.components.
- For non‑GRID components, validates the existence of a grid component and then recursively locates the appropriate descendant.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/frequenz/sdk/microgrid/component_graph.py | Adjusted find_first_descendant_component method for deterministic grid component look‑up. |
| RELEASE_NOTES.md | Updated release notes to describe the fixed bug in the find_first_descendant_component method. |
Comments suppressed due to low confidence (1)
src/frequenz/sdk/microgrid/component_graph.py:877
- [nitpick] Consider reusing the already obtained grid_component to search for the descendant instead of making a recursive call, which would reduce redundant graph traversals.
root_component = self.find_first_descendant_component(root_category=ComponentCategory.GRID, descendant_categories=[root_category])
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.
The other comments are optional, but I also wonder what happens with islands, we are supposed to support islands. Isn't there any way to find descendants if there is no grid connection?
|
I'm actually wondering why we need to support this Unless you're against, I'll remove this parameter. But if we keep it instead, we should reject everything that's not the GRID. The rest are not "root", because there can be multiple of them. But there can only be one GRID component in the graph. |
|
Ideally this function is replaced by a bfs, but I will not do that now. |
The `find_first_descendant_component` accepted a `root_category` where categories could be specified that were not really the root of the graph. This feature was not necessary (and was never used) and was buggy. It is removed in this commit. Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
There was some bfs implemented by @matthias-wende-frequenz somewhere, IIRC. |
No, he made a dfs |
The
find_first_descendant_componentaccepts aroot_categoryand findsa component matching that category to begin traversing from. This PR
ensures that the matching root component that's found is as close as
possible to the GRID component.