-
Notifications
You must be signed in to change notification settings - Fork 4
Change type of TargetComponents #170
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
Change type of TargetComponents #170
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 updates the TargetComponents
API to use ComponentId
wrappers instead of raw integers, adjusts all related serialization logic and tests, and exposes the new type in the public API.
- Swapped
list[int]
forlist[ComponentId]
inTargetComponents
and conversion functions - Updated tests, CLI mocks, and data generators to wrap targets in
ComponentId
- Added
frequenz-client-microgrid
dependency and documented the change in release notes
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
tests/test_proto.py | Updated target lists to use ComponentId |
tests/test_cli.py | Wrapped CLI mock targets in ComponentId and adjusted type hints |
src/frequenz/client/dispatch/types.py | Changed TargetComponents alias, import, and protobuf converters |
src/frequenz/client/dispatch/test/generator.py | Updated random generator to yield ComponentId |
src/frequenz/client/dispatch/init.py | Exported TargetComponents in __all__ |
pyproject.toml | Added frequenz-client-microgrid dependency |
RELEASE_NOTES.md | Documented new ComponentId usage and dependency |
Comments suppressed due to low confidence (2)
src/frequenz/client/dispatch/types.py:86
- The pattern
case list(component_ids)
is a class pattern and may not match arbitrary lists as expected. Consider using a sequence pattern likecase [*component_ids] if all(...)
.
case list(component_ids) if all(isinstance(id, ComponentId) for id in component_ids):
pyproject.toml:43
- Align this dependency's indentation with the other entries in
[tool.poetry.dependencies]
for consistency.
"frequenz-client-microgrid >= 0.7.0, < 0.8.0",
@@ -40,6 +40,7 @@ dependencies = [ | |||
"frequenz-api-dispatch == 1.0.0-rc1", | |||
"frequenz-client-base >= 0.8.0, < 0.10.0", | |||
"frequenz-client-common >= 0.1.0, < 0.4.0", | |||
"frequenz-client-microgrid >= 0.7.0, < 0.8.0", |
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.
Let's not do this yet. If needed we should move it to frequenz-client-common
. I will do a PR soon.
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.
But I need this now to move actor to latest SDK :)
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 guess if it is temporary is OK, but please create an issue so we don't forget to remove the dependency in the future.
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.
On a second thought, it is not necessary to start using ComponentId
, you can always convert between it and int
freely (cid = ComponentId(1)
/ id = int(cid)
).
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.
TargetComponents is part of DispatchRequest.
Actor receives DispatchRequest and needs to create BatteryPool from the target.
BatteryPool expects set[ComponentId] :)
I can to change every actor to change int
to ComponentId.
But after we add this, I would have to revert this change in every actor.
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.
Mmmm, damn. I guess then I'm back to the "OK as a temporary thing" 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.
please create an issue so we don't forget to remove the dependency in the future.
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.
We can use typing.SupportsInt and support the unknown to int castable ComponentsId that way
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.
how would it fix it? The problem with Actor will still be there. They except ComponentId, get int.
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.
Marenz had awesome idea to make this change temporarily somewhere else :)
frequenz-floss/frequenz-dispatch-python#156
ad830ef
to
3c08ffc
Compare
3c08ffc
to
e9bf91a
Compare
Because it is used in other code. Signed-off-by: Elzbieta Kotulska <[email protected]>
* `frequenz.client.dispatch.TargetComponents` is now public * its type has changed from `list[int] | list[ComponentCategory]` to `list[ComponentId] | list[ComponentCategory]`. * This change introduces a new dependency on `frequenz-client-microgrid` (>= v0.7.0, < 0.8.0) for the `frequenz.client.microgrid.ComponentId` type. Signed-off-by: Elzbieta Kotulska <[email protected]>
e9bf91a
to
22be2c2
Compare
Closed in favor of frequenz-floss/frequenz-dispatch-python#156 |
No description provided.