Skip to content

Commit 7d70ddf

Browse files
authored
chore: include additional build info (#2333)
1 parent 461602d commit 7d70ddf

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/ansys/geometry/core/_grpc/_services/v0/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def get_backend(self, **kwargs) -> dict: # noqa: D102
8787
"version": backend_version,
8888
"api_server_build_info": api_server_build_info,
8989
"product_build_info": product_build_info,
90+
"additional_info": {k: v for k, v in response.additional_build_info.items()},
9091
}
9192

9293
@protect_grpc

src/ansys/geometry/core/connection/client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def __init__(
229229
self._backend_version = response.get("version")
230230
self._backend_api_server_build_info = response.get("api_server_build_info")
231231
self._backend_product_build_info = response.get("product_build_info")
232+
self._backend_additional_info = response.get("additional_info", {})
232233

233234
# Register the close method to be called at exit - irrespectively of
234235
# the user calling it or not...
@@ -313,12 +314,23 @@ def backend_info(self, indent=0) -> str:
313314
str
314315
String with the backend information.
315316
"""
316-
return (
317+
base_info = (
317318
f"{' ' * indent}Version: {self.backend_version}\n"
318319
f"{' ' * indent}Backend type: {self.backend_type.name}\n"
319320
f"{' ' * indent}Backend number: {self._backend_product_build_info}\n"
320321
f"{' ' * indent}API server number: {self._backend_api_server_build_info}"
321322
)
323+
if self._backend_additional_info:
324+
# Calculate padding to align values consistently
325+
# (19 chars total for label + colon + spaces)
326+
additional_info_lines = [
327+
f"{' ' * indent}{key + ':':<19}{value}"
328+
for key, value in self._backend_additional_info.items()
329+
]
330+
additional_info_str = "\n".join(additional_info_lines)
331+
return f"{base_info}\n{additional_info_str}"
332+
else: # pragma: no cover
333+
return base_info
322334

323335
def __repr__(self) -> str:
324336
"""Represent the client as a string."""

tests/integration/test_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def test_client_backend_info(client: GrpcClient):
5858
assert "Backend number" in backend_info
5959
assert "API server number" in backend_info
6060

61+
# Additional info may or may not be present depending on the backend version
62+
if client._backend_additional_info:
63+
for key in client._backend_additional_info.keys():
64+
assert key in backend_info
65+
6166

6267
def test_client_through_channel(modeler: Modeler):
6368
"""Test the instantiation of a client from a gRPC channel."""

0 commit comments

Comments
 (0)