Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/ansys/geometry/core/_grpc/_services/v0/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def get_backend(self, **kwargs) -> dict: # noqa: D102
"version": backend_version,
"api_server_build_info": api_server_build_info,
"product_build_info": product_build_info,
"additional_info": {k: v for k, v in response.additional_build_info.items()},
}

@protect_grpc
Expand Down
14 changes: 13 additions & 1 deletion src/ansys/geometry/core/connection/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def __init__(
self._backend_version = response.get("version")
self._backend_api_server_build_info = response.get("api_server_build_info")
self._backend_product_build_info = response.get("product_build_info")
self._backend_additional_info = response.get("additional_info", {})

# Register the close method to be called at exit - irrespectively of
# the user calling it or not...
Expand Down Expand Up @@ -313,12 +314,23 @@ def backend_info(self, indent=0) -> str:
str
String with the backend information.
"""
return (
base_info = (
f"{' ' * indent}Version: {self.backend_version}\n"
f"{' ' * indent}Backend type: {self.backend_type.name}\n"
f"{' ' * indent}Backend number: {self._backend_product_build_info}\n"
f"{' ' * indent}API server number: {self._backend_api_server_build_info}"
)
if self._backend_additional_info:
# Calculate padding to align values consistently
# (19 chars total for label + colon + spaces)
additional_info_lines = [
f"{' ' * indent}{key + ':':<19}{value}"
for key, value in self._backend_additional_info.items()
]
additional_info_str = "\n".join(additional_info_lines)
return f"{base_info}\n{additional_info_str}"
else: # pragma: no cover
return base_info

def __repr__(self) -> str:
"""Represent the client as a string."""
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def test_client_backend_info(client: GrpcClient):
assert "Backend number" in backend_info
assert "API server number" in backend_info

# Additional info may or may not be present depending on the backend version
if client._backend_additional_info:
for key in client._backend_additional_info.keys():
assert key in backend_info


def test_client_through_channel(modeler: Modeler):
"""Test the instantiation of a client from a gRPC channel."""
Expand Down
Loading