Skip to content

Commit

Permalink
Fix: Generate protos using oldest allowed grpcio version (#307)
Browse files Browse the repository at this point in the history
* fix: generate using older grpcio ver

* chore: ver
  • Loading branch information
mrkaye97 authored Jan 31, 2025
1 parent 3d29644 commit b09f92e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 44 deletions.
8 changes: 8 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ cp $tmp_dir/hatchet_sdk/clients/rest/api/__init__.py $dst_dir/api/__init__.py
# remove tmp folder
rm -rf $tmp_dir


MIN_GRPCIO_VERSION=$(grep -A 1 'grpcio =' pyproject.toml | grep 'version' | sed -E 's/.*">=([0-9]+\.[0-9]+\.[0-9]+).*/\1/' | sort -V | head -n 1
)

poetry add "grpcio@$MIN_GRPCIO_VERSION" "grpcio-tools@$MIN_GRPCIO_VERSION"

poetry run python -m grpc_tools.protoc --proto_path=../oss/api-contracts/dispatcher --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts --grpc_python_out=./hatchet_sdk/contracts dispatcher.proto
poetry run python -m grpc_tools.protoc --proto_path=../oss/api-contracts/events --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts --grpc_python_out=./hatchet_sdk/contracts events.proto
poetry run python -m grpc_tools.protoc --proto_path=../oss/api-contracts/workflows --python_out=./hatchet_sdk/contracts --pyi_out=./hatchet_sdk/contracts --grpc_python_out=./hatchet_sdk/contracts workflows.proto

git restore pyproject.toml poetry.lock

# Fix relative imports in _grpc.py files
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
Expand Down
12 changes: 1 addition & 11 deletions hatchet_sdk/contracts/dispatcher_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions hatchet_sdk/contracts/dispatcher_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

from . import dispatcher_pb2 as dispatcher__pb2

GRPC_GENERATED_VERSION = '1.69.0'
GRPC_GENERATED_VERSION = '1.64.1'
GRPC_VERSION = grpc.__version__
EXPECTED_ERROR_RELEASE = '1.65.0'
SCHEDULED_RELEASE_DATE = 'June 25, 2024'
_version_not_supported = False

try:
Expand All @@ -16,12 +18,15 @@
_version_not_supported = True

if _version_not_supported:
raise RuntimeError(
warnings.warn(
f'The grpc package installed is at version {GRPC_VERSION},'
+ f' but the generated code in dispatcher_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
+ f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
+ f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
RuntimeWarning
)


Expand Down
12 changes: 1 addition & 11 deletions hatchet_sdk/contracts/events_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions hatchet_sdk/contracts/events_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

from . import events_pb2 as events__pb2

GRPC_GENERATED_VERSION = '1.69.0'
GRPC_GENERATED_VERSION = '1.64.1'
GRPC_VERSION = grpc.__version__
EXPECTED_ERROR_RELEASE = '1.65.0'
SCHEDULED_RELEASE_DATE = 'June 25, 2024'
_version_not_supported = False

try:
Expand All @@ -16,12 +18,15 @@
_version_not_supported = True

if _version_not_supported:
raise RuntimeError(
warnings.warn(
f'The grpc package installed is at version {GRPC_VERSION},'
+ f' but the generated code in events_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
+ f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
+ f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
RuntimeWarning
)


Expand Down
12 changes: 1 addition & 11 deletions hatchet_sdk/contracts/workflows_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions hatchet_sdk/contracts/workflows_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

from . import workflows_pb2 as workflows__pb2

GRPC_GENERATED_VERSION = '1.69.0'
GRPC_GENERATED_VERSION = '1.64.1'
GRPC_VERSION = grpc.__version__
EXPECTED_ERROR_RELEASE = '1.65.0'
SCHEDULED_RELEASE_DATE = 'June 25, 2024'
_version_not_supported = False

try:
Expand All @@ -16,12 +18,15 @@
_version_not_supported = True

if _version_not_supported:
raise RuntimeError(
warnings.warn(
f'The grpc package installed is at version {GRPC_VERSION},'
+ f' but the generated code in workflows_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
+ f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
+ f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
RuntimeWarning
)


Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hatchet-sdk"
version = "0.45.1"
version = "0.45.2"
description = ""
authors = ["Alexander Belanger <[email protected]>"]
readme = "README.md"
Expand All @@ -9,12 +9,12 @@ include = ["hatchet_sdk/py.typed"]
[tool.poetry.dependencies]
python = "^3.10"
grpcio = [
{ version = ">=1.64.1, !=1.68.*", markers = "python_version < '3.13'" },
{ version = ">=1.69.0", markers = "python_version >= '3.13'" }
{ version = ">=1.64.1, !=1.68.*", markers = "python_version < '3.13'" },
{ version = ">=1.69.0", markers = "python_version >= '3.13'" },
]
grpcio-tools = [
{ version = ">=1.64.1, !=1.68.*", markers = "python_version < '3.13'" },
{ version = ">=1.69.0", markers = "python_version >= '3.13'" }
{ version = ">=1.64.1, !=1.68.*", markers = "python_version < '3.13'" },
{ version = ">=1.69.0", markers = "python_version >= '3.13'" },
]
python-dotenv = "^1.0.0"
protobuf = "^5.29.1"
Expand Down

0 comments on commit b09f92e

Please sign in to comment.