Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize CGrpcServer getters #1284

Merged
merged 13 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
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 @@
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

Check warning on line 150 in src/ansys/dpf/core/result_info.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/result_info.py#L150

Added line #L150 was not covered by tests

return _description(self._internal_obj, self._server)

Check warning on line 152 in src/ansys/dpf/core/result_info.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/result_info.py#L152

Added line #L152 was not covered by tests

@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
6 changes: 6 additions & 0 deletions src/ansys/dpf/gate/result_info_grpcapi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import functools

PProfizi marked this conversation as resolved.
Show resolved Hide resolved
from ansys.dpf.gate.generated import result_info_abstract_api
from ansys.dpf.gate.data_processing_grpcapi import DataProcessingGRPCAPI
from ansys.dpf.gate.object_handler import ObjHandler
Expand All @@ -24,6 +26,7 @@ def init_result_info_environment(result_info):
result_info._deleter_func = (_get_stub(result_info._server).Delete, lambda obj: obj._internal_obj)

@staticmethod
@functools.lru_cache(maxsize=50, typed=False)
PProfizi marked this conversation as resolved.
Show resolved Hide resolved
def list(result_info):
from types import SimpleNamespace
server = result_info._server
Expand Down Expand Up @@ -55,6 +58,7 @@ def list(result_info):
return response

@staticmethod
@functools.lru_cache(maxsize=50, typed=False)
PProfizi marked this conversation as resolved.
Show resolved Hide resolved
def list_result(result_info, idx):
from ansys.grpc.dpf import result_info_pb2
request = result_info_pb2.AvailableResultRequest()
Expand Down Expand Up @@ -219,6 +223,7 @@ def result_info_get_main_title(result_info):
return ResultInfoGRPCAPI.list(result_info).main_title

@staticmethod
@functools.lru_cache(maxsize=50, typed=False)
PProfizi marked this conversation as resolved.
Show resolved Hide resolved
def result_info_get_string_property(result_info, property_name):
from ansys.grpc.dpf import result_info_pb2
request = result_info_pb2.GetStringPropertiesRequest()
Expand All @@ -227,6 +232,7 @@ def result_info_get_string_property(result_info, property_name):
return _get_stub(result_info._server).GetStringProperties(request).properties[property_name]

@staticmethod
@functools.lru_cache(maxsize=50, typed=False)
PProfizi marked this conversation as resolved.
Show resolved Hide resolved
def result_info_get_int_property(result_info, property_name):
from ansys.grpc.dpf import result_info_pb2
request = result_info_pb2.GetStringPropertiesRequest()
Expand Down
Loading