-
Notifications
You must be signed in to change notification settings - Fork 11
Update base client to v0.7.0 #66
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
Update base client to v0.7.0 #66
Conversation
560ddd6 to
e1f5969
Compare
| # pylint: disable=no-member | ||
| from frequenz.api.electricity_trading.v1 import electricity_trading_pb2 | ||
| from frequenz.api.electricity_trading.v1.electricity_trading_pb2_grpc import ( | ||
| ElectricityTradingServiceAsyncStub, |
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.
@llucax, we can't import the async stub like this, right? Should this only be under if typing.TYPE_CHECKING:?
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 was done here in the example section of the upgrading section of the new base client release. But since it's just an example I don't know if it was tested
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 just tried as well, can't find an easy solution. I guess we need to wait for @llucax
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.
try just importing
from frequenz.api.electricity_trading.v1 import electricity_trading_pb2_grpc
and then just using electricity_trading_pb2_grpc.ElectricityTradingServiceAsyncStub with a global setting to disable the no-member check in pyproject.toml
[tool.pylint.messages_control]
disable = [
[..]
# Checked by mypy
"no-member",
[..]
]
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 @Marenz for the summary, that should work.
I just updated the release notes (once again) to hopefully provide instructions that finally work.
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.
Correction: I wrote electricity_trading_pb2 but meant electricity_trading_pb2_grpc, it is updated in my 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.
I still get an error from pytest_min and pytest_max:
ERROR AttributeError: module 'frequenz.api.electricity_trading.v1.electricity_trading_pb2_grpc' has no attribute 'ElectricityTradingServiceAsyncStub'
| super().__init__(server_url, ElectricityTradingServiceStub, connect=connect) | ||
| super().__init__(server_url, connect=connect) | ||
| self._stub = cast( | ||
| ElectricityTradingServiceAsyncStub, | ||
| ElectricityTradingServiceStub(self.channel), | ||
| ) |
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 seems there's another problem here.
We have to create the _stub when we are connecting. So if connect=False, we can't create the stub immediately, because there's no channel.
And we're going to have to override connect, to call super.connect(), then create the stub.
@llucax this is also not covered in the upgrade notes.
I'll try to make a working patch for this now.
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 new base client's interface feels inconsistent compared to the older one because we have to override connect, but with that, it works for now.
c2440a2 to
3c9cfd9
Compare
The user had tried to instantiate the client outside the asyncio event loop, but it must be created within the loop to handle asynchronous calls correctly. This change updates the examples to use async functions and runs them within an asyncio event loop. Signed-off-by: Daniel Zullo <[email protected]>
Signed-off-by: camille-bouvy-frequenz <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
Also import the `ElectricityTradingServiceAsyncStub` type only when `TYPE_CHECKING`. Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
3c9cfd9 to
6be510e
Compare
Signed-off-by: camille-bouvy-frequenz <[email protected]>
6be510e to
98bcb0b
Compare
Update base client from 0.6.1 to v0.7.0, and upgrade the code accordingly.