Skip to content

Commit c69cfa1

Browse files
dirkkultsmith023
andauthored
Fixup dependencies for package test (#1791)
* Fixup dependencies for package test * Explicitly depend on protobuf * Add changelog * Fix test dependencies * Install proper protobuf dependency * Add stubs for v5.27.4 and v5.28.3, required due to incompatibilities with v5.26.1 and higher minor vers * Change to generate with minimum supported grpcio-tools dep for pb major ver * Add test to matrix of incompat grpcio with pb * Raise custom exception on incompatible grpc/pb versions for stubs * Add test verifying compatability throw for all grpcio/protobuf combinations * Add install of test deps in new test * Remove env var drilling in test * Move test to standalone package to avoid imports outside of test * Add missed init for pkg * Move weaviate import into test * Except the expected connection error in new test * Fix test for wrong protos * Remove other import * Fix checking of exception message * More fixes * Remove yanked dep in test --------- Co-authored-by: Tommy Smith <[email protected]>
1 parent 334380b commit c69cfa1

28 files changed

+947
-209
lines changed

.github/workflows/main.yaml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ jobs:
9797
name: coverage-report-${{ matrix.folder }}
9898
path: coverage-${{ matrix.folder }}.xml
9999

100+
proto-test:
101+
name: Run importing protos test
102+
runs-on: ubuntu-latest
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
grpc: ["1.59.5", "1.63.0", "1.65.0", "1.66.0", "1.68.0", "1.72.1", "1.73.0", "1.74.0"]
107+
protobuf: ["4.25.8", "5.26.0", "5.27.4", "5.28.3", "5.29.0", "6.30.0", "6.31.1", "6.32.0"]
108+
steps:
109+
- uses: actions/checkout@v4
110+
- uses: actions/setup-python@v5
111+
with:
112+
python-version: "3.11"
113+
cache: 'pip' # caching pip dependencies
114+
- run: |
115+
pip install -r requirements-test.txt -r requirements-devel.txt
116+
pip install grpcio==${{ matrix.grpc }} protobuf==${{ matrix.protobuf }}
117+
- name: Run proto test
118+
run: pytest proto_test/test_proto.py
119+
100120
integration-tests-embedded:
101121
name: Run Integration Tests Embedded
102122
runs-on: ubuntu-latest
@@ -133,11 +153,11 @@ jobs:
133153
fail-fast: false
134154
matrix:
135155
versions: [
136-
{ py: "3.9", weaviate: $WEAVIATE_131, grpc-version: "1.59.0"},
137-
{ py: "3.10", weaviate: $WEAVIATE_131, grpc-version: "1.66.0"},
138-
{ py: "3.11", weaviate: $WEAVIATE_131, grpc-version: "1.70.0"},
139-
{ py: "3.12", weaviate: $WEAVIATE_131, grpc-version: "1.70.0"},
140-
{ py: "3.13", weaviate: $WEAVIATE_131, grpc-version: "1.70.0"}
156+
{ py: "3.9", weaviate: $WEAVIATE_131, grpc: "1.59.0"},
157+
{ py: "3.10", weaviate: $WEAVIATE_131, grpc: "1.66.0"},
158+
{ py: "3.11", weaviate: $WEAVIATE_131, grpc: "1.70.0"},
159+
{ py: "3.12", weaviate: $WEAVIATE_131, grpc: "1.72.1"},
160+
{ py: "3.13", weaviate: $WEAVIATE_131, grpc: "1.74.0"}
141161
]
142162
optional_dependencies: [false]
143163
steps:
@@ -157,7 +177,7 @@ jobs:
157177
password: ${{secrets.DOCKER_PASSWORD}}
158178
- run: |
159179
pip install -r requirements-test.txt
160-
pip install grpcio==${{ matrix.versions.grpc-version }} grpcio-tools==${{ matrix.versions.grpc-version }} grpcio-health-checking==${{ matrix.versions.grpc-version }}
180+
pip install grpcio==${{ matrix.versions.grpc }} grpcio-tools==${{ matrix.versions.grpc }} grpcio-health-checking==${{ matrix.versions.grpc }}
161181
pip install .
162182
- name: start weaviate
163183
run: /bin/bash ci/start_weaviate.sh ${{ matrix.versions.weaviate }}
@@ -278,14 +298,14 @@ jobs:
278298
fail-fast: false
279299
matrix:
280300
version: [
281-
{ extra: "1.62.0", server: $WEAVIATE_125},
282-
{ extra: "1.66.2", server: $WEAVIATE_126},
283-
{ extra: "1.70.0", server: $WEAVIATE_127},
284-
{ extra: "1.59.5", server: $WEAVIATE_128},
285-
{ extra: "1.62.0", server: $WEAVIATE_129},
286-
{ extra: "1.69.0", server: $WEAVIATE_130},
287-
{ extra: "1.70.0", server: $WEAVIATE_131},
288-
{ extra: "1.71.0", server: $WEAVIATE_132}
301+
$WEAVIATE_125,
302+
$WEAVIATE_126,
303+
$WEAVIATE_127,
304+
$WEAVIATE_128,
305+
$WEAVIATE_129,
306+
$WEAVIATE_130,
307+
$WEAVIATE_131,
308+
$WEAVIATE_132
289309
]
290310
steps:
291311
- name: Checkout
@@ -305,16 +325,15 @@ jobs:
305325
- run: |
306326
pip install -r requirements-test.txt # install test dependencies
307327
pip install weaviate_client-*.whl
308-
pip install grpcio==${{ matrix.version.extra }} grpcio-tools==${{ matrix.version.extra }} grpcio-health-checking==${{ matrix.version.extra }}
309328
- run: rm -r weaviate
310329
- name: start weaviate
311-
run: /bin/bash ci/start_weaviate.sh ${{ matrix.version.server }}
330+
run: /bin/bash ci/start_weaviate.sh ${{ matrix.version }}
312331
- name: Run integration tests without auth secrets (auth tests ran in previous job)
313332
run: pytest -v -n auto --dist loadgroup integration
314333

315334
build-and-publish:
316335
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
317-
needs: [integration-tests, unit-tests, lint-and-format, type-checking, test-package]
336+
needs: [integration-tests, unit-tests, lint-and-format, type-checking, test-package, proto-test]
318337
runs-on: ubuntu-latest
319338
steps:
320339
- name: Checkout

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
Version 4.16.9
5+
--------------
6+
This patch version includes:
7+
- Explicitly depend on protobuf package
8+
49
Version 4.16.8
510
--------------
611
This patch version includes:

proto_test/__init__.py

Whitespace-only changes.

proto_test/test_proto.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
from importlib.metadata import version as metadata_version
3+
from packaging import version
4+
5+
6+
def test_proto_import():
7+
grpc_ver = version.parse(metadata_version("grpcio"))
8+
pb_ver = version.parse(metadata_version("protobuf"))
9+
10+
if (pb_ver >= version.parse("6.30.0") and grpc_ver < version.parse("1.72.0")) or (
11+
pb_ver >= version.parse("5.26.1") and grpc_ver < version.parse("1.63.0")
12+
):
13+
with pytest.raises(Exception) as exc_info:
14+
import weaviate
15+
assert "gRPC incompatibility detected" in str(exc_info.value)
16+
else:
17+
import weaviate
18+
19+
assert weaviate.version is not None

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ install_requires =
3939
authlib>=1.2.1,<2.0.0
4040
pydantic>=2.8.0,<3.0.0
4141
grpcio>=1.59.5,<1.80.0
42+
protobuf>=4.21.6,<7.0.0
4243
deprecation>=2.1.0,<3.0.0
4344
python_requires = >=3.9
4445

weaviate/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import httpx
77
from grpc import Call, StatusCode # type: ignore
88
from grpc.aio import AioRpcError # type: ignore
9+
from packaging import version
910

1011
ERROR_CODE_EXPLANATION = {
1112
413: """Payload Too Large. Try to decrease the batch size or increase the maximum request size on your weaviate
@@ -375,3 +376,10 @@ def __init__(self) -> None:
375376
super().__init__(
376377
'Weaviate Agents (Alpha) functionality requires additional dependencies. Please install them using: "pip install weaviate-client[agents]"'
377378
)
379+
380+
381+
class WeaviateProtobufIncompatibility(Exception):
382+
def __init__(self, pb: version.Version, grpc: version.Version) -> None:
383+
super().__init__(
384+
f"gRPC incompatibility detected. Protobuf: {pb.base_version}, gRPC: {grpc.base_version}. Ensure that your protobuf and grpcio versions are compatible or runtime errors may occur."
385+
)

weaviate/proto/v1/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,24 @@
1313

1414
from importlib.metadata import version as metadata_version
1515

16-
def get_protobuf_version() -> version.Version:
17-
"""Get the installed protobuf version."""
18-
return version.parse(metadata_version('protobuf'))
16+
from weaviate.exceptions import WeaviateProtobufIncompatibility
1917

18+
def get_version(pkg: str)-> version.Version:
19+
return version.parse(metadata_version(pkg))
2020

21-
pb_version = get_protobuf_version()
21+
pb_version, grpc_version = get_version("protobuf"), get_version("grpcio")
2222
if pb_version >= version.parse("6.30.0"):
23+
if grpc_version < version.parse("1.72.0"):
24+
raise WeaviateProtobufIncompatibility(pb_version, grpc_version)
2325
from weaviate.proto.v1.v6300.v1 import weaviate_pb2_grpc, aggregate_pb2, base_pb2, base_search_pb2, batch_delete_pb2, batch_pb2, generative_pb2, health_pb2, health_pb2_grpc, properties_pb2, search_get_pb2, tenants_pb2
2426
elif pb_version >= version.parse("5.26.1"):
27+
if grpc_version < version.parse("1.63.0"):
28+
raise WeaviateProtobufIncompatibility(pb_version, grpc_version)
2529
from weaviate.proto.v1.v5261.v1 import weaviate_pb2_grpc, aggregate_pb2, base_pb2, base_search_pb2, batch_delete_pb2, batch_pb2, generative_pb2, health_pb2, health_pb2_grpc, properties_pb2, search_get_pb2, tenants_pb2
2630
elif pb_version >= version.parse("4.21.6"):
2731
from weaviate.proto.v1.v4216.v1 import weaviate_pb2_grpc, aggregate_pb2, base_pb2, base_search_pb2, batch_delete_pb2, batch_pb2, generative_pb2, health_pb2, health_pb2_grpc, properties_pb2, search_get_pb2, tenants_pb2
2832
else:
29-
raise RuntimeError(f"Unsupported grpcio-tools version: {pb_version}. Only versions 1.50.0+ and <1.80 are supported.")
33+
raise RuntimeError(f"Unsupported protobuf version: {pb_version}. Only versions 4.21.6+ are supported.")
3034

3135
__all__ = [
3236
"aggregate_pb2", "base_pb2", "base_search_pb2", "batch_delete_pb2", "batch_pb2", "generative_pb2", "health_pb2", "health_pb2_grpc", "properties_pb2", "search_get_pb2", "tenants_pb2", "weaviate_pb2_grpc"

weaviate/proto/v1/v4216/v1/batch_pb2.py

Lines changed: 43 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)