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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
411 changes: 252 additions & 159 deletions poetry.lock

Large diffs are not rendered by default.

29 changes: 24 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ python = "^3.8"
oauthlib = "^3.1.0"
requests-oauthlib = ">=1.3.0,<3.0.0"
aiofiles = ">=0.7,<25"
zeebe-grpc = "^8.4.0"
grpcio = ">=1.66.0"
grpcio-tools = ">=1.66.0"
protobuf = ">=5.27.2,<5.28.0"
typing-extensions = "^4.11.0"

[tool.poetry.group.dev.dependencies]
Expand All @@ -45,33 +47,50 @@ importlib-metadata = ">=6.8,<9.0"
types-aiofiles = ">=0.7,<25"
types-oauthlib = "^3.1.0"
types-requests-oauthlib = ">=1.3.0,<3.0.0"
types-protobuf = "*"
mypy-protobuf = "*"

[tool.mypy]
python_version = "3.8"
packages = ["pyzeebe"]
strict = true

[[tool.mypy.overrides]]
module = "grpc"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
"grpc",
"zeebe_grpc.gateway_pb2",
"zeebe_grpc.gateway_pb2_grpc",
"pyzeebe.proto.*"
]
ignore_missing_imports = true
#disallow_untyped_defs = false
disable_error_code = [ "import-untyped", "unused-ignore"] # "type-arg"

[tool.pylint.master]
max-line-length = 120
disable = ["C0114", "C0115", "C0116"]

[tool.black]
line-length = 120
extend-exclude = '''
(
.*_pb2.py # exclude autogenerated Protocol Buffer files anywhere in the project
| .*_pb2_grpc.py
)
'''

[tool.isort]
profile = "black"
extend_skip_glob = ["*_pb2.py", "*_pb2_grpc.py", "*.pyi"]

[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.coverage.run]
omit = [
"pyzeebe/proto/*"
]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion pyzeebe/grpc_internals/zeebe_adapter_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import NoReturn

import grpc
from zeebe_grpc.gateway_pb2_grpc import GatewayStub

from pyzeebe.errors import (
UnknownGrpcStatusCodeError,
Expand All @@ -12,6 +11,7 @@
)
from pyzeebe.errors.pyzeebe_errors import PyZeebeError
from pyzeebe.grpc_internals.grpc_utils import is_error_status
from pyzeebe.proto.gateway_pb2_grpc import GatewayStub

logger = logging.getLogger(__name__)

Expand Down
14 changes: 7 additions & 7 deletions pyzeebe/grpc_internals/zeebe_job_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
from typing import AsyncGenerator, Iterable, Optional

import grpc
from zeebe_grpc.gateway_pb2 import (
ActivatedJob,
ActivateJobsRequest,
CompleteJobRequest,
FailJobRequest,
ThrowErrorRequest,
)

from pyzeebe.errors import (
ActivateJobsRequestInvalidError,
Expand All @@ -20,6 +13,13 @@
from pyzeebe.grpc_internals.grpc_utils import is_error_status
from pyzeebe.grpc_internals.zeebe_adapter_base import ZeebeAdapterBase
from pyzeebe.job.job import Job
from pyzeebe.proto.gateway_pb2 import (
ActivatedJob,
ActivateJobsRequest,
CompleteJobRequest,
FailJobRequest,
ThrowErrorRequest,
)
from pyzeebe.types import Variables

from .types import CompleteJobResponse, FailJobResponse, ThrowErrorResponse
Expand Down
2 changes: 1 addition & 1 deletion pyzeebe/grpc_internals/zeebe_message_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from typing import Optional

import grpc
from zeebe_grpc.gateway_pb2 import PublishMessageRequest

from pyzeebe.errors import MessageAlreadyExistsError
from pyzeebe.grpc_internals.grpc_utils import is_error_status
from pyzeebe.grpc_internals.zeebe_adapter_base import ZeebeAdapterBase
from pyzeebe.proto.gateway_pb2 import PublishMessageRequest
from pyzeebe.types import Variables

from .types import PublishMessageResponse
Expand Down
22 changes: 11 additions & 11 deletions pyzeebe/grpc_internals/zeebe_process_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@

import aiofiles
import grpc
from zeebe_grpc.gateway_pb2 import (
CancelProcessInstanceRequest,
CreateProcessInstanceRequest,
CreateProcessInstanceWithResultRequest,
DecisionMetadata,
DecisionRequirementsMetadata,
DeployResourceRequest,
FormMetadata,
ProcessMetadata,
Resource,
)

from pyzeebe.errors import (
InvalidJSONError,
Expand All @@ -26,6 +15,17 @@
)
from pyzeebe.grpc_internals.grpc_utils import is_error_status
from pyzeebe.grpc_internals.zeebe_adapter_base import ZeebeAdapterBase
from pyzeebe.proto.gateway_pb2 import (
CancelProcessInstanceRequest,
CreateProcessInstanceRequest,
CreateProcessInstanceWithResultRequest,
DecisionMetadata,
DecisionRequirementsMetadata,
DeployResourceRequest,
FormMetadata,
ProcessMetadata,
Resource,
)
from pyzeebe.types import Variables

from .types import (
Expand Down
Empty file added pyzeebe/proto/__init__.py
Empty file.
Loading
Loading