From ddd526bc0dc3dac3fa8fa8ec6d9af66f6e3e4e69 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:50:21 +0100 Subject: [PATCH 1/3] fix: proper v0/v1 handling --- src/ansys/geometry/core/_grpc/_version.py | 43 +++++++++++++------- src/ansys/geometry/core/connection/client.py | 5 ++- src/ansys/geometry/core/modeler.py | 5 +++ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_version.py b/src/ansys/geometry/core/_grpc/_version.py index 0d905f5e44..cddd3c835c 100644 --- a/src/ansys/geometry/core/_grpc/_version.py +++ b/src/ansys/geometry/core/_grpc/_version.py @@ -23,28 +23,34 @@ from enum import Enum, unique -from google.protobuf.empty_pb2 import Empty import grpc # ATTEMPT v0 IMPORT try: - import ansys.api.dbu.v0.admin_pb2_grpc as dbu_v0_admin_pb2_grpc + from ansys.api.dbu.v0.admin_pb2_grpc import AdminStub as V0HealthStub + from google.protobuf.empty_pb2 import Empty as V0HealthRequest except ImportError: - dbu_v0_admin_pb2_grpc = None + V0HealthStub = None + V0HealthRequest = None + # ATTEMPT v1 IMPORT try: - import ansys.api.dbu.v1.admin_pb2_grpc as dbu_v1_admin_pb2_grpc + from ansys.api.discovery.v1.commands.communication_pb2 import HealthRequest as V1HealthRequest + from ansys.api.discovery.v1.commands.communication_pb2_grpc import ( + CommunicationStub as V1HealthStub, + ) except ImportError: - dbu_v1_admin_pb2_grpc = None + V1HealthStub = None + V1HealthRequest = None @unique class GeometryApiProtos(Enum): """Enumeration of the supported versions of the gRPC API protocol.""" - V0 = 0, dbu_v0_admin_pb2_grpc - V1 = 1, dbu_v1_admin_pb2_grpc + V0 = 0, V0HealthStub, V0HealthRequest + V1 = 1, V1HealthStub, V1HealthRequest @staticmethod def get_latest_version() -> "GeometryApiProtos": @@ -85,13 +91,14 @@ def verify_supported(self, channel: grpc.Channel) -> bool: ----- This method checks if the server supports the gRPC API protocol version. """ - pb2_grpc = self.value[1] - if pb2_grpc is None: + StubClass = self.value[1] # noqa: N806 + RequestClass = self.value[2] # noqa: N806 + if StubClass is None: return False try: - admin_stub = pb2_grpc.AdminStub(channel) - admin_stub.Health(Empty()) + admin_stub = StubClass(channel) + admin_stub.Health(RequestClass()) return True except grpc.RpcError: return False @@ -126,9 +133,17 @@ def set_proto_version( # If no version specified... Attempt to use all of them, starting # with the latest version if version is None: - version = GeometryApiProtos.get_latest_version() - while not version.verify_supported(channel): - version = GeometryApiProtos.from_int_value(version.value[0] - 1) + # TODO: Once blitz is over, we will enable this... + # https://github.com/ansys/pyansys-geometry/issues/2366 + # + # ---> REPLACE THIS BLOCK <--- + # version = GeometryApiProtos.get_latest_version() + # while not version.verify_supported(channel): + # version = GeometryApiProtos.from_int_value(version.value[0] - 1) + # ---> REPLACE THIS BLOCK <--- + # xxx> DELETE THIS BLOCK DELETE THIS BLOCK Date: Tue, 11 Nov 2025 17:51:03 +0100 Subject: [PATCH 2/3] fix: pre-commit --- src/ansys/geometry/core/_grpc/_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/geometry/core/_grpc/_version.py b/src/ansys/geometry/core/_grpc/_version.py index cddd3c835c..49d3dc9dcc 100644 --- a/src/ansys/geometry/core/_grpc/_version.py +++ b/src/ansys/geometry/core/_grpc/_version.py @@ -141,9 +141,9 @@ def set_proto_version( # while not version.verify_supported(channel): # version = GeometryApiProtos.from_int_value(version.value[0] - 1) # ---> REPLACE THIS BLOCK <--- - # xxx> DELETE THIS BLOCK DELETE THIS BLOCK <--- version = GeometryApiProtos.V0 - # xxx> DELETE THIS BLOCK DELETE THIS BLOCK <--- # Return the version return version From 4a7a6aa753233a438f7a4c010609ad80659aebd4 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 11 Nov 2025 16:54:29 +0000 Subject: [PATCH 3/3] chore: adding changelog file 2368.added.md [dependabot-skip] --- doc/changelog.d/2368.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/2368.added.md diff --git a/doc/changelog.d/2368.added.md b/doc/changelog.d/2368.added.md new file mode 100644 index 0000000000..8f532c65f4 --- /dev/null +++ b/doc/changelog.d/2368.added.md @@ -0,0 +1 @@ +Properly handling v0 and v1 initialization