-
Notifications
You must be signed in to change notification settings - Fork 4
Initial client #7
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
Initial client #7
Conversation
9d2d8f1
to
818c66e
Compare
818c66e
to
21a75dd
Compare
21a75dd
to
8dcf561
Compare
manufacturer: str | ||
model_name: str | ||
status: str | ||
start_timestamp: Optional[datetime] |
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.
{start,end}_time
id: int | ||
enterprise_id: int | ||
name: str | ||
delivery_area_code: Optional[str] |
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.
Optional = str | None
longitude=location.longitude if location else None, | ||
country_code=location.country_code if location else None, | ||
status=pb.status, | ||
created_at=pb.create_timestamp.ToDatetime().replace(tzinfo=timezone.utc), |
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.
create_time
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.
microgrid_id: int | ||
name: str | ||
category: str | ||
category_metadata: dict[str, Any] |
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.
This is a bit tricky, I think the type implementation for the metadata variant should also be implemented in common client.
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.
Will be addressed after common-client wrappers have been reviewed
category_metadata: dict[str, Any] | ||
manufacturer: str | ||
model_name: str | ||
status: str |
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.
Same here, we need to use a python equivalent of that type (I think it exists also already in common).
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.
Will be addressed after common-client wrappers have been reviewed
status: str | ||
start_timestamp: Optional[datetime] | ||
end_timestamp: Optional[datetime] | ||
metric_config_bounds: list[dict] |
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 metric could be the key and the bounds be in a dedicated dataclass. Maybe also worth in common?
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.
Will be addressed after common-client wrappers have been reviewed
|
||
# pylint: disable=too-many-instance-attributes | ||
@dataclass(frozen=True) | ||
class Microgrid: |
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 am not sure if all these dataclasses here should go into the common client repo
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.
Should we discuss this with someone else from the api-team?
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.
Posted it in the assets-channel to get some opinions on it.
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.
Will be addressed after common-client wrappers have been reviewed
self, | ||
microgrid_id: int, | ||
source_component_ids: Optional[list[int]] = None, | ||
destination_component_ids: Optional[list[int]] = None, |
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 think it would be useful to be able to optionally pass a timestamp and the connections are filtered such that only those relevant to that point in time are returned.
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.
Still missing in service
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.
It could be implemented in the client already since we have this information. However, it's not so easy since it would ideally support a time range, which could result in multiple graphs. Maybe that's something for the assets API tooling.
8dcf561
to
18f523a
Compare
7bd17bd
to
deb6533
Compare
0797dc2
to
2609589
Compare
2609589
to
e33fa52
Compare
Signed-off-by: Flora <[email protected]>
e33fa52
to
42b012e
Compare
@cwasicki & @cyiallou: I would like to get this one merged if possible (it is working, but has been open very long due to dependencies on other repos). We can then improve on the open topics (such taking wrappers out and using the ones from client-common once available , generally updating the service / assets-api to common-api v0.8.0 etc) in follow up PRs. Costas, Richard & I will meet tomorrow to discuss open topics and next steps forward. Let me know if anything speaks against this plan of action. |
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.
Thanks for putting this together. I’m still getting up to speed with all the integration points across the various repos, so I’m not in a position to fully evaluate all the implementation details just yet. From what I can see, the client seems functional, but it looks like tests are still missing, and as you noted, some refactoring would be needed. I imagine those improvements could be done in follow-up PRs.
I will hold off on giving a formal approval for now and would appreciate if someone with more context around the broader system could take a closer look.
@@ -0,0 +1,86 @@ | |||
# License: MIT |
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.
This would be better implemented as a CLI tool similar to the reporting client.
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.
Actually more like the CLI tool in trading, which provides an example for different endpoints.
source_component_ids: List of source component IDs to filter. | ||
destination_component_ids: List of destination component IDs to filter. | ||
""" | ||
server_url = "localhost:50052" |
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.
Should be a command line argument.
|
||
source_component_id: int | ||
destination_component_id: int | ||
start_time: Optional[datetime] |
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.
datetime | None
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.
You can replace all Optional
s in this module following this pattern
self, | ||
microgrid_id: int, | ||
source_component_ids: Optional[list[int]] = None, | ||
destination_component_ids: Optional[list[int]] = None, |
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.
It could be implemented in the client already since we have this information. However, it's not so easy since it would ideally support a time range, which could result in multiple graphs. Maybe that's something for the assets API tooling.
with the component. | ||
""" | ||
|
||
id: 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.
Needs docstrings.
|
||
# pylint: disable=too-many-instance-attributes | ||
@dataclass | ||
class ElectricalComponent: |
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.
What's the status of these in the common repo? Can't this be used already? https://github.com/frequenz-floss/frequenz-api-common/blob/v0.8.0/proto/frequenz/api/common/v1alpha8/microgrid/electrical_components/electrical_components.proto
|
||
|
||
@dataclass | ||
class ElectricalComponentConnection: |
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.
This one was replaced by #21, right @eduardiazf ? |
Only partly, e.g. the connection part is not part of #21. |
@llucax @cwasicki , Just close this one since @eduardiazf will cover the missing methods in separate PRs |
First draft of initial client, tests still need to be added.