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

feat: generate python class interface from protobuf #476

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

felicijus
Copy link
Contributor

@felicijus felicijus commented Sep 9, 2024

Description of PR...

Changes

  • add proto directory for protobuf and the generated stub and interface files
  • remove zeebe-grpc

API Updates

New Features (required)

Latest version of Zeebe API (GRPC) proto.

  1. grpcio = ">=1.66.0"
  2. grpcio-tools = ">=1.66.0"
  3. protobuf = ">=5.27.2,<5.28.0
  4. types-protobuf
  5. mypy-protobuf

Command for generation with .pyi:

python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. --pyi_out=. ./pyzeebe/proto/gateway.proto

or with mypy

python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. --mypy_out . --mypy_grpc_out . ./pyzeebe/proto/gateway.proto

Deprecations (required)

Package zeebe-grpc is no longer used. And is removed rom pyproject.toml
Removed all traces of zeebe-grpc and exchanged for the new stubs and interface files generated from .proto

Enhancements (optional)

Now .pyi interface file is available and supports better type hints.

Checklist

  • Unit tests
  • Documentation

References

https://grpc.io/docs/languages/python/basics/#generating-client-and-server-code
https://mypy.readthedocs.io/en/stable/stubs.html

Resolves #475

felicijus and others added 4 commits September 9, 2024 18:25
Command for generation with .pyi:
python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. --pyi_out=. ./pyzeebe/proto/gateway.proto
mypy-protobuf is more precise in the generated interface.
@dimastbk
Copy link
Collaborator

Hi. Why not fix it in zeebe-grpc?

@felicijus
Copy link
Contributor Author

The reasoning was that we could track changes more closely if we maintained it ourselves, which I think is even more important if we use the mypy option.

Secondly, it's the interfaces for connecting to zeebe that we are programming against, especially when using typing. My understanding is that the interface belongs in the package itself.

By the way, which version do you prefer, mypy or just the pyi?

@dimastbk
Copy link
Collaborator

I think this package shouldn't be a part of pyzeebe:

  1. some people may want to use only grpc stubs without worker;
  2. zeebe-grpc should have own release cycle.

@felicijus felicijus marked this pull request as draft September 26, 2024 17:47
@felicijus
Copy link
Contributor Author

Hello,
just looked into older stuff.

  1. You can still to that even with pyzeebe, stubs are still there.
  2. Yes it should, but if you already do releases (way more often thaan (zeebe-grpc) why not automate the stub file creation plus mypy for types for every release, meaning no upstream dependency and always the latest interface?

Kind Regards
Felix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate python class interface files from protobuf
2 participants