Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Nov 1, 2024

For some reason the Component and Connection objects were converted to dict to store them in the component graph. This requires re-building the objects when they need to be extracted, which is wasteful.

It also means that type information is lost, and in the future, when adopting the microgrid API client using v0.17, we have a class hierarchy for components instead of relaying in the category and type, so we would even need to store the type if we wanted to rebuild the objects.

Having nested objects is also an issue, as then the nested properties were kept as dict, adding an inconsistency and making it type-unsafe.

With this change we are able to get rid of a hack to retrieve the grid metadata.

Fixes #789.

@llucax llucax requested a review from a team as a code owner November 1, 2024 12:08
@llucax llucax requested review from daniel-zullo-frequenz and removed request for a team November 1, 2024 12:08
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:data-pipeline Affects the data pipeline part:microgrid Affects the interactions with the microgrid labels Nov 1, 2024
@llucax llucax force-pushed the component-graph-nodes branch from 82d3016 to 35a4a80 Compare November 1, 2024 12:08
@llucax llucax changed the title Store the original Component and Connection in the component graph Store the original Component and Connection in the component graph Nov 1, 2024
@llucax llucax self-assigned this Nov 1, 2024
@llucax llucax added this to the v1.0.0-rc1100 milestone Nov 1, 2024
@llucax llucax added type:tech-debt Improves the project without visible changes for users cmd:skip-release-notes It is not necessary to update release notes for this PR labels Nov 1, 2024
@llucax
Copy link
Contributor Author

llucax commented Nov 1, 2024

Skipping release notes as it is invisible to the user.

@llucax llucax enabled auto-merge November 1, 2024 12:09
Copy link
Contributor

@daniel-zullo-frequenz daniel-zullo-frequenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few minor comments to check for. LGTM otherwise

@daniel-zullo-frequenz
Copy link
Contributor

daniel-zullo-frequenz commented Nov 1, 2024

IIUC this PR is fixing #789. If that's the case, it should be mentioned in the PR description

@llucax llucax linked an issue Nov 1, 2024 that may be closed by this pull request
llucax and others added 5 commits November 4, 2024 12:42
For some reason the Component and Connection objects were converted to
`dict` to store them in the component graph. This requires re-building
the objects when they need to be extracted, which is wasteful.

It also means that type information is lost, and in the future, when
adopting the microgrid API client using v0.17, we have a class hierarchy
for components instead of relaying in the category and type, so we would
even need to store the type if we wanted to rebuild the objects.

Having nested objects is also an issue, as then the nested properties
were kept as `dict`, adding an inconsistency and making it type-unsafe.

With this change we are able to get rid of a hack to retrieve the grid
metadata.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
There is plenty we can still do without the metadata, so completely
disabling access to the grid connection point if we don't have metadata
is too strict.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Co-authored-by: Daniel Zullo <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
@llucax llucax force-pushed the component-graph-nodes branch from 35a4a80 to 90e2131 Compare November 4, 2024 11:42
@llucax
Copy link
Contributor Author

llucax commented Nov 4, 2024

Updated with the suggested fixes.

@llucax llucax added this pull request to the merge queue Nov 4, 2024
Merged via the queue into frequenz-floss:v1.x.x with commit c374a38 Nov 4, 2024
18 checks passed
@llucax llucax deleted the component-graph-nodes branch November 4, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:data-pipeline Affects the data pipeline part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests type:tech-debt Improves the project without visible changes for users

Projects

Development

Successfully merging this pull request may close these issues.

Fix Component Graph conversion from dict to class

2 participants