From 6e2a078ff57f8cbb316fadb84d7a6e0769c905b5 Mon Sep 17 00:00:00 2001 From: sohier Date: Tue, 23 Jun 2026 22:17:17 +0000 Subject: [PATCH 1/3] Add grpcio-tools --- kaggle_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/kaggle_requirements.txt b/kaggle_requirements.txt index 18b5fbdd..39b4c4ec 100644 --- a/kaggle_requirements.txt +++ b/kaggle_requirements.txt @@ -40,6 +40,7 @@ google-cloud-aiplatform google-cloud-videointelligence google-cloud-vision google-genai +grpcio-tools>=1.60.0 gpxpy h2o haversine From 7b5605b957d31eb2882e7a79c6a1f7938bf6bb72 Mon Sep 17 00:00:00 2001 From: sohier Date: Wed, 24 Jun 2026 22:15:43 +0000 Subject: [PATCH 2/3] Smoke test & patch --- Dockerfile.tmpl | 3 +- kaggle_requirements.txt | 1 - tests/test_grpcio_tools.py | 59 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tests/test_grpcio_tools.py diff --git a/Dockerfile.tmpl b/Dockerfile.tmpl index d9d38935..472e7434 100644 --- a/Dockerfile.tmpl +++ b/Dockerfile.tmpl @@ -26,8 +26,9 @@ RUN uv pip install --no-build-isolation --no-cache --system "git+https://github. # b/404590350: Ray and torchtune have conflicting cli named `tune`. `ray` is not part of Colab's base image. Re-install `tune` to ensure the torchtune CLI is available by default. # b/468367647: Unpin protobuf, version greater than v5.29.5 causes issues with numerous packages +# grpcio-tools must be installed here (not in kaggle_requirements.txt) to stay version-compatible with protobuf. RUN uv pip install --system --force-reinstall --no-cache --no-deps torchtune -RUN uv pip install --system --force-reinstall --no-cache "protobuf==5.29.5" +RUN uv pip install --system --force-reinstall --no-cache "protobuf==5.29.5" "grpcio-tools>=1.60.0" # Adding non-package dependencies: ADD clean-layer.sh /tmp/clean-layer.sh diff --git a/kaggle_requirements.txt b/kaggle_requirements.txt index 39b4c4ec..18b5fbdd 100644 --- a/kaggle_requirements.txt +++ b/kaggle_requirements.txt @@ -40,7 +40,6 @@ google-cloud-aiplatform google-cloud-videointelligence google-cloud-vision google-genai -grpcio-tools>=1.60.0 gpxpy h2o haversine diff --git a/tests/test_grpcio_tools.py b/tests/test_grpcio_tools.py new file mode 100644 index 00000000..cf8fc8c6 --- /dev/null +++ b/tests/test_grpcio_tools.py @@ -0,0 +1,59 @@ +import os +import subprocess +import sys +import tempfile +import unittest + +PROTO_CONTENT = """\ +syntax = "proto3"; + +package smoketest; + +message PingRequest { + string message = 1; +} + +message PingReply { + string message = 1; +} + +service PingService { + rpc Ping (PingRequest) returns (PingReply); +} +""" + + +class TestGrpcioTools(unittest.TestCase): + def test_compile_proto(self): + with tempfile.TemporaryDirectory() as tmpdir: + proto_path = os.path.join(tmpdir, "ping.proto") + with open(proto_path, "w") as f: + f.write(PROTO_CONTENT) + + subprocess.check_call([ + sys.executable, "-m", "grpc_tools.protoc", + f"--proto_path={tmpdir}", + f"--python_out={tmpdir}", + f"--grpc_python_out={tmpdir}", + f"--pyi_out={tmpdir}", + "ping.proto", + ]) + + pb2_path = os.path.join(tmpdir, "ping_pb2.py") + pb2_grpc_path = os.path.join(tmpdir, "ping_pb2_grpc.py") + pyi_path = os.path.join(tmpdir, "ping_pb2.pyi") + self.assertTrue(os.path.exists(pb2_path)) + self.assertTrue(os.path.exists(pb2_grpc_path)) + self.assertTrue(os.path.exists(pyi_path)) + + sys.path.insert(0, tmpdir) + try: + import ping_pb2 + import ping_pb2_grpc + + req = ping_pb2.PingRequest(message="hello") + self.assertEqual(req.message, "hello") + self.assertTrue(hasattr(ping_pb2_grpc, "PingServiceStub")) + self.assertTrue(hasattr(ping_pb2_grpc, "PingServiceServicer")) + finally: + sys.path.remove(tmpdir) From 3d1fd84ed6880bc1c30c08642c2f7ed083ba9266 Mon Sep 17 00:00:00 2001 From: sohier Date: Wed, 24 Jun 2026 22:23:59 +0000 Subject: [PATCH 3/3] Format & simplify test --- tests/test_grpcio_tools.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/tests/test_grpcio_tools.py b/tests/test_grpcio_tools.py index cf8fc8c6..cc0c6418 100644 --- a/tests/test_grpcio_tools.py +++ b/tests/test_grpcio_tools.py @@ -30,14 +30,18 @@ def test_compile_proto(self): with open(proto_path, "w") as f: f.write(PROTO_CONTENT) - subprocess.check_call([ - sys.executable, "-m", "grpc_tools.protoc", - f"--proto_path={tmpdir}", - f"--python_out={tmpdir}", - f"--grpc_python_out={tmpdir}", - f"--pyi_out={tmpdir}", - "ping.proto", - ]) + subprocess.check_call( + [ + sys.executable, + "-m", + "grpc_tools.protoc", + f"--proto_path={tmpdir}", + f"--python_out={tmpdir}", + f"--grpc_python_out={tmpdir}", + f"--pyi_out={tmpdir}", + "ping.proto", + ] + ) pb2_path = os.path.join(tmpdir, "ping_pb2.py") pb2_grpc_path = os.path.join(tmpdir, "ping_pb2_grpc.py") @@ -47,13 +51,10 @@ def test_compile_proto(self): self.assertTrue(os.path.exists(pyi_path)) sys.path.insert(0, tmpdir) - try: - import ping_pb2 - import ping_pb2_grpc - - req = ping_pb2.PingRequest(message="hello") - self.assertEqual(req.message, "hello") - self.assertTrue(hasattr(ping_pb2_grpc, "PingServiceStub")) - self.assertTrue(hasattr(ping_pb2_grpc, "PingServiceServicer")) - finally: - sys.path.remove(tmpdir) + import ping_pb2 + import ping_pb2_grpc + + req = ping_pb2.PingRequest(message="hello") + self.assertEqual(req.message, "hello") + self.assertTrue(hasattr(ping_pb2_grpc, "PingServiceStub")) + self.assertTrue(hasattr(ping_pb2_grpc, "PingServiceServicer"))