Skip to content

Commit

Permalink
Optimize CGrpcServer getters (#1284)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PProfizi authored Nov 24, 2023
1 parent ff8c5e9 commit 8048e2b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/ansys/dpf/core/result_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ def __str__(self):
return txt
except Exception as e:
raise e
from ansys.dpf.core.core import _description

return _description(self._internal_obj, self._server)
@property
def _description(self):
from ansys.dpf.core.core import _description

return _description(self._internal_obj, self._server)

@property
def _names(self):
Expand Down
25 changes: 15 additions & 10 deletions src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,8 @@ def __init__(
self._grpc_client_path = load_api.load_grpc_client(ansys_path=ansys_path)
self._own_process = launch_server
self._local_server = False
self._os = None
self._version = None

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

Expand Down Expand Up @@ -735,21 +737,24 @@ def _check_first_call(self, num_connection_tryouts):

@property
def version(self):
from ansys.dpf.gate import data_processing_capi, integral_types
if not self._version:
from ansys.dpf.gate import data_processing_capi, integral_types

api = data_processing_capi.DataProcessingCAPI
major = integral_types.MutableInt32()
minor = integral_types.MutableInt32()
api.data_processing_get_server_version_on_client(self.client, major, minor)
out = str(int(major)) + "." + str(int(minor))
return out
api = data_processing_capi.DataProcessingCAPI
major = integral_types.MutableInt32()
minor = integral_types.MutableInt32()
api.data_processing_get_server_version_on_client(self.client, major, minor)
self._version = str(int(major)) + "." + str(int(minor))
return self._version

@property
def os(self):
from ansys.dpf.gate import data_processing_capi
if not self._os:
from ansys.dpf.gate import data_processing_capi

api = data_processing_capi.DataProcessingCAPI
return api.data_processing_get_os_on_client(self.client)
api = data_processing_capi.DataProcessingCAPI
self._os = api.data_processing_get_os_on_client(self.client)
return self._os

def _create_shutdown_funcs(self):
from ansys.dpf.gate import data_processing_capi
Expand Down

0 comments on commit 8048e2b

Please sign in to comment.