Skip to content

Commit 8048e2b

Browse files
authored
Optimize CGrpcServer getters (#1284)
* Add ResultInfo._description in result_info.py * Bypass location in available results when LegacyGrpc as it is too slow * Tests on ResultInfo.__str__ skip LegacyGrpc * Cache call to result_info_grpcapi.py list_result * Cache call to result_info_grpcapi.py result_info_get_int_property * Cache call to result_info_grpcapi.py result_info_get_string_property * Cache call to result_info_grpcapi.py list * Revert "Tests on ResultInfo.__str__ skip LegacyGrpc" This reverts commit ff45b25. * Revert "Bypass location in available results when LegacyGrpc as it is too slow" This reverts commit e9a2888. * Remove unreachable code * Cache GrpcServer.version and GrpcServer.os * Remove useless import * Remove changes to gate code
1 parent ff8c5e9 commit 8048e2b

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/ansys/dpf/core/result_info.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ def __str__(self):
144144
return txt
145145
except Exception as e:
146146
raise e
147-
from ansys.dpf.core.core import _description
148147

149-
return _description(self._internal_obj, self._server)
148+
@property
149+
def _description(self):
150+
from ansys.dpf.core.core import _description
151+
152+
return _description(self._internal_obj, self._server)
150153

151154
@property
152155
def _names(self):

src/ansys/dpf/core/server_types.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ def __init__(
678678
self._grpc_client_path = load_api.load_grpc_client(ansys_path=ansys_path)
679679
self._own_process = launch_server
680680
self._local_server = False
681+
self._os = None
682+
self._version = None
681683

682684
address = f"{ip}:{port}"
683685

@@ -735,21 +737,24 @@ def _check_first_call(self, num_connection_tryouts):
735737

736738
@property
737739
def version(self):
738-
from ansys.dpf.gate import data_processing_capi, integral_types
740+
if not self._version:
741+
from ansys.dpf.gate import data_processing_capi, integral_types
739742

740-
api = data_processing_capi.DataProcessingCAPI
741-
major = integral_types.MutableInt32()
742-
minor = integral_types.MutableInt32()
743-
api.data_processing_get_server_version_on_client(self.client, major, minor)
744-
out = str(int(major)) + "." + str(int(minor))
745-
return out
743+
api = data_processing_capi.DataProcessingCAPI
744+
major = integral_types.MutableInt32()
745+
minor = integral_types.MutableInt32()
746+
api.data_processing_get_server_version_on_client(self.client, major, minor)
747+
self._version = str(int(major)) + "." + str(int(minor))
748+
return self._version
746749

747750
@property
748751
def os(self):
749-
from ansys.dpf.gate import data_processing_capi
752+
if not self._os:
753+
from ansys.dpf.gate import data_processing_capi
750754

751-
api = data_processing_capi.DataProcessingCAPI
752-
return api.data_processing_get_os_on_client(self.client)
755+
api = data_processing_capi.DataProcessingCAPI
756+
self._os = api.data_processing_get_os_on_client(self.client)
757+
return self._os
753758

754759
def _create_shutdown_funcs(self):
755760
from ansys.dpf.gate import data_processing_capi

0 commit comments

Comments
 (0)