Skip to content
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

Add new type ComponentId #795

Draft
wants to merge 1 commit into
base: v1.x.x
Choose a base branch
from
Draft

Conversation

Marenz
Copy link
Contributor

@Marenz Marenz commented Nov 27, 2023

This is a WIP and the current work is 90% done by ChatGPT.
I am currently busy with a few other things, so anyone can take over this PR and finish it.
Otherwise I'll get back to it when my important stuff is done.

@github-actions github-actions bot added part:data-pipeline Affects the data pipeline part:actor Affects an actor ot the actors utilities (decorator, etc.) part:microgrid Affects the interactions with the microgrid labels Nov 27, 2023
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

I would really avoid using NewType in this case, also I'm not sure if we should update all component_id to component as how the component is specified now is encoded in the type system, and could open the door to pass a component as an object for example (or even think more on a case-by-case basis if another name is more suitable). But I guess that part is out of scope for this PR.

@@ -17,6 +17,9 @@
from ...timeseries import Fuse


ComponentId = NewType("ComponentId", int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why NewType and not dataclass?

NewType allows this for example: ComponentId(1) + 2 and microgrid.battery_pool(priority=ComponentId(1)) which is just weird.

Also the str and repr looks just like a bare int, which might be good or not (I personally would like to at least have repr use ComponentId(1) instead of just 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, no specific reason, I selected NewType after a quick research, I am not set on using it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case I would use a dataclass, I see no benefits in using NewType and a few drawbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just a data class with one member you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup.

@llucax llucax modified the milestones: v1.0.0-rc5, v1.0.0-rc6 Jan 29, 2024
@llucax llucax modified the milestones: v1.0.0-rc6, v1.0.0-rc7 Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:actor Affects an actor ot the actors utilities (decorator, etc.) part:data-pipeline Affects the data pipeline part:microgrid Affects the interactions with the microgrid
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

None yet

2 participants