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

Import code from the SDK v1.0.0-rc5 #9

Merged
merged 11 commits into from
Feb 28, 2024

Conversation

llucax
Copy link
Contributor

@llucax llucax commented Feb 27, 2024

The microgrid API client code is imported as-is from the SDK v1.0.0-rc5, except for some fixes to make nox/the CI pass:

  • Fix imports
  • Add the missing Fuse type
  • Workaround a weird mypy error about type mismatch in grpcio
  • Fix wrong comparison
  • Ignore pylint check

Any other cleanups and improvements will be done in future PRs.

The code is imported **as-is** from the SDK v1.0.0-rc5, without any
modification. The code will be adapted to make it work independently
in the next commits.

Signed-off-by: Leandro Lucarella <[email protected]>
These are the dependencies used currently in the SDK by the code we just
imported.

Signed-off-by: Leandro Lucarella <[email protected]>
We need this to be able to use it as a Python package, and do relative
imports for example.

Signed-off-by: Leandro Lucarella <[email protected]>
Adapt the imports to find the modules in the new repository structure
instead of the SDK, where possible.

Signed-off-by: Leandro Lucarella <[email protected]>
We add the `Fuse` class from `frequenz.sdk.timeseries._fuse`
which was misplaced (or rather mixed 2 classes, the client class with
the higher-level class using `Quantity`s) and adapt to use raw `float`s
instead of the `Current` `Quantity`.

Signed-off-by: Leandro Lucarella <[email protected]>
Without the `type: ignore`, this triggers an error:

> Argument "trailing_metadata" to "AioRpcError" has incompatible type
> "tuple[_Metadatum, ...]"; expected "Metadata"

My guess is this is a bug in grpcio bug, the documentation[1] says both
the constructor and the method should return `Metadata`. Checking the
code, it also have the correct type hinting, but `mypy` shows another
error in `trailing_metadata()` saying it is overriding the parent class
incorrectly. Also the type hints are correct but type checking is
completely ignored, as for example internally in the error class the
trailing_metada is `Metadata | None`, but then it is returned as just
`Metadata` without checking for `None` or explicitly `cast`ing. This is
why I suspect it is a grpcio bug, but I couldn't find any reports for
it. It might be a good idea to open one at some point if necessary.

I'm not sure why this is not happening in the SDK.

[1] https://grpc.github.io/grpc/python/grpc_asyncio.html#grpc.aio.AioRpcError

Signed-off-by: Leandro Lucarella <[email protected]>
The types generated by grpc are different (created via `NewType`), so
we should compare the `int` values instead.

Signed-off-by: Leandro Lucarella <[email protected]>
These classes are expected to have quite a few attributes.

Signed-off-by: Leandro Lucarella <[email protected]>
@llucax llucax requested a review from a team as a code owner February 27, 2024 12:30
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:client Affects the client code labels Feb 27, 2024
@llucax llucax requested a review from shsms February 27, 2024 12:30
@llucax llucax self-assigned this Feb 27, 2024
@llucax llucax added this to the v0.1.0 milestone Feb 27, 2024
@llucax
Copy link
Contributor Author

llucax commented Feb 27, 2024

@cwasicki @flora-hofmann-frequenz FYI (although is not really that interesting, because this is the code that's using the old microgrid API version, which is quite different from the new version, which is the one more similar to the reporting API).

Signed-off-by: Leandro Lucarella <[email protected]>
@github-actions github-actions bot added the part:docs Affects the documentation label Feb 27, 2024
Marenz
Marenz previously approved these changes Feb 27, 2024
Copy link
Contributor

@Marenz Marenz left a comment

Choose a reason for hiding this comment

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

LGTM, though I am sad about the loss of Quantities for the fuse class

@llucax
Copy link
Contributor Author

llucax commented Feb 27, 2024

LGTM, though I am sad about the loss of Quantities for the fuse class

That should be addressed in the higher-level interface.

@llucax llucax enabled auto-merge February 27, 2024 13:55
@llucax
Copy link
Contributor Author

llucax commented Feb 27, 2024

I was going to merge so I can move forward, as it is just importing code, but I still need a review from a code owner (@frequenz-floss/api-microgrid-team). Not sure if we want to change this, at least for repos that need a fast pace during the initial development (either add more owners or remove the requirement that only code owners can really approve)

@shsms
Copy link
Contributor

shsms commented Feb 27, 2024

Why is it owned by the microgrid api team? They don't know this code and didn't write it either. Unless you want to change the composition of the microgrid team, this should be owned by the sdk team.

@leandro-lucarella-frequenz
Copy link
Contributor

I added a new commit to add the SDK team as an owner but we still need approval from the old owner to merge the change of ownership. I also added a discussion item for next meeting to talk about team structure.

@leandro-lucarella-frequenz
Copy link
Contributor

I'm force-merging to unblock this.

@leandro-lucarella-frequenz leandro-lucarella-frequenz merged commit 27a7466 into frequenz-floss:v0.x.x Feb 28, 2024
14 checks passed
@llucax llucax deleted the sdk-1.0.0rc5 branch February 28, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:client Affects the client code part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants